Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp729213rdh; Wed, 14 Feb 2024 09:33:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBKbi3Px8op81wIj4hMh6uSFp1ZOt4lrOwuRwHznTo0IovkB9RIyhF4L5wBZgTkBT4Wrjn5Px7c2Hho51OkY6MPH2CyudzaUEohOFwVw== X-Google-Smtp-Source: AGHT+IF9Z+d2Ol9HsdzNNWCikEg3KSojiAD2tjLUO+X+wEJC33Hhfi8owaw6mslYdBaRTWkmClm3 X-Received: by 2002:a05:6e02:92e:b0:363:e034:47f1 with SMTP id o14-20020a056e02092e00b00363e03447f1mr3629260ilt.0.1707932002097; Wed, 14 Feb 2024 09:33:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707932002; cv=pass; d=google.com; s=arc-20160816; b=sQXROr54Y2CA1pRAN8oUuntiEIesWm2a9KOU5P6Oi4qch678AKr8mcsgzm3P5nVTtL csiS452asE1UhGffaVc0MCYUhFY/ENooTOmKvno0tcGI/XkLqRgi05BvLBze85wxulKH y22EeMDLdFY3xT64TqaI3PwZzu+aaKZCdua3FKRVcImqQF2gIqoWT8R2YVA7/yv3Y8HN PZk/enC1BCdWzpUFG3KUd9CHLzmOtJF5bUQV8mXo75Bs3ptuC2fJCIWamw7D7aI0whqU yYGDdIg3XtiMWGL/g0JmvxKEjvUX6p8ZhbWVD9EIVtL5uKt8qs0AHxMyfJI+uCJ2xya9 bY7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-id :content-language:accept-language:in-reply-to:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-filter; bh=YtoIcxIjVpT8BnnPLrnzK0hvALjZLW8dvHfgRts0Qjc=; fh=u0zVePdzrCnNYvyxBRGwk8nESnizeAZBvsn7na0jlhw=; b=gKFc7gFAJFgwOqhk8yr5MnIKiLPxBOFEg+O1MD2qR9sbSLp6SVcJy+CcutBnrLMNfH 9rkfE8nkzgG2KDXGWf8fs0rIRNzPJ8KTNee7PiWtzVLkhl1OY5N+hwZIswYWXTLQ+q6K 2kvhVQWWtXeQ6/R5ikreGjUxJsQ2NSGTNP0TTsripeuI7nssL6kF3cYtxGxx7c6cK2h3 GKM1uVooo6p14xdxYnq7FolDtwo/+tpiHkuCs90s2CqmNiBGwjC9QkoS77a1mhgr4X39 W5QtxLCpt633182PMsGh7/3ZNaYe/ADs6EMaZEQ6q2hvyaelr8clrlmCeIr47NfmP3jC EKEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aGmdNHw2; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-65613-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65613-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCVFo3YWPG0/YZ2CTrx/LlY9jGq3Ae8T2MzMwhusBKAV+Ca7J0rwei77se7XReAzJ0WOZAsLtQ6Sgfu9AOXdGwynTz4UCU/l4Rkds8lh8g== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w16-20020a639350000000b005dc42fd8c40si3907725pgm.404.2024.02.14.09.33.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:33:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65613-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aGmdNHw2; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-65613-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65613-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C3492B28372 for ; Wed, 14 Feb 2024 17:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67FDB60887; Wed, 14 Feb 2024 17:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="aGmdNHw2" Received: from mailout1.w2.samsung.com (mailout1.w2.samsung.com [211.189.100.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DE6460864; Wed, 14 Feb 2024 17:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.189.100.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707930261; cv=none; b=RE+sdtV7InIJK4E7Nu1m2WkOgRavC5EAcB3CicKj5p5FybXrtHoulOfJXM9wMBV0GfO4jQ4CK5iC77cIHyn0/BvdfJIid1TMksfe3Bzgx/Fb8aWHk2CyBHFz0Ytks6fQwzD1bWoMIv1zGSwXy8WtkzLFCLIFfGNrkSTf4r/E+5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707930261; c=relaxed/simple; bh=1cXJYhjHiLin0wIW2fMe06uKIO+gJp9378M26epkUjQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=BNjJ6NSWspP77+TaGzunImirUUkyeMTA6TuLdBARP/EUO2I4DhCfZDwjEhzxSFIX8nhManG02QeeRzbEs9iPF24a390ftAs/34GfiEptmopM0imNqMQWoVesFf/KP1H9E5ZQCvdqJfyPe9a0TUSWAWqnH4Q/mJoeEs+X814yPAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=aGmdNHw2; arc=none smtp.client-ip=211.189.100.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20240214170410usoutp01769c6e25ffd864139ad722c70a48a050~zyYOOvomP0041900419usoutp01j; Wed, 14 Feb 2024 17:04:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20240214170410usoutp01769c6e25ffd864139ad722c70a48a050~zyYOOvomP0041900419usoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707930250; bh=YtoIcxIjVpT8BnnPLrnzK0hvALjZLW8dvHfgRts0Qjc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=aGmdNHw2hbdocL2bf2YtZmO1dkVtSOXnbbXPpmr3iPQ8mcf0RQhG6ZU91FsTY8GIo uVLv3FSvzgozq2sKt1rcZ5hRB68qhwhF5l01k8L8a2MiAHWEvGDRZu6JNa1ODrq3Ph +udkPA0HtpyX8muWrgOMyyL3HVVRPDO6hbVfGm4c= Received: from ussmges1new.samsung.com (u109.gpu85.samsung.co.kr [203.254.195.109]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214170410uscas1p2f00f19d678ad15d7d0ad77fcc337d6c0~zyYN2ognw1117011170uscas1p2R; Wed, 14 Feb 2024 17:04:10 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges1new.samsung.com (USCPEMTA) with SMTP id F4.62.09678.A82FCC56; Wed, 14 Feb 2024 12:04:10 -0500 (EST) Received: from ussmgxs1new.samsung.com (u89.gpu85.samsung.co.kr [203.254.195.89]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20240214170409uscas1p1e04d5916cb91670ea7f6413f0347d9ca~zyYNiK1Oa1217212172uscas1p1v; Wed, 14 Feb 2024 17:04:09 +0000 (GMT) X-AuditID: cbfec36d-acdff700000025ce-ce-65ccf28a4046 Received: from SSI-EX1.ssi.samsung.com ( [105.128.3.67]) by ussmgxs1new.samsung.com (USCPEXMTA) with SMTP id F7.3F.50167.982FCC56; Wed, 14 Feb 2024 12:04:09 -0500 (EST) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX1.ssi.samsung.com (105.128.2.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Wed, 14 Feb 2024 09:04:08 -0800 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Wed, 14 Feb 2024 09:04:08 -0800 From: Jim Harris To: Leon Romanovsky CC: Bjorn Helgaas , Kuppuswamy Sathyanarayanan , Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jason Gunthorpe , "Alex Williamson" , =?iso-8859-1?Q?Pierre_Cr=E9gut?= Subject: Re: [PATCH v2 1/2] PCI/IOV: Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" Thread-Topic: [PATCH v2 1/2] PCI/IOV: Revert "PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes" Thread-Index: AQHaW7MAtwi2xwjfZkaUZDAOVEJQA7EDbuYAgAHuDQCAAlV9AIAAuocAgACNHQCAAB2nAIAAIYAAgADA4wCAAKQ8gA== Date: Wed, 14 Feb 2024 17:04:08 +0000 Message-ID: In-Reply-To: <20240214071618.GE52640@unreal> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="iso-8859-1" Content-ID: <29CAD9892A45E6448C9198E23903385E@ssi.samsung.com> Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHKsWRmVeSWpSXmKPExsWy7djX87pdn86kGjy6wGbx7X8Pm8WSpgyL V2fWsllc+beH0WLThicsFpd3zWGzODvvOJvF+q/v2SzaV15hdeD0WLCp1GPTqk42j3knAz16 m9+xebQ8O8nm8X7fVTaPz5vkAtijuGxSUnMyy1KL9O0SuDI6fp9kLNglUbH2XSN7A+Ns4S5G Tg4JAROJNU3LGLsYuTiEBFYySrzbcpINwmllkri38RsjTNXsvomsEIk1jBK7pvQwQzifGCV6 1n1hgXCWMUocn3CcFaSFTUBT4teVNUwgtoiAusSHVRfB2pkFljNLtMz7CpYQFkiV+NS/HKoo TeLa6UuMEHaWxLcl68HiLAKqEnNWn2cGsXmB7Hn/28BsTgEdiakTz4PVMAqISXw/BbGMWUBc 4taT+UwQdwtKLJq9hxnCFpP4t+shG4StKHH/+0t2iHo9iRtTp7BB2HYSzY+nQc3Rlli28DXU XkGJkzOfsED0SkocXHED7GMJgRccEhPXLYAGkovErndfoWxpiavXp0ItzpZYub4DaCgHkF0g 0XAkCCJsLbHwz3qmCYwqs5CcPQvJSbO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TULCSjFjCyrmIULy0uzk2vKDbMSy3XK07MLS7NS9dLzs/dxAhM AKf/HY7cwXj01ke9Q4xMHIyHGCU4mJVEeCf1nkkV4k1JrKxKLcqPLyrNSS0+xCjNwaIkznv3 gUaqkEB6YklqdmpqQWoRTJaJg1OqgYnbbYsC30zz4N7okiXvjV6IX7ubpyxpyya8qcZ80Xtu kfTHdzgMHS0d3359f6vIabvSu0MnDjYfnvaVfaL53wvvLn2YKB5W/+6I/5WsX9xJx7+/cLt1 wP5nXDTH3LJVcie/8ondu51/M3Gmjvpv28Jd6v9W7D6943bO8loT3eVpWZtnt6VV7lXwcIrR MXtfdZzVRSjwpVncRY1fJo4qB0Qtv0qGt6d8PuEfWPmCRffhJ2meMH0nph01xVtrjL5kH3O8 7rXErs7hpV+MV78My4MHtnol3mm+rhoHnVNWWZ10/VbAeFHlw6LEQ4a5n32WmX6acL/33NVp H933xQhuSpWSPuJVLnc/6XOuk4zAUiWW4oxEQy3mouJEAK+E41hvAwAA X-CMS-MailID: 20240214170409uscas1p1e04d5916cb91670ea7f6413f0347d9ca CMS-TYPE: 301P X-CMS-RootMailID: 20240214170409uscas1p1e04d5916cb91670ea7f6413f0347d9ca References: <20240213174602.GD52640@unreal> <20240213194556.GA1219770@bhelgaas> <20240214071618.GE52640@unreal> On Wed, Feb 14, 2024 at 09:16:18AM +0200, Leon Romanovsky wrote: > On Tue, Feb 13, 2024 at 01:45:56PM -0600, Bjorn Helgaas wrote: > > On Tue, Feb 13, 2024 at 07:46:02PM +0200, Leon Romanovsky wrote: > > > On Tue, Feb 13, 2024 at 09:59:54AM -0600, Bjorn Helgaas wrote: > > > ... > >=20 > > > > I guess that means that if we apply this revert, the problem Pierre > > > > reported will return. Obviously the deadlock is more important tha= n > > > > the inconsistency Pierre observed, but from the user's point of vie= w > > > > this will look like a regression. > > > >=20 > > > > Maybe listening to netlink and then looking at sysfs isn't the > > > > "correct" way to do this, but I don't want to just casually break > > > > existing user code. If we do contemplate doing the revert, at the > > > > very least we should include specific details about what the user c= ode > > > > *should* do instead, at the level of the actual commands to use > > > > instead of "ip monitor dev; cat ${path}/device/sriov_numvfs". > > >=20 > > > udevadm monitor will do the trick. > > >=20 > > > Another possible solution is to refactor the code to make sure that > > > .probe on VFs happens only after sriov_numvfs is updated. > >=20 > > I like the idea of refactoring it so as to preserve the existing > > ordering while also fixing the deadlock. >=20 > I think something like this will be enough (not tested). It will et the n= umber of VFs > before we make VFs visible to probe: I'll push a v3, replacing the second patch with this one instead. Although based on this discussion it seems we're moving towards squashing the revert with Leon's suggested patch. Bjorn, I'll assume you're still OK with just squashing these on your end. I would like some input on how to actually test this though. Presumably we = see some event on device PF and we want to make sure if we read PF/device/sriov= _numvfs that we see the updated value. But the only type of event I think we can expect is the PF's sriov_numvfs CHANGE event. Is there any way for VFs to be created outside of writing to the sriov_numvfs sysfs file? My understanding is some older devices/drivers wil= l auto-create VFs when the PF is initialized, but it wasn't clear from the bu= g report whether that was part of the configuration here. Pierre, do you have any recollection on this? Or maybe testing for this case just means compile and verify with udevadm monitor that we see the CHANGE event before any of the VFs are actually created... >=20 > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index aaa33e8dc4c9..0cdfaae80594 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -679,12 +679,14 @@ static int sriov_enable(struct pci_dev *dev, int nr= _virtfn) > msleep(100); > pci_cfg_access_unlock(dev); > =20 > + iov->num_VFs =3D nr_virtfn; > rc =3D sriov_add_vfs(dev, initial); > - if (rc) > + if (rc) { > + iov->num_VFs =3D 0; > goto err_pcibios; > + } > =20 > kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > - iov->num_VFs =3D nr_virtfn; > =20 > return 0; > =