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 9F013A050C for ; Sat, 7 May 2022 08:02:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C403740DFD; Sat, 7 May 2022 08:02:58 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 8FBC74014F; Sat, 7 May 2022 08:02:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651903375; x=1683439375; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kEQaPALStaEe92OpxvFjEBtniVVptdxRW4vlU40UfXE=; b=XyTrjAGO2erPJB9el7Xxkj6L7VfBAME+/FFUwQYqDXvkEA4EQZyvhALP nCG/v5xD+WU52wdWxMENs7DpRIqBTZE3pNiIZHGYxgYiKArYZm+N4iryA gV8IqnPrlS0bIlVnycISmVEcGwzOIhUXrAedMwx+XDvJJmnmLay7TBL5N 8yQCuGvEUd/tad4X/mZUVI8mGNf9JKUWeZK6I9HhWti7qFaJWbp8PeCFB vENK92oUKIt4bF8YKGKxnDrsjTxdz1W9SGSjTaasl7E2TNNlEJA37Zll+ EiU4nCDvqJD1FHJwxhbBt5DNxmNM0LAnJhlxpg+fSQZvx0enKZnSrc1IH A==; X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="256147529" X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="256147529" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 23:02:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="600876665" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga001.jf.intel.com with ESMTP; 06 May 2022 23:02:53 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) 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 23:02:53 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX612.amr.corp.intel.com (10.22.229.25) 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 23:02:52 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) 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 23:02:52 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.41) by edgegateway.intel.com (134.134.137.100) 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 23:02:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UAwljt2tMyJhgrFu2ZZBXiA8XtNnEai81pdH00S7NDbeBdVe8eS/B1e1IqyZZjk+OL7kSYrmf9CkMzm8bUnc6FgzYGo1tUPzCJvrkO2myqtNzGhWW3pEGklTShDbNZj7c1oXXwFlOCeWhHGvpypZUADodUv1XZsKnrdw68Tdn1H+L3bqOsnRXIf2AUtlD+z+JQhe3JCTS5gpMasZmVtduKnLsV+2wSqoF+n4WqyllyZOuOU8T73WWvjexObBX4U5tjbx6pNNQ++KVFm0KI6QjJ+EKEBTUM9aGr9SzcBgsF/Nah2/IlPTY2x0J6i8We0twXRrm+5f4imfSgVGjEOxow== 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=rvaGgxpuDQbXXNdRVQL44Lw9K4oatYpgaJ5rZ/H0V0I=; b=lCfDlutA36Sz9J3piaJK/5ed7XBDsdeZ9Ai+T8EJPmHnkaAYcoMX5DkWKEUct5VRrjwwLDMr98zZIngs/KiA6HbLCq8PbuEsqK+A2oilzct20rCmXFLO4z9JWue3F66APSlxUSVjjXgyJfbETFc17pIoPkX4vTOqAT0IN41DGfld/zQrC5c4bVlQdYAbxxVJheIO9Xm+FwEv/W1SEp8PpqUyWpAIUqYiTqf61ivgGFZRThqU5MHqf9vS0J/ITTSRZ+jA2FXhHZ7ccwllBh69uPQEOriMJBOERscLmwmEPERnETvn9sMuFmzfiosVYXM50WC7+R0RDinBVRfYohF8JA== 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 CH2PR11MB4453.namprd11.prod.outlook.com (2603:10b6:610:43::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Sat, 7 May 2022 06:02:50 +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; Sat, 7 May 2022 06:02:50 +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 v3] vhost: fix deadlock when message handling failed Thread-Topic: [PATCH v3] vhost: fix deadlock when message handling failed Thread-Index: AQHYYdOEKu9g1FyxTkKQD9JcwcJOS60S7FiA Date: Sat, 7 May 2022 06:02:50 +0000 Message-ID: References: <20220505134008.2865-1-wenwux.ma@intel.com> <20220507132753.11357-1-wenwux.ma@intel.com> In-Reply-To: <20220507132753.11357-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: ace55ffc-632a-4224-9796-08da2fef379b x-ms-traffictypediagnostic: CH2PR11MB4453: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: u4Wkf4g+gdZMhUk0Zp5599jk1oI1NBR41Q8etYJEpuYQWrPvD7VvKQ5f71zJIBLfH38pRngSvEX/UtXtDPu+OXOFLeXWSjv8qpj3AajnU4nO2c0NSyTAeMLHK9g61B5LYqQfz/7t8I1nrZ+rwgOYktRxLcHxwk0nj7RK0d+DB39mwnHL8WsnvIE6aBUQ+UPbMn5gkLy8ugqlJFc7PMuDn02nR8Ilc2MhYHAn3TYSdW7Ltp29Ve8gzA3FDXqfwQ38jqyUM1tNJCloIhcAQADBo6AHW/XZxs11Uo6At/sY5QQtHL55WyNT8w7hxdKibMrphTFBRL8Z1CZElgAejfqtm1H0K+iuybtrn6Vd95T9PCfkDlTQPrJHZdmCXCGrlCehHthIe9igautJvJcG/tgV9i84d2HtgBFTHF0jbJlgLcJMe40MweXi1gC4+uvs09YJrNccTu3k/olySM5Wx+8TqleP8ST6aB9ne+wOFZZ4nIzAn37wp4u1jPu/XW+663tuGdpjo8zF8TJ5si0VtH05RneYiPgi8jhVQ3WbYuW7NXQNuNeb0AMtF8GLsN4EEQhbZJV8I19f+eo7a1BTilDzl2UEueVTUypJYxY1+TvjBUDTDbZtZ8cI768kTtb8NHd+SD6G8LK3/u6WkHANDhRlog+yNF4ZaCtsnupfzeA8OU81DVPpmj2X9dzQVLFObZlCHJ1Os8QWSoOmKlSz7axeAQ== 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)(110136005)(508600001)(316002)(54906003)(76116006)(26005)(4326008)(6506007)(53546011)(9686003)(7696005)(66556008)(64756008)(66946007)(66446008)(8676002)(66476007)(186003)(71200400001)(83380400001)(33656002)(38100700002)(38070700005)(15650500001)(82960400001)(2906002)(122000001)(86362001)(55016003)(8936002)(52536014)(5660300002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?1K1eznIgXAfkifMzC32G85gbrMwzEYnGZeBE5+xGZguqyE+br9Oxk4+fc5kR?= =?us-ascii?Q?dZ0FynOw65+gCfRXgsVuJguXjgGRj3NjWimuceD3BKHsMK0qQQFaLdP213bh?= =?us-ascii?Q?juMsHVxri+Im/ayKmXuMi3XhWteLD5fSAKRbUrg0PawwQ3deHAPgkgBf22a1?= =?us-ascii?Q?BqjoYU25aVkhwCpKncdIeQ857rzZdzzg07OD9FxVYhi2qVJolbGrrVgKnXCQ?= =?us-ascii?Q?NyHpOyKCDLwxXnSdCTdjng/EXhwT3H3MJjOAtKn8OzUKc0wPpDZT9RxRVO4W?= =?us-ascii?Q?MiSPnUt3iY2rg2GVpkdqfccGtvcWE3j32onar6TgBBIHVjqUnCAnTf7QWqOr?= =?us-ascii?Q?Rx8CAPEGL/b6MRcBt+0kjVjR5yIii41wJ8PC81D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ln2bC8cXxKGzyJjqHNQjpEZ8DoBAVk3CW1Af8nNuTjUM?= =?us-ascii?Q?RGnyoOn+zoRqI3bO9JCSVkO3bkkf/x1H+dU5Zj67lrlv2MPE56xWtIoOnfXf?= =?us-ascii?Q?nuHHh+Y3fICieLfq1kn6ZLRfAQSbAOuEvc7mkJeBidfqPi82RqM+9pFqWzQt?= =?us-ascii?Q?Kh+yzI84ghDoM0CL0zzeZD4KET/i2uZuEbdaKnZY3pApXuBHpzmXhElxgd/4?= =?us-ascii?Q?lbNDIW26wR2eGhCJw4XjZ8ry59zmIZRh+pM7Y0jkHvbj5e19PpFhdv9g6w7h?= =?us-ascii?Q?8WjGrObmCClJValFfSS0cFBn6hrtOcS3AavBO8YXik/0mOOlVK6OkTeqij7q?= =?us-ascii?Q?4Q6JCqW2UH+F/RLfygxvWpC+7LrhqofwiBynb6dssWPpW85ojbhP6QSG8al8?= =?us-ascii?Q?HAI7wtqGNl97GJjRdUOigGmaMMANiFTwLK7lQ/zAchF2Hs1AXctmHhvqjDgj?= =?us-ascii?Q?etTfFX3JgQ=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: ace55ffc-632a-4224-9796-08da2fef379b X-MS-Exchange-CrossTenant-originalarrivaltime: 07 May 2022 06:02:50.2667 (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: 1OwHnR047sNHTTJUhtG58JwQySSj1TKJyWteN/fGSnvrH3OcJxwMlK9hYv+2Xa2X5WCJxayK/aiEaEjk6GkhIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR11MB4453 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: Saturday, May 7, 2022 9:28 PM > 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 v3] vhost: fix deadlock when message handling failed >=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 Reviewed-by: Chenbo Xia