[dpdk-dev] [PATCH v2 11/11] lib/librte_vhost: support dynamically registering vhost server

Ananyev, Konstantin konstantin.ananyev at intel.com
Mon Feb 16 18:11:15 CET 2015



> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Huawei Xie
> Sent: Thursday, February 12, 2015 5:07 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v2 11/11] lib/librte_vhost: support dynamically registering vhost server
> 
> * support calling rte_vhost_driver_register after rte_vhost_driver_session_start
> * add mutext to protect fdset from concurrent access
> * add busy flag in fdentry. this flag is set before cb and cleared after cb is finished.
> 
> mutex lock scenario in vhost:
> 
> * event_dispatch(in rte_vhost_driver_session_start) runs in a seperate thread, infinitely
> processing vhost messages through cb(callback).
> * event_dispatch acquires the lock, get the cb and its context, mark the busy flag,
> and releases the mutex.
> * vserver_new_vq_conn cb calls fdset_add, which acquires the mutex and add new fd into fdset.
> * vserver_message_handler cb frees data context, marks remove flag to request to delete
> connfd(connection fd) from fdset.
> * after cb returns, event_dispatch
>   1. clears busy flag.
>   2. if there is remove request, call fdset_del, which acquires mutex, checks busy flag, and
> removes connfd from fdset.
> * rte_vhost_driver_unregister(not implemented) runs in another thread, acquires the mutex,
> calls fdset_del to remove fd(listenerfd) from fdset. Then it could free data context.
> 
> The above steps ensures fd data context isn't freed when cb is using.
> 
> VM(s) should have been shutdown before rte_vhost_driver_unregister.
> 
> Signed-off-by: Huawei Xie <huawei.xie at intel.com>

Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>

> ---
>  lib/librte_vhost/vhost_user/fd_man.c         | 63 +++++++++++++++++++++++++---
>  lib/librte_vhost/vhost_user/fd_man.h         |  5 ++-
>  lib/librte_vhost/vhost_user/vhost-net-user.c | 34 +++++++++------
>  3 files changed, 82 insertions(+), 20 deletions(-)
> 


More information about the dev mailing list