Message ID | 170752273749.1693615.1293677023514112939.stgit@bgt-140510-bm01.eng.stellus.in |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-60158-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1201052dyd; Fri, 9 Feb 2024 15:53:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5EbhqxWFMb9cnUdF+a30uhKk887IuO7t4LFAT52UEztrL51yej9OBSozqzbE1qCjz/uFh X-Received: by 2002:a17:903:246:b0:1d9:8d17:87b8 with SMTP id j6-20020a170903024600b001d98d1787b8mr1031831plh.34.1707522781196; Fri, 09 Feb 2024 15:53:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707522781; cv=pass; d=google.com; s=arc-20160816; b=wQft/rc+ZCjGS0UrYTvd0nfKUkQUOggHJ5fNP8s8Lj+TJpV4gXo5Tut9suVMpcA5yQ jMkeQmomT30nSP/ZgA63ymWCi5IaNHNbPtQsrTJ4cggrSzxwdOJN22w3BaAOe/z4YSs8 Pnrpcl1yFFAVASzcB6UMOui94a21PVbwwE+C0Wa6ZkXTftydcpgvQiLe5WssBSCcU0l1 2bAlL1UfBKD0sUJjS20ZpO4W9pTLETtL373vDdenJaYyPf2gIspkUQPKZmeO3WExcklY rB7my+SbE1o+LAxsmbdvMjH0DuiiX/iOZ1n8itSEu5tWde2gMxhvJVEyqEcUVSBWF5BA dA/A== 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:to:from:dkim-signature :dkim-filter; bh=WLrHOuX9LdrO7L5O1dP72CK5rXJ4snnRsQhv9u8vEK0=; fh=fyri73RBCF53KyFk4sAApAt4LIqmWclugV40Z6Mg9M8=; b=riSRYH7fcrkg8Wo5DTu3wF5jk+UVqi9ALJzFwbrojafN6WKf55k0Mb+0rlsA6MoeBX 5PTMFXFGdHr727M6hFBE1o8iQ7X2qaV9tOPzyYnbOji457MuDrIEHPXEjwYv8sKhkp01 7r1rCBJz69zS614ESkbi0RsH/yiAcKD+jarOJ2QBBBcTRdgbqoM82bXOE1KdIGdp3QFX 6uy4uXVQJDEWsRekD4wzqJ/fZVRrx3J6fLSoHeGCm9JEDwmawec9E1sw7WsMlH+Zm1H2 0XUsvbzWKNz8b7nrOKMDwt3TyspbMHh+H3QSThegWd2ruXv2QInPe97+9CU0jxUmvA+n 8aYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mN14RZDL; 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-60158-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60158-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCUd5plBAALndkZ/7X9krVt3TpCEIvmdxL6q524cQ3yI1k2VScZfGEfXNNycP6w42Aec1SmQOaYxldIL9rSZN3nxSpS5aQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j1-20020a170902da8100b001d97804deb2si2574039plx.459.2024.02.09.15.53.01 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 15:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60158-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mN14RZDL; 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-60158-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60158-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EE61728C3A9 for <ouuuleilei@gmail.com>; Fri, 9 Feb 2024 23:53:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDB3039FCD; Fri, 9 Feb 2024 23:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="mN14RZDL" 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 044F538399; Fri, 9 Feb 2024 23:52:19 +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=1707522742; cv=none; b=qYsCvZntC1Xb7vqZKhUV+JOxWaV5hJaRStZg8SEt2zz4FSd7M9LwhEw33rb5BPOaGnGNCpsnUcsd/RcC1SEVhiveVT0fpb0zaFwd/YrsnSPAycNwRoNccsGoPsnH+j1RUPtowuQF+reFH+ITuh5BpA4qQU2n3EUdjTOrVzqcw40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707522742; c=relaxed/simple; bh=WLrHOuX9LdrO7L5O1dP72CK5rXJ4snnRsQhv9u8vEK0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=DIMALQU1CgVjvKMuPZ9zJqZhQREBbzrjNPmTa7EprKTHXNkjG0VGksDiWJSFHMzQPpAeEt44g8I4owtygi5LqwS8YxKRW97xa27UovHbvpaVyIFgrmV0ikNozk2wcC6H7WlTI7OEZtw3w5MiPcycvnxvI01SpMPpNZtAjlQZemY= 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=mN14RZDL; 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 20240209235219usoutp0184de282892a811f8b9d7e9d2b15b3cbc~yVuJldZpG0135901359usoutp01F; Fri, 9 Feb 2024 23:52:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20240209235219usoutp0184de282892a811f8b9d7e9d2b15b3cbc~yVuJldZpG0135901359usoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707522739; bh=WLrHOuX9LdrO7L5O1dP72CK5rXJ4snnRsQhv9u8vEK0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mN14RZDLHqp2SNMowOLAWAowlYnXEl0FcmsVph8ugmoaXOMn6CbUhuxAYJj6U6414 SQzYMDTl7M+Ye444r5OHYP57uZX/BoBVIM552DA2HODRWR6QB0BXzSlLY9gORN0PrK e9rVv5Yr3AToaUlZtM4QadfA9Eoe/V9fJHgGCMKw= Received: from ussmges1new.samsung.com (u109.gpu85.samsung.co.kr [203.254.195.109]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20240209235218uscas1p122a48f65d0cbd18350608763c21ef317~yVuJfB9Ov2264622646uscas1p1O; Fri, 9 Feb 2024 23:52:18 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges1new.samsung.com (USCPEMTA) with SMTP id 55.51.09678.2BAB6C56; Fri, 9 Feb 2024 18:52:18 -0500 (EST) Received: from ussmgxs3new.samsung.com (u92.gpu85.samsung.co.kr [203.254.195.92]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209235218uscas1p2d0978af6623037fa1b9358a2ad2320c5~yVuJLHlSF3138731387uscas1p2u; Fri, 9 Feb 2024 23:52:18 +0000 (GMT) X-AuditID: cbfec36d-acdff700000025ce-cf-65c6bab23583 Received: from SSI-EX2.ssi.samsung.com ( [105.128.3.66]) by ussmgxs3new.samsung.com (USCPEXMTA) with SMTP id 97.EB.50948.2BAB6C56; Fri, 9 Feb 2024 18:52:18 -0500 (EST) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX2.ssi.samsung.com (105.128.2.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Fri, 9 Feb 2024 15:52:17 -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; Fri, 9 Feb 2024 15:52:17 -0800 From: Jim Harris <jim.harris@samsung.com> To: Bjorn Helgaas <bhelgaas@google.com>, "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Leon Romanovsky <leonro@nvidia.com>, "Jason Gunthorpe" <jgg@nvidia.com>, Alex Williamson <alex.williamson@redhat.com>, "pierre.cregut@orange.com" <pierre.cregut@orange.com> Subject: [PATCH v2 2/2] pci/iov: fix kobject_uevent() ordering in sriov_enable() Thread-Topic: [PATCH v2 2/2] pci/iov: fix kobject_uevent() ordering in sriov_enable() Thread-Index: AQHaW7MDr2cp3vZCgUeCreKO+yDYPA== Date: Fri, 9 Feb 2024 23:52:17 +0000 Message-ID: <170752273749.1693615.1293677023514112939.stgit@bgt-140510-bm01.eng.stellus.in> In-Reply-To: <170752254154.1693615.9176696143128338408.stgit@bgt-140510-bm01.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" Content-ID: <2400EE9658E5F547852121863CD747C6@ssi.samsung.com> Content-Transfer-Encoding: base64 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJKsWRmVeSWpSXmKPExsWy7djX87qbdh1LNfi8zsTi2/8eNoslTRkW V/7tYbTYtOEJi8XlXXPYLM7OO85msf7rezYHdo8Fm0o9epvfsXm0PDvJ5vF+31U2j8+b5AJY o7hsUlJzMstSi/TtErgyVj/6wFiwhbPixPnNrA2MUzi7GDk5JARMJC7fnsvexcjFISSwklGi Y9FSKKeVSaLr8kwWmKpfPyewQSTWMEqsXfWTFcL5yCgx/90LqMxSRolNf5+wgrSwCWhK/Lqy hgkkISJwlUli8uoPzCAJYYEgiQdPXzGC2CIC4RIH3jexQdh6Eidm3GYCsVkEVCS+fnwLVsMr EC2xe+c5sDinQIzEu75NYHMYBcQkvp9aAxZnFhCXuPVkPhPErYISi2bvYYawxST+7XrIBmEr Stz//hLoOQ6gek2J9bv0IVrtJDb1TWSDsBUlpnQ/ZIdYKyhxcuYTqPclJQ6uuMEC8ouEwBkO ibvvZk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uh+yQ5wgKHFy5hMWiFZJiYMrbrBMYBSfhWTbLIRJs5BMmoVk0iwkkxYw sq5iFC8tLs5Nryg2zkst1ytOzC0uzUvXS87P3cQIjN/T/w7H7GC8d+uj3iFGJg7GQ4wSHMxK IrwhS46kCvGmJFZWpRblxxeV5qQWH2KU5mBREue9+0AjVUggPbEkNTs1tSC1CCbLxMEp1cBU 6HT4YFyPMENx7U2bpwK//ucua9nLZ5T8eFnxkc49rrPterL2B+/O/33T9cq2UKHZE1gf5nWy W5+d8tdLJODpgz1y7kssmSwsNsvsOmWwNYxt3TTmSbOXzi4/5ZywIcP7l4VY0MW2GfW3DofW 5/3J/Prb0GTeDXWr69wGTNxMO/6KVqyKX3T69oTdD6Tv3fwuWvJ7erVCpTl785TErt2tvgWs 995yXpHd4LX3gYvLnnovy5RrXhmm5x374kSePftvyew5X+Xq9PvXAlTXTmlvEeu19PVf2tJ6 vkzwwMavCZVbynWTYpn+rehh4e1XW2rfLrBW8lur/vm/Ln7rl37NUdpzPmf7lOA1Xxtvuj5T YinOSDTUYi4qTgQAO5jdO04DAAA= X-CMS-MailID: 20240209235218uscas1p2d0978af6623037fa1b9358a2ad2320c5 CMS-TYPE: 301P X-CMS-RootMailID: 20240209235218uscas1p2d0978af6623037fa1b9358a2ad2320c5 References: <170752254154.1693615.9176696143128338408.stgit@bgt-140510-bm01.eng.stellus.in> <CGME20240209235218uscas1p2d0978af6623037fa1b9358a2ad2320c5@uscas1p2.samsung.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790467407461584189 X-GMAIL-MSGID: 1790467407461584189 |
Series |
PCI/IOV: sriov_numvfs bug fixes
|
|
Commit Message
Jim Harris
Feb. 9, 2024, 11:52 p.m. UTC
Wait to call kobject_uevent() until all of the associated changes are done, including updating the num_VFs value. This avoids any possibility of userspace responding to the event and getting a stale value (although probably impossible to actually happen). Suggested-by: Leon Romanovsky <leonro@nvidia.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jim Harris <jim.harris@samsung.com> --- drivers/pci/iov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 2/9/24 3:52 PM, Jim Harris wrote: > Wait to call kobject_uevent() until all of the associated changes are done, > including updating the num_VFs value. This avoids any possibility of > userspace responding to the event and getting a stale value (although > probably impossible to actually happen). > > Suggested-by: Leon Romanovsky <leonro@nvidia.com> > Reviewed-by: Leon Romanovsky <leonro@nvidia.com> > Signed-off-by: Jim Harris <jim.harris@samsung.com> > --- It looks fine to me. Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > drivers/pci/iov.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index 0ca20cd518d5..c00b0f822526 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -677,8 +677,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) > if (rc) > goto err_pcibios; > > - kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > iov->num_VFs = nr_virtfn; > + kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > > return 0; > >
On Fri, Feb 09, 2024 at 07:22:17PM -0800, Kuppuswamy Sathyanarayanan wrote: > On 2/9/24 3:52 PM, Jim Harris wrote: > > @@ -677,8 +677,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) > > if (rc) > > goto err_pcibios; > > > > - kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > > iov->num_VFs = nr_virtfn; > > + kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); Since it's accessed unlocked now, I *think* this wants appropriate barriers to ensure the order is observed the same on all CPUs. Something like 'smp_store_release(&iov->num_VFs, nr_virtfn)' for writing it, and use 'smp_load_acquire()' on the read-side.
On Mon, Feb 12, 2024 at 08:17:58AM -0700, Keith Busch wrote: > On Fri, Feb 09, 2024 at 07:22:17PM -0800, Kuppuswamy Sathyanarayanan wrote: > > On 2/9/24 3:52 PM, Jim Harris wrote: > > > @@ -677,8 +677,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) > > > if (rc) > > > goto err_pcibios; > > > > > > - kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > > > iov->num_VFs = nr_virtfn; > > > + kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); > > Since it's accessed unlocked now, I *think* this wants appropriate > barriers to ensure the order is observed the same on all CPUs. Something > like 'smp_store_release(&iov->num_VFs, nr_virtfn)' for writing it, and > use 'smp_load_acquire()' on the read-side. It is unlocked only for sysfs read. IMHO it is overkill to use stores for this case. Thanks >
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 0ca20cd518d5..c00b0f822526 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -677,8 +677,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) if (rc) goto err_pcibios; - kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); iov->num_VFs = nr_virtfn; + kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); return 0;