From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6256E91B6 for ; Thu, 12 Nov 2015 13:52:11 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 12 Nov 2015 04:52:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,281,1444719600"; d="scan'208";a="818178347" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 12 Nov 2015 04:52:10 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 12 Nov 2015 04:52:09 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 12 Nov 2015 04:52:09 -0800 Received: from shsmsx152.ccr.corp.intel.com ([169.254.6.193]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.88]) with mapi id 14.03.0248.002; Thu, 12 Nov 2015 20:52:07 +0800 From: "Wang, Zhihong" To: Tetsuya Mukawa , "dev@dpdk.org" , "Liu, Yuanhan" Thread-Topic: [dpdk-dev] [PATCH v3 2/2] vhost: Add VHOST PMD Thread-Index: AQHRGq4PEMLA9T3mPk2+1Znj979fCJ6YPiLw Date: Thu, 12 Nov 2015 12:52:06 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE09418328A9@SHSMSX152.ccr.corp.intel.com> References: <1446436737-25606-2-git-send-email-mukawa@igel.co.jp> <1447046221-20811-1-git-send-email-mukawa@igel.co.jp> <1447046221-20811-3-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1447046221-20811-3-git-send-email-mukawa@igel.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "ann.zhuangyanying@huawei.com" Subject: Re: [dpdk-dev] [PATCH v3 2/2] vhost: Add VHOST PMD X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2015 12:52:12 -0000 Hi Tetsuya, In my test I created 2 vdev using "--vdev 'eth_vhost0,iface=3D/tmp/sock0,qu= eues=3D1' --vdev 'eth_vhost1,iface=3D/tmp/sock1,queues=3D1'", and the qemu = message got handled in wrong order. The reason is that: 2 threads are created to handle message from 2 sockets,= but their fds are SHARED, so each thread are reading from both sockets. This can lead to incorrect behaviors, in my case sometimes the VHOST_USER_S= ET_MEM_TABLE got handled after VRING initialization and lead to destroy_dev= ice(). Detailed log as shown below: thread 69351 & 69352 are both reading fd 25. T= hanks Yuanhan for helping debugging! Thanks Zhihong ---------------------------------------------------------------------------= -------------------------------------- ----> debug: setting up new vq conn for fd: 23, tid: 69352 VHOST_CONFIG: new virtio connection is 25 VHOST_CONFIG: new device, handle is 0 ----> debug: vserver_message_handler thread id: 69352, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_OWNER ----> debug: vserver_message_handler thread id: 69352, fd: 25 VHOST_CONFIG: read message VHOST_USER_GET_FEATURES ----> debug: vserver_message_handler thread id: 69352, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_CALL VHOST_CONFIG: vring call idx:0 file:26 ----> debug: vserver_message_handler thread id: 69352, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_CALL VHOST_CONFIG: vring call idx:1 file:27 ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_CALL VHOST_CONFIG: vring call idx:0 file:28 ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_CALL VHOST_CONFIG: vring call idx:1 file:26 ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_FEATURES ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_MEM_TABLE ----> debug: device_fh: 0: user_set_mem_table VHOST_CONFIG: mapped region 0 fd:27 to 0x7ff6c0000000 sz:0xa0000 off:0x0 VHOST_CONFIG: mapped region 1 fd:29 to 0x7ff680000000 sz:0x40000000 off:0xc= 0000 ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_NUM ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_BASE ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_ADDR ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_KICK VHOST_CONFIG: vring kick idx:0 file:30 ----> debug: vserver_message_handler thread id: 69352, fd: 25 VHOST_CONFIG: virtio is not ready for processing. ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_BASE ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_ADDR ----> debug: vserver_message_handler thread id: 69351, fd: 25 VHOST_CONFIG: read message VHOST_USER_SET_VRING_KICK VHOST_CONFIG: vring kick idx:1 file:31 VHOST_CONFIG: virtio is now ready for processing. PMD: New connection established VHOST_CONFIG: read message VHOST_USER_SET_VRING_NUM ---------------------------------------------------------------------------= -------------------------------------- > ... > + > +static void *vhost_driver_session(void *param __rte_unused) > +{ > + static struct virtio_net_device_ops *vhost_ops; > + > + vhost_ops =3D rte_zmalloc(NULL, sizeof(*vhost_ops), 0); > + if (vhost_ops =3D=3D NULL) > + rte_panic("Can't allocate memory\n"); > + > + /* set vhost arguments */ > + vhost_ops->new_device =3D new_device; > + vhost_ops->destroy_device =3D destroy_device; > + if (rte_vhost_driver_pmd_callback_register(vhost_ops) < 0) > + rte_panic("Can't register callbacks\n"); > + > + /* start event handling */ > + rte_vhost_driver_session_start(); > + > + rte_free(vhost_ops); > + pthread_exit(0); > +} > + > +static void vhost_driver_session_start(struct pmd_internal *internal) > +{ > + int ret; > + > + ret =3D pthread_create(&internal->session_th, > + NULL, vhost_driver_session, NULL); > + if (ret) > + rte_panic("Can't create a thread\n"); > +} > + > ...