From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQet-00076K-DP for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbQep-0008Bo-A4 for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQep-0008Ba-30 for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:06:43 -0400 References: <1442221092-4545-1-git-send-email-yuanhan.liu@linux.intel.com> <1442221092-4545-6-git-send-email-yuanhan.liu@linux.intel.com> From: Jason Wang Message-ID: <55F69C2D.8030607@redhat.com> Date: Mon, 14 Sep 2015 18:06:37 +0800 MIME-Version: 1.0 In-Reply-To: <1442221092-4545-6-git-send-email-yuanhan.liu@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/6] vhost-user: add multiple queue support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yuanhan Liu , qemu-devel@nongnu.org Cc: mst@redhat.com, changchun.ouyang@intel.com On 09/14/2015 04:58 PM, Yuanhan Liu wrote: > From: Changchun Ouyang > > 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 > Signed-off-by: Changchun Ouyang > Signed-off-by: Yuanhan Liu > --- > 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