From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0071.outbound.protection.outlook.com [104.47.0.71]) by dpdk.org (Postfix) with ESMTP id F1FFF2082 for ; Tue, 6 Nov 2018 07:23:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TRWDIgozKObWOPfvnZjdJRSCSNly+eUpkWMYSMARjYI=; b=RsJ1+AZPV2IRW8sMvW8elCNUyMO/Sm/vicNTKjPMYTblhB/QF0iNAxzbVOyhMA9JCTlA0RC3oQUZaILnvaDdIroX4jRVTekuh+R2N832auyUUAF992CNWfztDUevlVIDDXmeyMcTpWmxiRbBm62NC1De+AZx4zWnGAm2GnmUoUg= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.41.11) by AM0PR0502MB3684.eurprd05.prod.outlook.com (52.133.46.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.33; Tue, 6 Nov 2018 06:23:22 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::b158:af20:5026:3d25]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::b158:af20:5026:3d25%2]) with mapi id 15.20.1294.034; Tue, 6 Nov 2018 06:23:22 +0000 From: Matan Azrad To: Jeff Guo , "konstantin.ananyev@intel.com" , "anatoly.burakov@intel.com" , Thomas Monjalon , "bernard.iremonger@intel.com" , "jingjing.wu@intel.com" , "wenzhuo.lu@intel.com" CC: "ferruh.yigit@intel.com" , "dev@dpdk.org" , "helin.zhang@intel.com" , "shaopeng.he@intel.com" Thread-Topic: [PATCH 2/3] vfio: fix to add handler lock for hot-unplug Thread-Index: AQHUdZZ6KGI5DW3yiU6wuad724mZ86VCRx6Q Date: Tue, 6 Nov 2018 06:23:22 +0000 Message-ID: References: <1541484436-91320-1-git-send-email-jia.guo@intel.com> <1541484436-91320-3-git-send-email-jia.guo@intel.com> In-Reply-To: <1541484436-91320-3-git-send-email-jia.guo@intel.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR0502MB3684; 6:V3IAXor1CgL9FIBbWAxmemxcf16Q4FSxum2sBg7VbnIDPUhwDguRtqyW8S78GPtLmg/tDG17Wxzo+3+Tyl/ByPIOdNNDYtX/iAwABiib8tgshd/928W1tbRqqIzCjp3DnErhoKDgPfmYLSl9697ad46UhAHUA2Xe4JcYXTjHgYfUfjy6mpN5I2+7K13pGnpQ4RDcR6OqoxAofar3KaU09rgfpthOzhjTq6nVaovHJysXpMpzqgqwJwyST0SBKG1KFukt7GMyCc7wIbGBmpnTHt3KJYS/cGFi+SG1iyFHaac9GLnLuzqNHIWxIkBSkd6c9xnpnxYSmGkuTtP28HNtsJJE77NBPeDU+/77coeFzMAQFX4HEKzohw0zR/U9qhmqJBIZpxONksP8iqDSdGITYu0V+iOFGSD7UO1Fy2Re0iVhNo7H1jQOhOnsT1OTkgaTLdGkHDvuXN6eMfcvgl0zXw==; 5:zVzKtT2UrCnc5Vu2wR0yr70je52Tv+NatykhJd5Iawr8QSLCZ04WDYSbJkrhC5mLV9OyOM6Dhi1Agwa6i4GPMXmT888QdPUVmYoRO+CH7XiNgHKGUQjTkXI4jwauzfiG9wAOiKPMbybu0hdBDpPkpVRiVx0QFjRThkLD2ER2gbE=; 7:JfAFqgBXbBoSutz3/nKwJwf6UUVhV7L2SQeDblEiBbvLA5TxzuX9HIGzyTza9NhBJTwd+50jWky67t8lvxI54OCeVztGljuU+H186coOtZoSEVXcIgZrKKGz4XsaPy6Z2al9rU1rfCJnqHUK859hgQ== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 93d05860-3f0b-4aa6-732b-08d643b05a09 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR0502MB3684; x-ms-traffictypediagnostic: AM0PR0502MB3684: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM0PR0502MB3684; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0502MB3684; x-forefront-prvs: 0848C1A6AA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39860400002)(346002)(396003)(136003)(189003)(199004)(13464003)(478600001)(4326008)(186003)(2201001)(6246003)(86362001)(66066001)(14454004)(53936002)(97736004)(2501003)(99286004)(102836004)(33656002)(5660300001)(305945005)(53546011)(6506007)(7416002)(106356001)(7736002)(7696005)(26005)(105586002)(76176011)(74316002)(54906003)(110136005)(6436002)(316002)(2906002)(8676002)(71200400001)(71190400001)(476003)(55016002)(229853002)(446003)(486006)(9686003)(11346002)(2900100001)(14444005)(81156014)(6116002)(68736007)(81166006)(8936002)(256004)(3846002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3684; H:AM0PR0502MB4019.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 0Aw564MGuTG9j9EnZTWMKMRAha8qDdnPz25drcpc1old3UKwicszZsbbabhYPYQnD8JyxtkFca48K1qr5lfXrQmbA/jCilW1iUOWDrrWHRkIy0SMQTx3C/aBAXH5ZOtBoPElndKwAbFFG0JcJLJsn/f30MIhKaV2khElA2kWuf+37iwOqrUbaMaYFXGGn2Hi+U0vVEUUZKZT2vDe61V9EHnOWU2sNQpvwHKis95YYn1+utO7DYUaPRshQ1UTkMRo9+byBqFj2JCJ6rXnhwsIMfIYwwVu441GbgApoZ+PZQA/svoc35EWbS03vzGLyiiLnAB0pUHLQjywYaJfcXgd6lm0FiOH8wTHXU+VXe8/Bqw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93d05860-3f0b-4aa6-732b-08d643b05a09 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2018 06:23:22.1846 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3684 Subject: Re: [dpdk-dev] [PATCH 2/3] vfio: fix to add handler lock for hot-unplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Nov 2018 06:23:24 -0000 Hi Jeff Can you detail more in the commit log that we can understand the synchroniz= ation problematic scenario. And how does this commit fix it?=20 > -----Original Message----- > From: Jeff Guo > Sent: Tuesday, November 6, 2018 8:07 AM > To: konstantin.ananyev@intel.com; anatoly.burakov@intel.com; Thomas > Monjalon ; bernard.iremonger@intel.com; > jingjing.wu@intel.com; wenzhuo.lu@intel.com > Cc: ferruh.yigit@intel.com; dev@dpdk.org; jia.guo@intel.com; > helin.zhang@intel.com; Matan Azrad ; > shaopeng.he@intel.com > Subject: [PATCH 2/3] vfio: fix to add handler lock for hot-unplug >=20 > This patch add hot-unplug handler lock and unlock in device request handl= er > when process bus and device resource, in order to avoid the synchronizati= on > issue when device be hot-unplugged. >=20 > Fixes: c115fd000c32 ("vfio: handle hotplug request notifier") > Signed-off-by: Jeff Guo > --- > drivers/bus/pci/linux/pci_vfio.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci= _vfio.c > index 305cc06..d2c8410 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include >=20 > #include "eal_filesystem.h" >=20 > @@ -35,6 +36,14 @@ > * This file is only compiled if CONFIG_RTE_EAL_VFIO is set to "y". > */ >=20 > +/* > + * spinlock for device hot-unplug failure handling. If it try to access > +bus or > + * device, such as handle sigbus on bus or handle memory failure for > +device > + * just need to use this lock. It could protect the bus and the device > +to avoid > + * race condition. > + */ > +static rte_spinlock_t failure_handle_lock =3D RTE_SPINLOCK_INITIALIZER; > + > #ifdef VFIO_PRESENT >=20 > #ifndef PAGE_SIZE > @@ -289,11 +298,12 @@ pci_vfio_req_handler(void *param) > int ret; > struct rte_device *device =3D (struct rte_device *)param; >=20 > + rte_spinlock_lock(&failure_handle_lock); > bus =3D rte_bus_find_by_device(device); > if (bus =3D=3D NULL) { > RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", > device->name); > - return; > + goto handle_end; > } >=20 > /* > @@ -306,6 +316,8 @@ pci_vfio_req_handler(void *param) > RTE_LOG(ERR, EAL, > "Can not handle hot-unplug for device (%s)\n", > device->name); > +handle_end: > + rte_spinlock_unlock(&failure_handle_lock); > } >=20 > /* enable notifier (only enable req now) */ > -- > 2.7.4