[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 5/6] vhost-user: add multiple queue support
From: |
Jason Wang |
Subject: |
Re: [Qemu-devel] [PATCH 5/6] vhost-user: add multiple queue support |
Date: |
Mon, 14 Sep 2015 18:06:37 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/14/2015 04:58 PM, Yuanhan Liu wrote:
> From: Changchun Ouyang <address@hidden>
>
> This patch is initially based a patch from Nikolay Nikolaev.
>
> Here is the latest version for adding vhost-user multiple queue support,
> by creating a nc and vhost_net pair for each queue.
>
> What differs from last version is that this patch addresses two major
> concerns from Michael, and fixes one hidden bug.
>
> - Concern #1: no feedback when the backend can't support # of
> requested queues(by providing queues=# option).
>
> Here we address this issue by querying VHOST_USER_PROTOCOL_F_MQ
> protocol features first, if not set, it means the backend don't
> support mq feature, and let max_queues be 1. Otherwise, we send
> another message, VHOST_USER_GET_QUEUE_NUM, for getting the max_queues
> the backend supports.
>
> At vhost-user initiation stage(net_vhost_user_start), we then initiate
> one queue first, which, in the meantime, also gets the max_queues.
> We then do a simple compare: if requested_queues > max_queues, we
> exit(I guess it's safe to exit here, as the vm is not running yet).
>
> - Concern #2: some messages are sent more times than necessary.
>
> We came an agreement with Michael that we could categorize vhost
> user messages to 2 types: none-vring specific messages, which should
> be sent only once, and vring specific messages, which should be sent
> per queue.
>
> Here I introduced a helper function vhost_user_one_time_request(),
> which lists following messages as none-vring specific messages:
>
> VHOST_USER_GET_FEATURES
> VHOST_USER_SET_FEATURES
> VHOST_USER_GET_PROTOCOL_FEATURES
> VHOST_USER_SET_PROTOCOL_FEATURES
> VHOST_USER_SET_OWNER
> VHOST_USER_RESET_DEVICE
> VHOST_USER_SET_MEM_TABLE
> VHOST_USER_GET_QUEUE_NUM
>
> For above messages, we simply ignore them when they are not sent the first
> time.
>
> I also observed a hidden bug from last version. We register the char dev
> event handler N times, which is not necessary, as well as buggy: A later
> register overwrites the former one, as qemu_chr_add_handlers() will not
> chain those handlers, but instead overwrites the old one. So, in theory,
> invoking qemu_chr_add_handlers N times will not end up with calling the
> handler N times.
>
> However, the reason the handler is invoked N times is because we start
> the backend(the connection server) first, and hence when net_vhost_user_init()
> is executed, the connection is already established, and
> qemu_chr_add_handlers()
> then invoke the handler immediately, which just looks like we invoke the
> handler(net_vhost_user_event) directly from net_vhost_user_init().
>
> The solution I came up with is to make VhostUserState as an upper level
> structure, making it includes N nc and vhost_net pairs:
>
> typedef struct VhostUserNetPair {
> NetClientState *nc;
> VHostNetState *vhost_net;
> } VhostUserNetPair;
>
> typedef struct VhostUserState {
> CharDriverState *chr;
> bool running;
> int queues;
> struct VhostUserNetPair pairs[];
> } VhostUserState;
>
> v8: set net->dev.vq_index correctly inside vhost_net_init() based on the
> value from net->nc->queue_index.
>
> Signed-off-by: Nikolay Nikolaev <address@hidden>
> Signed-off-by: Changchun Ouyang <address@hidden>
> Signed-off-by: Yuanhan Liu <address@hidden>
> ---
> docs/specs/vhost-user.txt | 13 +++++
> hw/net/vhost_net.c | 5 +-
> hw/virtio/vhost-user.c | 32 ++++++++++-
> include/net/net.h | 1 +
> net/vhost-user.c | 140
> +++++++++++++++++++++++++++++++++-------------
> qapi-schema.json | 6 +-
> qemu-options.hx | 5 +-
> 7 files changed, 157 insertions(+), 45 deletions(-)
Saw this version too late. I've some comments for last version and looks
like more of them still apply here. Please see there.
Thanks
- [Qemu-devel] [PATCH 0/6 v8] vhost-user multiple queue support, Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 2/6] vhost-user: add protocol feature negotiation, Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 1/6] vhost-user: use VHOST_USER_XXX macro for switch statement, Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 3/6] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE, Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 4/6] vhost-user: add VHOST_USER_GET_QUEUE_NUM message, Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 6/6] vhost-user: add a new message to disable/enable a specific virt queue., Yuanhan Liu, 2015/09/14
- [Qemu-devel] [PATCH 5/6] vhost-user: add multiple queue support, Yuanhan Liu, 2015/09/14
- Re: [Qemu-devel] [PATCH 5/6] vhost-user: add multiple queue support,
Jason Wang <=