From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wang, Zhihong" Subject: Re: [PATCH v3 2/2] vhost: Add VHOST PMD 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> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "ann.zhuangyanying@huawei.com" To: Tetsuya Mukawa , "dev@dpdk.org" , "Liu, Yuanhan" 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) In-Reply-To: <1447046221-20811-3-git-send-email-mukawa@igel.co.jp> Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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"); > +} > + > ...