Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp117378rdb; Wed, 14 Feb 2024 14:56:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwxGjWYDArXu/BZR0POy6Wb5jQnDcZLx1kLYx/YzuVvU+2tlmZaz2WgmOv665ZmDoVNnDFUC5IXbKbAdnA80Nld/L/MT6AH0PRMvz+rw== X-Google-Smtp-Source: AGHT+IGWCTh6KiwGoWL8LyInST+6F/RV+K13aTsRdsdYalWtirZ0mC0njIx+HhKt8cQaQTD08dUH X-Received: by 2002:a05:6830:1c7:b0:6e2:d925:4f20 with SMTP id r7-20020a05683001c700b006e2d9254f20mr3909364ota.25.1707951364261; Wed, 14 Feb 2024 14:56:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707951364; cv=pass; d=google.com; s=arc-20160816; b=uVdyhDnZgks/ReZf/XmnxsbcaWbvMqcA8LtxLQbZGEN+RWlt3k1XxDcsel1rNGCB22 LLcRgDkwmQsNtVR/cYFsgBU92c4N7Xbf/xWszTxpWEhE4ecytMsvUyji/Y15cwyNdLCE VSWgTYQd010sqDPXti195XxqP3gvjHOtuPzuoldgn1H5ErP7JM9be5EqBeanqoYM0aqK 8/mdVW/Cgh099V3oM+Gj3lYvU2onJgphGOaT4KlgRekaRjdQXAfKGrNQjf6gVbqitglj +WebX/5x5N7LMHZZ7UTbrUonkTQlgKZuU7SMe4vGuJYoAQSRolibVIgPTH7HqMMzH9mR HSuQ== 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=hzYFUuVAQk0FCSPELf76ZGU4cGQXXNSqGnjqdzUhN60=; fh=24IKISFz5JFTTkTC2W2mlhrkCABATpPPQnsmtKhO794=; b=EJceyW8WBMCizbagNMH90g+IuteCNCsxdS3v50P3wh/5yLbQRsKlLsAqXSNDUCB/bQ 2h0zCuPi5Ite3DbYqM+hwNJ9Aj9ovaTNbtkdOpaH1zE7gou9/UMAlUOXVBPmeFhBL2qY 2aul7Dz9bNo9N9TUK/sdpfjdC7djOk0Hxo6WkoLzTfU1f+XZZ5KGg+C9kAnlDirGWulo dYyeTIbpyUhqoKm4h43n/SpdgHEbZ/y9LmDU0tqQ33piN1Xo4GUJsIjBKPNBBtvwpbra zqwT8TJH/Pd8vGrzy7pUx8VeHK+TdGY2ZRrE514hCgcvbZH7tsPI+5BPRmnhXOiJUom2 n25Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Zgs10DNi; 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-66084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66084-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 3-20020ac85703000000b0042db36a9447si16228qtw.66.2024.02.14.14.56.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 14:56:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Zgs10DNi; 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-66084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66084-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C80BE1C2356A for ; Wed, 14 Feb 2024 22:55:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6C601DDD7; Wed, 14 Feb 2024 22:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Zgs10DNi" 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 9D263250F6; Wed, 14 Feb 2024 22:55:40 +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=1707951343; cv=none; b=aclRR33K7FmXefMGqov9bQCGdqUeDykXytPKicrsK7PeQiHvKFoy/9zoGukHYdT/bDCgHTuXQgomMqcZPssErXn0PiDyNd6gbDxu1RyFzP2wIenVSJxK00dAvFpERJ4oEbrnSCsUYuFRqO2Cii4u89ypcJvXTGnY/nswVh3ATDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707951343; c=relaxed/simple; bh=0+cg/xnEl8pLBBzYZbEugcpP7E4uoOwj6ToG5UYN5aI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=R0OqupYMl1hqzx48RZDwYqPiDwEukUAaigcECgDCBzhPjp6IHb6rrHkx3EcUYDm7SlI30/BWfpqV1Fj+GYs6QE6VuHJK5Ewd838B8UYKnom4qJXKqUavyIfwdIK13nG8A7IRUt61Hlz86rMjMpzbZN6SjMzN11uKMALGoTuEB1A= 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=Zgs10DNi; 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 uscas1p1.samsung.com (unknown [182.198.245.206]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20240214225539usoutp0138cc055b6f98c374b1e0e1b463a1295a~z3LGY5RzI2570225702usoutp013; Wed, 14 Feb 2024 22:55:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20240214225539usoutp0138cc055b6f98c374b1e0e1b463a1295a~z3LGY5RzI2570225702usoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707951339; bh=hzYFUuVAQk0FCSPELf76ZGU4cGQXXNSqGnjqdzUhN60=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Zgs10DNiJbDcyf2kAi2AEfSosi1fXUR2EyMjQNOClVkj8WUVteL/ean0J2U9Q0aSc FwRqMs8U3jCYNu2XjNIU+VP4ypUOtlmtEHEiLcuJHnN965wM7U2/zwSWxXP/aTE1Li Hen9nfmo+qGrT2UdxBMMG55+2pncXNi0pUzLBYa8= Received: from ussmges3new.samsung.com (u112.gpu85.samsung.co.kr [203.254.195.112]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20240214225538uscas1p1a0bd544707f70208daadf8e306aadb9f~z3LGJg21t0998609986uscas1p1m; Wed, 14 Feb 2024 22:55:38 +0000 (GMT) Received: from uscas1p1.samsung.com ( [182.198.245.206]) by ussmges3new.samsung.com (USCPEMTA) with SMTP id FF.46.09550.AE44DC56; Wed, 14 Feb 2024 17:55:38 -0500 (EST) Received: from ussmgxs2new.samsung.com (u91.gpu85.samsung.co.kr [203.254.195.91]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240214225538uscas1p2d6502c3bd144e4d90d4506acf4847159~z3LFzDyZq1875018750uscas1p2I; Wed, 14 Feb 2024 22:55:38 +0000 (GMT) X-AuditID: cbfec370-933ff7000000254e-f2-65cd44eaae9c Received: from SSI-EX1.ssi.samsung.com ( [105.128.3.66]) by ussmgxs2new.samsung.com (USCPEXMTA) with SMTP id 50.C5.45319.AE44DC56; Wed, 14 Feb 2024 17:55:38 -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 14:55:37 -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 14:55:37 -0800 From: Jim Harris To: Bjorn Helgaas CC: Leon Romanovsky , 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: AQHaW7MAtwi2xwjfZkaUZDAOVEJQA7EDbuYAgAHuDQCAAlV9AIAAuocAgACNHQCAAB2nAIAAIYAAgADA4wCAAKQ8gIAADNIAgABVYgA= Date: Wed, 14 Feb 2024 22:55:37 +0000 Message-ID: In-Reply-To: <20240214175000.GA1260022@bhelgaas> 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: <76E6B18DAFFC284592B288B474CBC3ED@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+NgFtrNKsWRmVeSWpSXmKPExsWy7djXc7qvXM6mGhzsULf49r+HzWJJU4bF qzNr2Syu/NvDaLFpwxMWi8u75rBZnJ13nM1i/df3bBbtK6+wOnB6LNhU6rFpVSebx7yTgR69 ze/YPFqenWTzeL/vKpvH501yAexRXDYpqTmZZalF+nYJXBmLrhQVfFSqOHb2F1MD43+pLkZO DgkBE4mFj3axdTFycQgJrGSUWLtmPhOE08oksfFgOwtM1dfD51khEmsYJa59WsIO4XxilFj5 4woLhLOMUWLGu/WMIC1sApoSv66sAZrFwSEioCbR1R4KUsMssIJZYsn9R+wgNcICqRKf+pcz gdgiAmkS105fYoSwyySube9iBrFZBFQl5n76xQpi8wLZaxYtAjuJU8BA4uPFNjCbUUBM4vup NWBzmAXEJW49mc8EcbagxKLZe5ghbDGJf7seskHYihL3v79kh6jXk7gxdQobhG0n8WhPHzOE rS2xbOFrZoi9ghInZz6BBoWkxMEVN8AelhD4wCHx9PASNpAnJQRcJBobkyBqpCX+3l0GdUO2 xMr1HUwQJQUSDUeCIMLWEgv/rGeawKgyC8nVs5BcNAvJRbOQXDQLyUULGFlXMYqXFhfnpqcW G+ellusVJ+YWl+al6yXn525iBKav0/8OF+xgvHXro94hRiYOxkOMEhzMSiK8k3rPpArxpiRW VqUW5ccXleakFh9ilOZ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vmVQh3pTEyqrUovz4otKc1OJDjNIc LErivHcfaKQKCaQnlqRmp6YWpBbBZJk4OKUamKr4t7/85D/hXzt3s2jplIzU8LbCH8lcvM9k 7Z4tndhquuLv6VkJ2bJzznS1vp3XVMhdw7qQ61DMoeVHbVnZ2IJ/F2l+el9bGfdNJ3pGWOKa w+cN/QwkVYTmfQ3n/bn6afO7+/OqWforb/Nbfzi391b9vdS2Jb1z838a5B20W5okP6XwUurn 9FnVqaKXj1b9NVAQM5Nfm1sRx6e9x2Af0yFJ5sXV1xuqlxk4mke15B+MUu8Wm16+udTN6MSl xaH69+6yaiWH3XSzFrLYvPJyc0f11ZXvVid9CKp9fLg1Rirvh0by29MWohmx3759Dmy8pzPh 1ZqavDX3pE+YzWPIfPdw2hY3mzPSner8+WsXK7EUZyQaajEXFScCAFXG7HJsAwAA X-CMS-MailID: 20240214225538uscas1p2d6502c3bd144e4d90d4506acf4847159 CMS-TYPE: 301P X-CMS-RootMailID: 20240214225538uscas1p2d6502c3bd144e4d90d4506acf4847159 References: <20240214175000.GA1260022@bhelgaas> On Wed, Feb 14, 2024 at 11:50:00AM -0600, Bjorn Helgaas wrote: > On Wed, Feb 14, 2024 at 05:04:08PM +0000, Jim Harris wrote: > > 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 Pi= erre > > > > > > reported will return. Obviously the deadlock is more important= than > > > > > > the inconsistency Pierre observed, but from the user's point of= view > > > > > > 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 bre= ak > > > > > > existing user code. If we do contemplate doing the revert, at = the > > > > > > very least we should include specific details about what the us= er code > > > > > > *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 th= at > > > > > .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 t= he number of VFs > > > before we make VFs visible to probe: > >=20 > > I'll push a v3, replacing the second patch with this one instead. Altho= ugh > > based on this discussion it seems we're moving towards squashing the re= vert > > with Leon's suggested patch. Bjorn, I'll assume you're still OK with ju= st > > squashing these on your end. >=20 > Yep. >=20 > > 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. > >=20 > > 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 will auto-create VFs when the PF is initialized, but > > it wasn't clear from the bug report whether that was part of the > > configuration here. Pierre, do you have any recollection on this? > >=20 > > 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 > I just want to make sure that Pierre's existing code continues to work > unchanged. >=20 > Ideally we could revert 35ff867b7657 ("PCI/IOV: Serialize sysfs > sriov_numvfs reads vs writes"), reproduce the problem with the shell > script attached to https://bugzilla.kernel.org/show_bug.cgi?id=3D202991 > (I assume Pierre used a /sys/.../sriov_numvfs write to trigger the > change). =20 That shell script generates no output when writing to sriov_numvfs, so I'm unable to reproduce the problem. Terminal 1: # ip monitor dev ens7f0np0 Terminal 2: # echo 1 > /sys/class/net/ens7f0np0/device/sriov_numvfs # No output in terminal 1. I've done what testing I can with the proposed patch below, I'll send out t= he v3 series here shortly. > Then we could verify that with 35ff867b7657 still reverted but the > change below added, the problem is no longer reproducible. >=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, in= t 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; > > > =