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 32089A0505 for ; Fri, 6 May 2022 10:19:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26D074281B; Fri, 6 May 2022 10:19:08 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 67A1B4014F; Fri, 6 May 2022 10:19:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651825145; x=1683361145; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=J/5PruwE0qyWAyMvMucY5ztNZjl3dU77kGcCKVMhrmk=; b=dSgOE+mxj0J2WnxKPcxP1fON2Sa2moZTT9luQl8c65yDB0npfGnU5Pc7 VZXDqupvrIp2wvawEESHWQz1BOctcOTuAjihF+0/JEjs59mA+Vvor/zXN 2Q3wvcDNUarpYz5Us9bP6x0Q0zR+XXxbCvL4zCWADu6jjsmR4KmWwCuYh 5+WW4xIq4MkydiY0MJ9Bj2Nl4EhsMoP0CceQaw3eNIEdGZ3FCIxSpJn/Q uj28rCyb+nF6IRVHncPcQNmNMQ8DVegKUn91SNp5O7i+cIB4yixmdmXR3 dLVMOi3zTZJd5xJTiSI2Qwmmo7+0BQUujb69cErntJ1A4uK7zaz3yhyFr g==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="293598474" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="293598474" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 01:19:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="632826122" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga004.fm.intel.com with ESMTP; 06 May 2022 01:19:04 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) 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; Fri, 6 May 2022 01:19:03 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Fri, 6 May 2022 01:19:03 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) 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, 6 May 2022 01:19:03 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) 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, 6 May 2022 01:19:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aW9wNuRm5diLaNU2mlNsQ9cTHM8VHdbni8eVeM5EnI0aLHwMM1x2GwAhzZOK9EqW2BacDz7uml13fZYs8NbWVh5dVRMekCGQFF9YkTxdNYh39uBI3lSfjQZRnoKWpmFkSZrU1j8yILVlkGVn4YfQMwNRkAsBKfbr/JXa9gm2TieEJ7nlZSQ78NqwG44tOAAgpQp12gYJ2emhr+U7tyULaYqUo787ZU0l+XGhmOl2zPwMTSViDUIBtGBiKcRByW0aH9JpcXR2/i6giWyCu0vns2L+G4u3TbbDIy4Zn2OVxq7LxvbLLg/2QaFZBTo5fQ0sBPG/Xd6jAhzVTMD65FAHBg== 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=8E+oWoAeJ7dECpzqslKVesU3fhjfHiktw1zXyD0o7Eo=; b=RLGb5wgbdtPfb3ljWh1ad4w5kOl/YaviQMdgryphz6wY/1oz/0RLAvgRcbhNAXZMY9kXIfKNG/nm1YdRhIe8+0SLmmkLbI8ycqtUTOu4mEe0iLVfC59ckBV70vdzAS5vO8DwWu3B/8gmyQOr7S3iqI+upFKAy98zV7OooCwK9tX8xNYFN7ECQbc6dbejTTq+0oV7ddoY+bWhYKA0+cuqyKZFrwxgNHYzGjSR0QcHyqtaWvl1849zGw3ugzKObIMltvN41hPNIZlD8g4jpnujGI8w+deFPNrZoUToIeJHYjThkRJHG1MVJE+QoMv/0RQFo0qO5s/te6RLOrHK7V6B/w== 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 BL0PR11MB2964.namprd11.prod.outlook.com (2603:10b6:208:7c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.18; Fri, 6 May 2022 08:19:01 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::4d1d:6453:f00c:cf8a]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::4d1d:6453:f00c:cf8a%6]) with mapi id 15.20.5206.013; Fri, 6 May 2022 08:19:01 +0000 From: "Xia, Chenbo" To: "Ma, WenwuX" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "Wang, Yinan" , "He, Xingguang" , "stable@dpdk.org" Subject: RE: [PATCH v2] vhost: fix deadlock when handling user messages Thread-Topic: [PATCH v2] vhost: fix deadlock when handling user messages Thread-Index: AQHYYFjiubl7hfo7KUKu16TFQF1yda0RgmNg Date: Fri, 6 May 2022 08:19:00 +0000 Message-ID: References: <20220505134008.2865-1-wenwux.ma@intel.com> <20220505161725.7333-1-wenwux.ma@intel.com> In-Reply-To: <20220505161725.7333-1-wenwux.ma@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: 6a751576-d5ea-4493-f368-08da2f391342 x-ms-traffictypediagnostic: BL0PR11MB2964:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aOKxjVGyE9oc+cUdMjgutTyvZ92XD/2ev4330Y2YQP22aBX2xeQCIJlrxpooCPhlKlVJXQdkE0alWyOeoR6mMXufHIvSNyM3ulP7P8HAo4+bYDskBnSUsIZwtHkgbMM/cb4+ktt4pvMcYu0kfvA8gx+i/nWM4JpKtvAsqCC3QfHeOJPSN8s3n79CodAgPduw5Mi6NNUvt8JSx6rgOLDraA91/25FJdDwHdfSgWSA+GB+tHGxrn8qep286ysXy7CIuE0XVweGEiZuVeekYOBjooYGMEMtdyh/ifDvkzbP/dBY6e6x2G8pkAtBlvr6wTeTu9E4MKPUIO4dDLX+MIuz92fAJEDdl1mH5FGJPQCe3h1yrBvpVEAmwZexT5iCU3H1VddpSA6sKi6kX0GJVz2rXQl6LIy1Znbr4KFJIKAnDxS9MUP6QD3SHdJjpP0aiW6SpyAmbaEHU1kGKWjDAMobee+JcecWBIyhQCNEEkwk62G7dm8xwqiZGP+1a/d+3kk/+hMCJyQZ9gOaERBEshA27sHHXA4Io3D6gZIY3yccfBQj95d83o+6hCFocRLt8aqNUmET1VOtNJy3Io/tR1HCpwkg64PHetnC8tadW9HU/aGQ6sa3BqHl/nblvhpJOVwZfp/ug26BQtejIKbuOMxCHvGVRTq+inE9LGvoqwm6JnqgPxeLVdoAF9VOH3UT5Qg/Fs5jN4uDTrGGWX1cmMN/pw== 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:(13230001)(366004)(53546011)(122000001)(66446008)(8936002)(316002)(83380400001)(5660300002)(55016003)(52536014)(7696005)(2906002)(33656002)(15650500001)(66476007)(66556008)(86362001)(4326008)(8676002)(64756008)(186003)(71200400001)(38070700005)(38100700002)(82960400001)(54906003)(110136005)(508600001)(66946007)(76116006)(9686003)(6506007)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?AuVbaPEY7nushfl0wI1gr6RxAosEWhsWaVRbjAPfQRywK+YVvSYsYpHr5WhV?= =?us-ascii?Q?HXBYaCeHQPjUnd8Xk14eu5bJ8IoWqj8IUf9shT4lYZIUgm6hJrkdctRFpdMU?= =?us-ascii?Q?lMy8veDXG1mg1We53AA5GRA59IrKjvZJInfSHG50oO3q5SETRbu9D1b7tnkr?= =?us-ascii?Q?GvGOryMGvZwSUYYYPIY6B2AosrMzO0aEoun7mCpF3xsUmEJKX46Kn2yZfVFO?= =?us-ascii?Q?j0DT3htjmlab2WZOLWrLqkc2UMQUlQvvfyE89uyz1Bz6ZNEdKVvoSfieNtfD?= =?us-ascii?Q?Fqi02MZAoRDCrFDGdt5Uj4QF9ztwJf+/HhTA43uC/RM3n9tmN3VO1rTiFZwW?= =?us-ascii?Q?MfiRH2Opoyo4/IgVghKo47v6esuyk9LueAf5ta/qZb5dUZBWts9ZAhCiQ3I2?= =?us-ascii?Q?HB18F/f50/JWAkshs5Jq0zggziXJyHQ6IHtnPfUddpSTFFj315rCRwLvx2hD?= =?us-ascii?Q?VoLeZRYILpKOAxoJs6olrnVbX+8+brrsiWtYZx12LPGFW07Y4s9prZZxvgg7?= =?us-ascii?Q?DpcP5vpUj8OIGS2GeHNjz6mON4yfrzT51BW/03h0yqtybGoFeNmkftYYHmip?= =?us-ascii?Q?a3hXhqQufI1tT3htndEHtVHqE6jdRcgiiu43nI8ytHV5cpmRsBorUVd/8zQ4?= =?us-ascii?Q?xVir5+h8mS1DdgGWtuv/rfX+/LQcp/GnnNJmJOptUYVrTO0stlCHXthUU+yq?= =?us-ascii?Q?2+bugduNsAphEPtWMojO+c+2JHK87VeL5NaGh/VCWET+PPkisFhATNdzPHiJ?= =?us-ascii?Q?i6MFUP4b5c2sBpwFJV6XB9wkQ2r0DjKIy78J9vuq++FIamTCqwMDrEkvGcmX?= =?us-ascii?Q?fU/pPpBoY7v5TPZwamj6bER9n2GTkOY3FqSbnEmujITyM+bNYYq+tghQPxfm?= =?us-ascii?Q?yULjAlbfgVF8BFsjwZHGdtfyEGEHsW9xDx6tIbmpv3h5ExyiLr9GeChQmYkn?= =?us-ascii?Q?TWqZUbskj+t0XOe+/ZwlLN521B/gSA5sYIMPmamtTnCP/cvdFNJdRPBEfQL1?= =?us-ascii?Q?3wjcaoKMeWtVee6Gx9pJ0oZVTb+a5nks3LpKbI20ECrInd4+MjzLrnuVhvpL?= =?us-ascii?Q?B05Dtoidk1Nztuc1BGWooCRJC7POAi2ODf5wmUKP7dOotOwoR2raJJvmwXoz?= =?us-ascii?Q?p1El9hdu2fqbevZv//eSo0XtYWHvQY3fkKGoYNefI+J87YDatqRI17GzATBt?= =?us-ascii?Q?CoTiOdxNzmAH3Su5lE5DIis42s9R6qYT8Ef5HAto6a8//VGj6+GTFEj6RYno?= =?us-ascii?Q?C3uMg3+tzTD1NOgAwE2T3N65Y7/AZEpM4uV217/xpMaedtv50JLc9nBy5b59?= =?us-ascii?Q?GGOZfu05bs2wOz8A0PRv/GLqoYB5vnGHhL5qyckBXZ8jaf23+a5SVhRcp756?= =?us-ascii?Q?X4PAL1MveR1p0nAVt5sxP6UfGaRpW/q5NqXcQLXNy4hBEUTDWYXbvq3ECsVS?= =?us-ascii?Q?wPzzCarqp1zyn3dPfTdv8huUAJYbKnQJoChO9Sej4WbjrmxSN2qK/92oYeZz?= =?us-ascii?Q?LPPLqPfmKId4dFV9fKfT+Ce9YZC7DGwny8n/DWkwPXH/1UEY/YFYFHNuVtzU?= =?us-ascii?Q?gVwnmB7QLKfV9VwkRmVNNDm/21NNrvqtHrwc583vqL97RKTNdryUaimAuCVp?= =?us-ascii?Q?Q79z48h0w++K5IBrpWsPmGiOENC4WEMux96pl5pftKNWqJ2Tr8hURWWa/Eh1?= =?us-ascii?Q?pVxW4lW6jXitQjAYo4xHJEtWT5FCEzNbesiWJhn/vN1s/mSX4eoaJILKLCpL?= =?us-ascii?Q?Lad7FtQbkA=3D=3D?= 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: 6a751576-d5ea-4493-f368-08da2f391342 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 May 2022 08:19:00.8830 (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: xJQr2cs+wlDvF0BVj7VfnqzbnLKZa3eTRHp4AJxe/1l2mpG3O/+rsVaLFtyCY9GSZncHrTWsGYJa7Hitv5/GFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR11MB2964 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org > -----Original Message----- > From: Ma, WenwuX > Sent: Friday, May 6, 2022 12:17 AM > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > dev@dpdk.org > Cc: Hu, Jiayu ; Wang, Yinan ; H= e, > Xingguang ; Ma, WenwuX ; > stable@dpdk.org > Subject: [PATCH v2] vhost: fix deadlock when handling user messages >=20 > In vhost_user_msg_handler(), if vhost message handling > failed, we should check whether the queue is locked and > release the lock before returning. Or, it will cause a > deadlock later. >=20 > Fixes: 7f31d4ea05ca ("vhost: fix lock on device readiness notification") > Cc: stable@dpdk.org >=20 > Signed-off-by: Wenwu Ma > --- > lib/vhost/vhost_user.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 1d390677fa..4baf969ee0 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2976,7 +2976,6 @@ vhost_user_msg_handler(int vid, int fd) > return -1; > } >=20 > - ret =3D 0; > request =3D ctx.msg.request.master; > if (request > VHOST_USER_NONE && request < VHOST_USER_MAX && > vhost_message_str[request]) { > @@ -3113,9 +3112,11 @@ vhost_user_msg_handler(int vid, int fd) > send_vhost_reply(dev, fd, &ctx); > } else if (ret =3D=3D RTE_VHOST_MSG_RESULT_ERR) { > VHOST_LOG_CONFIG(ERR, "(%s) vhost message handling failed.\n", > dev->ifname); > - return -1; > + ret =3D -1; > + goto unlock; > } >=20 > + ret =3D 0; > for (i =3D 0; i < dev->nr_vring; i++) { > struct vhost_virtqueue *vq =3D dev->virtqueue[i]; > bool cur_ready =3D vq_is_ready(dev, vq); > @@ -3126,10 +3127,11 @@ vhost_user_msg_handler(int vid, int fd) > } > } >=20 > +unlock: > if (unlock_required) > vhost_user_unlock_all_queue_pairs(dev); >=20 > - if (!virtio_is_ready(dev)) > + if (ret !=3D 0 || !virtio_is_ready(dev)) > goto out; >=20 > /* > @@ -3156,7 +3158,7 @@ vhost_user_msg_handler(int vid, int fd) > } >=20 > out: > - return 0; > + return ret; > } >=20 > static int process_slave_message_reply(struct virtio_net *dev, > -- > 2.25.1 'vhost: fix deadlock when message handling failed' may be a better title. Reviewed-by: Chenbo Xia