From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA610A00C4; Fri, 1 Jul 2022 12:11:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AF5F4069D; Fri, 1 Jul 2022 12:11:11 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 5AFA040150; Fri, 1 Jul 2022 12:11:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656670269; x=1688206269; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ysA21vmuqIf7oNYQFgqJPwFPYALzdqkEWV+iQDDaWsE=; b=DS7dRRkVT/8qib8Q+fvhWHAkAZzaS0zxNW8ZlL/n8PgeMf6UVGrxmqKS V+kg7hfWRzWrE3hDCa0xWXNGkPzIR7nfLdOlgLXB6qkGZCtkySw7Ej1BU AdffRP4jr0Dty33/frqCqCnB81VlyQ/Qn1X5MUpundJKcbw2isFVWCTSe bNkDuP8ZPwaWp/Ciev1C9E5R5nK3k3JC8vhyY0F5RsPOz2tmJOHxSwst2 /fAMW4HaWqQp8ko9E7bQGv9gSTliW5AnyPr+5bytpzISHedtcYeGXdiwk oxgsHhLlRdW+FeqHOQ6cKf4k5JPOpLJ3W5QMUsCYU8tzlfRU8MPv3rUJO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="281380381" X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="281380381" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2022 03:11:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="918428687" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP; 01 Jul 2022 03:11:08 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Fri, 1 Jul 2022 03:11:07 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Fri, 1 Jul 2022 03:11:07 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Fri, 1 Jul 2022 03:11:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N6pX8K8N/dAKQnBwewtcAgObVA+EHm1KvqzvJEpRVHk+/Gjdddb5rqO3Brngqen7bXHtbWpHz5KMPmajmaXzCwv6K5wZoZc4Szpi8XjeKRCsGg4xIrEgZUhDjpoU0AsNbf+he9KkM2/lJ82f77jD05LTRsfMAHPdKd8IQW3YCr7h4UI+srVpqqGlOtq7gWt5U5kU3eVsJj+FLgEUI+61kG5xAdaNCnObDOrbWVhxLTHI5StiRxkiXOLI4eIB6zbFQfnzZTANHNU6cWIjAbV2rDB10B5AM4100fAmc1HdEcT6FCpAMr/jUvgfayiZ3TwFEQ4cdKduIsAxJjjn/Pcr8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qwBYD23U3bYc9DtJg3BuEnrADQ4inYu7sAtTwddw9V4=; b=SOvuD3aeJZBhrHVw14/uMGZ8/5yZtfn/9zB37B3eGo/IjwkkzjWSY9Xo7Q178VgGDTTh4lw5rNSSjoS37hi6ko3DFxqsyKj+On1j8u8VBQNtE+Li4uyUQJ23POa/BpLqffWyNb27W1etwlygHwvL4Y86E9/RPVVCFuFMNqrqyNisuVG8DGsNNK30MtR824W9zoEj364AWWRD+Vny4t372krOpj54VA428vID4C4ikTK28ZsPRKDnCKW5acilxBt7s8+hxf7nmhxbPGI2LQjEjPLlH1LpjNoxG8SWfdrxiQTLPOEhok1tJ3kAr9B+JGtzQEpLS623X4r376m3zYm/Og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by MW5PR11MB5764.namprd11.prod.outlook.com (2603:10b6:303:197::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Fri, 1 Jul 2022 10:11:05 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9%7]) with mapi id 15.20.5373.018; Fri, 1 Jul 2022 10:11:05 +0000 From: "Xia, Chenbo" To: "Wang, YuanX" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "He, Xingguang" , "stable@dpdk.org" Subject: RE: [PATCH] net/virtio: fix socket nonblocking mode affects initialization Thread-Topic: [PATCH] net/virtio: fix socket nonblocking mode affects initialization Thread-Index: AQHYgfP3brFb8k2OJ0eEfEGYeBdW1K1pYcsg Date: Fri, 1 Jul 2022 10:11:05 +0000 Message-ID: References: <20220617024229.706826-1-yuanx.wang@intel.com> In-Reply-To: <20220617024229.706826-1-yuanx.wang@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 36fb95a9-a323-4d79-33e9-08da5b4a0299 x-ms-traffictypediagnostic: MW5PR11MB5764:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kAtXJYP2Zjc5KlL/WLPjLYzPhsB69si57f4OnjEUvWFNg2JrxX4S+T8bCBr8UPu4cHzv/oq51LxZgl8JdQ66gO9TebGiwniR8xOi23PgwjZsQNVYphJxQtQvtmlM7xttE3+rK4C4M3JwG6d0vuWX/EnAcGNwxlTlbd3Ok+5A3ad68VITlhdyUVr8XEbJphP/oMGdfumwPaTKcIgzzED0D3LybHJKgyi5e6sMOxp7nan6u0SlLHm01iHDzL3FTdCpe2sfMk8PI1HNv0WGEBQj/29mklW++SkMoIuxGD9Y4qyMcdkW+JTz4hdcFUYFSkR5x87xZhI4frYxfSV0fV3Ju1/K1dbGAzS8rdUmZJAQc4w9AB2cniBcDmOMe2pNLLc6qwydDOWYKVMejS5RewCjjJeda3aZ3lLJ3wapRiPuaYsu/TXwQjuZUJjlD8DNGO4BqmyKYgr+H3D4TpVpIInQ1RXrTlNU2NBxWaUA/8ZVdcU8z7k5re2qeEnakGWYNJzQqI96iOsGfzE8KqicGaxv4RRkf9KMkKPQd8JU08b+FrndiQIlTyTQVZ+CsxG92ufpd/i7ej8HtD+cNkLg4LhGmTRDHU4AEOa6WijnwaRJkMxo3ElvaOzXfuVmfjDRSi+mVXS7T7hDiv56vAfpAgKkPedIkoKY7KsDwLQzXVBzqZmvZG/30UDXiRd8SiuVqOMP6Fab1xUBVpbRyLYK4hHErsBU92Ic0Dsfx0UmyatzjQ+lhtExeDHpbXXSvM97Jb2WNlsubg533Ab3VHgShcwyYvs12DW65Lqz+eIP3VmJ+h5gzY+leQAmt9pTiB+h6QeF x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(346002)(39860400002)(376002)(366004)(136003)(478600001)(82960400001)(71200400001)(186003)(38100700002)(83380400001)(122000001)(53546011)(6506007)(7696005)(33656002)(9686003)(316002)(54906003)(110136005)(41300700001)(66556008)(64756008)(8676002)(66476007)(66946007)(66446008)(55016003)(8936002)(5660300002)(52536014)(4326008)(38070700005)(76116006)(86362001)(2906002)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cdTD4Ee3G7PHspisj6Pt2s+G035L7Jq74roREooPmIFa8S8rMIJT5XMpgJi5?= =?us-ascii?Q?7vdokw1y1KapuZq7NJic30QNkzzoVGOSsyrezbcVkwNLIHP5abr86kicxnPx?= =?us-ascii?Q?hIqcojOgt4T0ljpWmf7ZIeGO73si4aopDgGDz2xr+lf3W9QVqa/6dBxgKdcO?= =?us-ascii?Q?w4o98Q6+XjOCOCq5kOFv35vmYIPFzeY636vIbn0skEix6U6gIdpNHbjt3jfe?= =?us-ascii?Q?TGzW0dOWW7unejUSijQvB/nnrfRXviZnhD/vQV7/jz5iRP7dqh20J+jxzSxF?= =?us-ascii?Q?EwABn1QO5TmUadWa5v+PH0TFFhGVo7VR/M2OBLoIrG0EE0twMW8tMM+tZUCy?= =?us-ascii?Q?EDZAcBdYtDlNQZJr31AsGBxqW6wluxhZTw8OXWxP0Jnk88DwLR70F7LqMXyk?= =?us-ascii?Q?oAgUyNpahZmVvyaigur4hVE4SNz1IHOTzvltGh6H1q88fSk5afHXGf3rZV0I?= =?us-ascii?Q?UxRcrRKRJ8kCli/SIwTKvywvTdF7TDiSMpe6MG/NmH31nhom7SRhCfs2crEl?= =?us-ascii?Q?DXcZVfHb43X7c/1CYeUMVwzDV5FW+dNr+VetoYy+mxOGy0nt+GZ9/HcILlyO?= =?us-ascii?Q?Q5cUJjalJBEfZ9/B0z07TIue9Lja2bEwspTmHNQBi+QXxz0UhEvupt9VFaNA?= =?us-ascii?Q?xA3L+DIlVX149LKZkoFiRm8gOYZTbxfuLUBPax72v2i44xq0oK/Wbf5y39rd?= =?us-ascii?Q?X2aLLcS5KUJH+s2WmY6NeGRNvopbRXmJNPkv2QdDtRT0KBX9tLhw312PeTiR?= =?us-ascii?Q?VYukVSdw/VSX67BSxbp9yFviLlitPE7/pNOCRhSRvY4KlUiChu5PXtVXXkCX?= =?us-ascii?Q?McvcqgIzyCCui+09rWqK02eaPcRPTPF67sWNlpB8q4tZoxptvUYq2GdJhQkD?= =?us-ascii?Q?dcF5i12oM7ig6bVTITE0BAjx+bv14N2bHk1fLUT5TkNWfcD+h7TpPxSBxlyc?= =?us-ascii?Q?epqzGMpFn/nOW5EJPCpZJ3SgigMwBgHAUGG3qeuV8e6DQHXvMGhD2y36cdMn?= =?us-ascii?Q?PXGLbnBlCc53FYDT73YkIEEBgZJ1goot5CgBP+ffJOSwz5gAPucgP7Ha0RxF?= =?us-ascii?Q?hF8wComhPPyS81inzd57HIXv5DE6y/RCH2i9jXHTrrV7BVyOUIYqwzXYgtDN?= =?us-ascii?Q?qXCMLzYAWx5WH4XxZqq9Mg2/T53HtHo0ySimHJsVrGeYS2KtSMiuRHksz1mx?= =?us-ascii?Q?BL5UokhQsoV+pmRQQL2qSaaVXhnEJmHOu1lBqnpKqenCxh+ek1oBB1malorD?= =?us-ascii?Q?uU58DsdAfifgizwa1z4EvGdBgpmiXG7BwJqdfgtV/htx410g2HKDkhzue8o/?= =?us-ascii?Q?r1oPrYQ4TRLEqalCGAedpcYo2gmMcPbWeyVl9slo7XYfH8B4wMUi9R1NVnOX?= =?us-ascii?Q?p63TJURYd4W2CqZgAyx0VwknHjdhNPL6aDhIaZDmUlARtxqSrNkA2h5G4JgG?= =?us-ascii?Q?QcGM5Yhbfy5gMq/QCCYUAB5Lc9zl6HxosCBgc619mlIcjBO0PS31KHINTDv4?= =?us-ascii?Q?IHcp+ir0qZFJ8crlpWGmeZbFt/A/qrbToLu6hrafH8jgBxP7fYlI5Xp9DaUy?= =?us-ascii?Q?bKCaxpmcnuasQk6SeBKJmMXtlNViFlx6UOjI3eL2?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36fb95a9-a323-4d79-33e9-08da5b4a0299 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2022 10:11:05.5336 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SvsRqqmEKlH39C0NTvfkasb65P4OvNlkI+cQt7rKRJ60YdUObrbM74SEEXosmMmyrO6NXag9tFRsWCnN7kQflg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR11MB5764 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Wang, YuanX > Sent: Friday, June 17, 2022 10:42 AM > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > dev@dpdk.org > Cc: Hu, Jiayu ; He, Xingguang ; > Wang, YuanX ; stable@dpdk.org > Subject: [PATCH] net/virtio: fix socket nonblocking mode affects > initialization >=20 > The virtio-user initialization requires unix socket to receive backend > messages in block mode. However, vhost_user_update_link_state() sets > the same socket to nonblocking via fcntl, which affects all threads. > Enabling the rxq interrupt can causes both of these behaviors to occur > concurrently, with the result that the initialization may fail > because no messages are received in nonblocking socket. >=20 > Thread 1: > virtio_init_device() > --> virtio_user_start_device() > --> vhost_user_set_memory_table() > --> vhost_user_check_reply_ack() >=20 > Thread 2: > virtio_interrupt_handler() > --> vhost_user_update_link_state() >=20 > Fix that by replacing O_NONBLOCK with the recv per-call option > MSG_DONTWAIT. >=20 > Fixes: ef53b6030039 ("net/virtio-user: support LSC") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yuan Wang > --- > drivers/net/virtio/virtio_user/vhost_user.c | 15 +-------------- > 1 file changed, 1 insertion(+), 14 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c > b/drivers/net/virtio/virtio_user/vhost_user.c > index 7d1749114d..198bd63d3c 100644 > --- a/drivers/net/virtio/virtio_user/vhost_user.c > +++ b/drivers/net/virtio/virtio_user/vhost_user.c > @@ -940,15 +940,8 @@ vhost_user_update_link_state(struct virtio_user_dev > *dev) >=20 > if (data->vhostfd >=3D 0) { > int r; > - int flags; >=20 > - flags =3D fcntl(data->vhostfd, F_GETFL); > - if (fcntl(data->vhostfd, F_SETFL, flags | O_NONBLOCK) =3D=3D -1) { > - PMD_DRV_LOG(ERR, "error setting O_NONBLOCK flag"); > - return -1; > - } > - > - r =3D recv(data->vhostfd, buf, 128, MSG_PEEK); > + r =3D recv(data->vhostfd, buf, 128, MSG_PEEK | MSG_DONTWAIT); > if (r =3D=3D 0 || (r < 0 && errno !=3D EAGAIN)) { > dev->net_status &=3D (~VIRTIO_NET_S_LINK_UP); > PMD_DRV_LOG(ERR, "virtio-user port %u is down", dev- > >hw.port_id); > @@ -963,12 +956,6 @@ vhost_user_update_link_state(struct virtio_user_dev > *dev) > } else { > dev->net_status |=3D VIRTIO_NET_S_LINK_UP; > } > - > - if (fcntl(data->vhostfd, F_SETFL, > - flags & ~O_NONBLOCK) =3D=3D -1) { > - PMD_DRV_LOG(ERR, "error clearing O_NONBLOCK flag"); > - return -1; > - } > } else if (dev->is_server) { > dev->net_status &=3D (~VIRTIO_NET_S_LINK_UP); > if (virtio_user_dev_server_reconnect(dev) >=3D 0) > -- > 2.25.1 Reviewed-by: Chenbo Xia