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 13FF7A00C4; Fri, 1 Jul 2022 14:32:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E74EC40A7B; Fri, 1 Jul 2022 14:32:11 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 25EB14069D; Fri, 1 Jul 2022 14:32: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=1656678730; x=1688214730; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=/G8tjsw+mBBaJmX/6OvDPUi8t/ByX0R40c8ME2sm5hg=; b=MjXxItlrUxKMPfN1/WXzyL8w1Y6hefDJDTqqZrvULUiU+zXR/yXvbroo xhlUB64VgzJ7RaaNhglIvZ+lvEk67hh0FzlvHwY3lcTh21BAR6KOLFEkQ 6R0Fc3K5UPGZEc8fVmoTVGIlVvNL15UYr9/Vaq17RCnmaEAAIdsmwLrtB glfeja3G8lfVOOSYznXpAKMy96vgN8LjNEtWjV9q8tQ21qylQPBjVaCvE PUMGmxF3IR4n2XOdulBr2bHLmZw8R6qInzL11Q2930UU+lMzKHfaZXyX4 QyFM6L8huqehGnHCkVBjawEyZJ7qLEgfmHFU0uYrMpgzHiqzzb3oh116n w==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="271413376" X-IronPort-AV: E=Sophos;i="5.92,237,1650956400"; d="scan'208";a="271413376" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2022 05:31:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,237,1650956400"; d="scan'208";a="589322743" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga007.jf.intel.com with ESMTP; 01 Jul 2022 05:31:51 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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 05:31:51 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx607.amr.corp.intel.com (10.18.126.87) 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 05:31:50 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx605.amr.corp.intel.com (10.18.126.85) 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 05:31:50 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by edgegateway.intel.com (192.55.55.71) 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 05:31:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AquSUwoqsD/0udB34r9N1UlQfLOEdBvkXS4T+t/IsY6ue4eAOWygAP15plCn2OKb9OvSPx8dJZeBAuiEdT/EcgqTmLO3083tBef8ejHl5xul6RZ5sHbD+CHYGJAAXvsIxoRPRssZYcatosl9VLSFRJKu8vqWxa8k5tUCxZLHKicMS6iHP/PP/I1QcbyECpni3ZAv289B1PjdCjOGM3Ttx2oQoSid8qTfFrKAPDVmq99k3SpyQ9l9+JRmz5b948NK1k6m0kjHsFoVtnW2xs9e/6e4MCuK21uMtOdplUJIG55lCJNYbws1YS32bD59u459pTIVi+JBS5V4EhCWSIBaAA== 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=/3CdU26hGHUVUsxE56JNqowc3cRpMzFVD1zuqWUid50=; b=YxA3lbnMY218MUtY0qBVCphaY19Vf/eQSHePJvLwXipfMyr6rxmZERJob4F06dSZ4Cg48msED63nAt0T1gbp/eSJ33lB/+1a4gip2XLYmuNp13rYI4B9tyTITjV82U2grDPqd7kOiOpHO0+FrIca+e2PDymS2C0903raulF/no/cDlYtvxx3oBafUI4rHYolpNPPUnq0df0ccrRaoQHnB0AIklYyW7WR/mF5bmPQv3eRJ+i6bAqAU6Yiu6KYPOseJ9OrdIzs+mIJGNU2z+nNzrU91S9P0rPMs7X16gPYVWNsHl1Y6a65SJBep0QNsRn6fO4YZRoeXzKARWXfNmHFlw== 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 BN9PR11MB5516.namprd11.prod.outlook.com (2603:10b6:408:105::13) 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 12:31:48 +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 12:31:48 +0000 From: "Xia, Chenbo" To: "Wang, YuanX" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "He, Xingguang" , "Jiang, Cheng1" , "Ling, WeiX" , "stable@dpdk.org" Subject: RE: [PATCH v2] net/vhost: fix deadlock on vring state change Thread-Topic: [PATCH v2] net/vhost: fix deadlock on vring state change Thread-Index: AQHYiepGH9UKt/Vvz0mw5gKLqVM+f61peSJA Date: Fri, 1 Jul 2022 12:31:48 +0000 Message-ID: References: <20220601142541.605301-1-yuanx.wang@intel.com> <20220627055125.1541652-1-yuanx.wang@intel.com> In-Reply-To: <20220627055125.1541652-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: dac7162a-01cf-4dd2-5e23-08da5b5dab0a x-ms-traffictypediagnostic: BN9PR11MB5516: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: mgkD3zUHclx7pSDEZwhZdc8r36M+8BuF8MFc8vup1coeUpOM/D+MFXRxAfCDUo/LhiRkrqoTvKWWfJ19HahBaTw6/g/xNRwsLikWBFKAQK+8WJDcBfyN757OlXUe+uP/wGXBKx3ZO/WXxF+f8tfEZJM4Wae4kk0ikTeyhjrGQ8EHT4qA545GJ3X4eP+mJpjBCJ5sIBQQ7OpfZHhR6Lyinn4naJxJNUbmFOlLc2TK+Zk8XwpF9Um604b7My+PgajDCKGgV94k1xbPIc7w88AVCoXdzpdy55BdbPldpBTZSrPEznsf5PJqKK5Ws4CZRsQ4kF8KyhcMj5OzP5cR7qtEJSwH9m/ZEemlRX5DfpZ8EvXKfTG+3txQzM4zp/f06GQjYm8RoqDIbyStK7l8cKXXEKcdc8yWMfYbeoBibAv7rADWh8s491cGVR1yt9XHMiD0/zpq2f18E3caIIsyU6RPlA9hfjt4yYeuBlNLmX8XtEiLVarvL33aUtpRcxZXaBbmGIznZjiE7gvB9pdtlUuiWI64ccYZtfzJjVShrIRf/BlB/3fXmgkzseVv+xQLNUEH6/auwuYZxISwdU5fmsPZ8dcB6cxcVprIJZ9rrBpaW7sPEAYDSW8b0v10d1iY0V9j9yEHbatPyohyEp25/DDLhLgxTa9I0LROGdDM8cvPzNVCAK26iPpRYhmLn4StKq1cpqxOTiiCUk8d4Qrs7mjk83G/6cJwDHbG1hkQoMXXAJwq3G9+EKdw3F/1bKR7Fn7Zy44wBzyEomzuVnZ1V+FqFGFm5kZKqehsAtxSXglFUJt5RaY6LXKnHj/Ouv1T68Sr 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)(366004)(346002)(136003)(396003)(376002)(39860400002)(66556008)(64756008)(66476007)(8676002)(8936002)(66446008)(66946007)(7696005)(122000001)(54906003)(38070700005)(4326008)(71200400001)(478600001)(41300700001)(53546011)(2906002)(86362001)(76116006)(82960400001)(26005)(186003)(52536014)(9686003)(316002)(110136005)(6506007)(5660300002)(83380400001)(55016003)(33656002)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?pN4TM8sd5Y59S7yN1kaAqK8UgOfqX4m6/uvg/uZFHcyhT5tkiBNyn3gTCg5x?= =?us-ascii?Q?fS6iyrbifepJQ1xD8YdB7cGnLJOsPpgbidviaKybYRK2/04h1C30zjnnnTMj?= =?us-ascii?Q?pgdWSY8DSFRHMZ57Pg3CvhtwfHBF86g7SEAEGB46p6pLQfIYCtVu7lyEezCm?= =?us-ascii?Q?Zjvcpvr9ULvdzz59MJiSevPpyebQIOHatj0csHjGQLaey2LuDAHMcN4tkqA3?= =?us-ascii?Q?LaA/l28oW6IRikG9fMEYR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V63paGCJM2?= =?us-ascii?Q?4zoMAq0Q+U2rbX7LK4W8hTrXaInu6HQWQX0moY/acc3/dQZSqvRbRuiY2fD6?= =?us-ascii?Q?90tRo+GQWv0OkwDgekah1iKntJGytxgRT8XS82pK/9QL96pv/JQ5mCL5csxV?= =?us-ascii?Q?tEbFFCiXzPP/UmlT8hBmk6hCIUnRMoQ67p0RLX7up4NoXLEgCWvcUJx5laky?= =?us-ascii?Q?fVZhAllCNWURmDXNYoGQmgv54d05Psi9R6bj90vjIA2+BOQV/TRZbOmytkpp?= =?us-ascii?Q?dgd6cl9du4hn/5L/hUCPcvYhkm0VaYeA0MC8mC/pwfFZ7j4uv6tAipxO+/YM?= =?us-ascii?Q?87dnd+QFbqG22ggpVnfO3oohu7fMsYSKVvjYuMzRvNihmr4TqhN807KA5z+h?= =?us-ascii?Q?gHItGWfQMgznbwmCxhUv5wqnRAM1PwQpPsiCbJW8vyKUrG7kF32tutaLfdAn?= =?us-ascii?Q?kWsGnw0qVpuIY1rvet0w3g/Ll/oCBjiZh4LG/1KE?= 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: dac7162a-01cf-4dd2-5e23-08da5b5dab0a X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2022 12:31:48.5859 (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: HqgIW5kLEFyFEZxQbVcvrJeComa3AHS9PIgFISyIzedJGqwjt65NioKbEbVD7ivUNCA0/4kz2b5GYD+ebN+vDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5516 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: Monday, June 27, 2022 1:51 PM > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > dev@dpdk.org > Cc: Hu, Jiayu ; He, Xingguang ; > Jiang, Cheng1 ; Ling, WeiX ; > Wang, YuanX ; stable@dpdk.org > Subject: [PATCH v2] net/vhost: fix deadlock on vring state change >=20 > If vring state changes after pmd starts working, the locked vring > notifies pmd, thus calling update_queuing_status(), the latter > will wait for pmd to finish accessing vring, while pmd is also > waiting for vring to be unlocked, thus causing deadlock. >=20 > Actually, update_queuing_status() only needs to wait while > destroy/stopping the device, but not in other cases. >=20 > This patch adds a flag for whether or not to wait to fix this issue. >=20 > Fixes: 1ce3c7fe149f ("net/vhost: emulate device start/stop behavior") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yuan Wang > --- > V2: rewrite the commit log. > --- > drivers/net/vhost/rte_eth_vhost.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/net/vhost/rte_eth_vhost.c > b/drivers/net/vhost/rte_eth_vhost.c > index d75d256040..7e512d94bf 100644 > --- a/drivers/net/vhost/rte_eth_vhost.c > +++ b/drivers/net/vhost/rte_eth_vhost.c > @@ -741,7 +741,7 @@ eth_vhost_install_intr(struct rte_eth_dev *dev) > } >=20 > static void > -update_queuing_status(struct rte_eth_dev *dev) > +update_queuing_status(struct rte_eth_dev *dev, bool wait_queuing) > { > struct pmd_internal *internal =3D dev->data->dev_private; > struct vhost_queue *vq; > @@ -767,7 +767,7 @@ update_queuing_status(struct rte_eth_dev *dev) > rte_atomic32_set(&vq->allow_queuing, 1); > else > rte_atomic32_set(&vq->allow_queuing, 0); > - while (rte_atomic32_read(&vq->while_queuing)) > + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) > rte_pause(); > } >=20 > @@ -779,7 +779,7 @@ update_queuing_status(struct rte_eth_dev *dev) > rte_atomic32_set(&vq->allow_queuing, 1); > else > rte_atomic32_set(&vq->allow_queuing, 0); > - while (rte_atomic32_read(&vq->while_queuing)) > + while (wait_queuing && rte_atomic32_read(&vq->while_queuing)) > rte_pause(); > } > } > @@ -868,7 +868,7 @@ new_device(int vid) > vhost_dev_csum_configure(eth_dev); >=20 > rte_atomic32_set(&internal->dev_attached, 1); > - update_queuing_status(eth_dev); > + update_queuing_status(eth_dev, false); >=20 > VHOST_LOG(INFO, "Vhost device %d created\n", vid); >=20 > @@ -898,7 +898,7 @@ destroy_device(int vid) > internal =3D eth_dev->data->dev_private; >=20 > rte_atomic32_set(&internal->dev_attached, 0); > - update_queuing_status(eth_dev); > + update_queuing_status(eth_dev, true); >=20 > eth_dev->data->dev_link.link_status =3D RTE_ETH_LINK_DOWN; >=20 > @@ -1008,7 +1008,7 @@ vring_state_changed(int vid, uint16_t vring, int > enable) > state->max_vring =3D RTE_MAX(vring, state->max_vring); > rte_spinlock_unlock(&state->lock); >=20 > - update_queuing_status(eth_dev); > + update_queuing_status(eth_dev, false); >=20 > VHOST_LOG(INFO, "vring%u is %s\n", > vring, enable ? "enabled" : "disabled"); > @@ -1197,7 +1197,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev) > } >=20 > rte_atomic32_set(&internal->started, 1); > - update_queuing_status(eth_dev); > + update_queuing_status(eth_dev, false); >=20 > return 0; > } > @@ -1209,7 +1209,7 @@ eth_dev_stop(struct rte_eth_dev *dev) >=20 > dev->data->dev_started =3D 0; > rte_atomic32_set(&internal->started, 0); > - update_queuing_status(dev); > + update_queuing_status(dev, true); >=20 > return 0; > } > -- > 2.25.1 Reviewed-by: Chenbo Xia