Message ID | 170249390826.436889.13896090394795622449.stgit@bgt-140510-bm01.eng.stellus.in |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7999211dys; Wed, 13 Dec 2023 10:58:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrHpLmjcSxlUOn05pDn0UbBPuuGFLD4lwy4O4LLqDPKCiuISxqF2VliSO62PvjpVQXaRAZ X-Received: by 2002:a05:6a00:179e:b0:6ce:41ab:9a13 with SMTP id s30-20020a056a00179e00b006ce41ab9a13mr4880754pfg.61.1702493923222; Wed, 13 Dec 2023 10:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702493923; cv=none; d=google.com; s=arc-20160816; b=alFvhtHmqbxtn5X4bMWEmF2QCeSw/ZqaL5FER/cVzBuUgJzEY8Iq6PY6M0s8Oz59Yr NtSlGy7sgVqowPvqStCBXR6zrlBdVXSQF8RrRlPu305st7yn/YJmL4pI0ADN9XOPEn9l kWmROqPGumLDv6lnFG/nF4fVJgVTIKtyhqEXVANqDUbLL128hkwdjaNbF9fNrZJyppoa 1UWXwv0t1wc9xYAWJADD2/ic4chOXWqZG2/5RkhUNZL1wHKFmY6yxNtLkadPCqA/kNRs IL/eDMe5Gl6gul5SJpHBHWIOTQyJImKg3a+nHCMfR7nORIyXzSGb2P9m3FK/+LOZYiBz yPOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-id:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :to:from:dkim-signature:dkim-filter; bh=h80joI7oKHnktwgbqFNgoVPBTLOrCLlQDQIfQdxtpkY=; fh=OtPxTFaFpOC/i6a2eMxR19Qv834xIhrDak+9qqew0ho=; b=YGn+gW2OSyCKKgbxEt5xzvmAJiQ+OLatbm9Y2s9lAMNWWybvG1tIh11GxeZbAgOiWT 7k8ELKzXZhxIp+D2phMaoWiYaEO+SCrraSYJZj1O23K+znZSX1YMno/7ZxYV5dk0dNmv XwNXqy4DF4Ijyillno2jg9vWJzB3se8ZDKE1kxrcb2O5Kk0/HmV3YKOY902mZWFYMOUv oUqpxYrvVd3g3bVXtTrnehotlYV0UntcedMrVe//8r+ZKTYcxIoYeQxM0QMTlR4uJ+wC nYmi4vmjufcaTDlkdP5Cf0q5JECknJnACrusUC1sIv9AraRJqq83LIhXMwCEkQS3Vl/f HpEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ibVOgsYD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f51-20020a056a000b3300b006ce7e15ce8esi9529287pfu.239.2023.12.13.10.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ibVOgsYD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 25F6B803F97C; Wed, 13 Dec 2023 10:58:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235450AbjLMS63 (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 13:58:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235384AbjLMS61 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 13:58:27 -0500 Received: from mailout1.w2.samsung.com (mailout1.w2.samsung.com [211.189.100.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72A85B0; Wed, 13 Dec 2023 10:58:32 -0800 (PST) Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20231213185830usoutp01ff139d42e939a50e9312679d91a01232~geTDwxzY-0534805348usoutp01j; Wed, 13 Dec 2023 18:58:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20231213185830usoutp01ff139d42e939a50e9312679d91a01232~geTDwxzY-0534805348usoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1702493910; bh=h80joI7oKHnktwgbqFNgoVPBTLOrCLlQDQIfQdxtpkY=; h=From:To:Subject:Date:References:From; b=ibVOgsYD8Qh7Wl2sgC6IbYWeOKkRJxvzBd6EqmdTn23eR5OsJSYNSBeCeCZmc3ILY 4tPFZiaRrwHcxrVPuBOk6xY6tHq/lvG2w/kiBRl7da6bKQOPW4NDpJjmjDhrPln4CJ qv4LIma0KcRJ9ZEoLSw1ieDFXeHJVOOO/9GYpks0= Received: from ussmges2new.samsung.com (u111.gpu85.samsung.co.kr [203.254.195.111]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20231213185830uscas1p26d838293335c7a41156280e078780a29~geTDpZt6P3022330223uscas1p2w; Wed, 13 Dec 2023 18:58:30 +0000 (GMT) Received: from uscas1p1.samsung.com ( [182.198.245.206]) by ussmges2new.samsung.com (USCPEMTA) with SMTP id 18.FC.09760.6DEF9756; Wed, 13 Dec 2023 13:58:30 -0500 (EST) Received: from ussmgxs2new.samsung.com (u91.gpu85.samsung.co.kr [203.254.195.91]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20231213185829uscas1p2fc3ee6a9c92bff3cc9a043a9ff93bd27~geTDPFIsL3023830238uscas1p2i; Wed, 13 Dec 2023 18:58:29 +0000 (GMT) X-AuditID: cbfec36f-7f9ff70000002620-9b-6579fed61b1f Received: from SSI-EX1.ssi.samsung.com ( [105.128.3.66]) by ussmgxs2new.samsung.com (USCPEXMTA) with SMTP id E1.E1.09813.5DEF9756; Wed, 13 Dec 2023 13:58:29 -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, 13 Dec 2023 10:58:28 -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, 13 Dec 2023 10:58:28 -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> Subject: [PATCH] pci/iov: fix kobject_uevent() ordering in sriov_enable() Thread-Topic: [PATCH] pci/iov: fix kobject_uevent() ordering in sriov_enable() Thread-Index: AQHaLfZbfzSE7OYN20WpA0TR5aL0dA== Date: Wed, 13 Dec 2023 18:58:28 +0000 Message-ID: <170249390826.436889.13896090394795622449.stgit@bgt-140510-bm01.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [105.128.2.176] Content-Type: text/plain; charset="utf-8" Content-ID: <6E0FA9BB41EEBF40A7FBB146649D7BF0@ssi.samsung.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsWy7djXc7rX/lWmGnzZx2Lx7X8Pm8WSpgyL K//2MFps2vCExeLyrjlsFmfnHWdzYPNYsKnUo7f5HZvH+31X2Tw+b5ILYInisklJzcksSy3S t0vgylg84Q9rwSb2ilkPTBsYZ7B3MXJySAiYSBxb/54JxBYSWMko0bNFpYuRC8huZZJ48mo1 K0zRzd332SASaxgl1l47zALR8YlR4sHcOIjEMkaJ7y9awEaxCWhK/LqyBswWEZjDJDHjgieI LSzgKXHi0zegZg6geIDE85f1ECV6Eu3PP4NdxCKgKnHmXjsjSAmvQLTEjJ1gJYwCYhLfT0FM ZBYQl7j1ZD4TxG2CEotm72GGsMUk/u16yAZhK0rc//6SHWQMM9A163fpQ7TaSaza/Y0FwlaU mNL9EGwrL9CYkzOfsEC0SkocXHEDyp7LIXHooSyE7SIxf8JVqPHSEn/vLoM6IVti5foOJpBV EgIFEg1HgiDC1hIL/6yHuphP4u+vR4wQJbwSHW1CExiVZiH5ZRbCnbOQ3DkLyZ2zkNy5gJF1 FaN4aXFxbnpqsVFearlecWJucWleul5yfu4mRmDaOf3vcP4Oxuu3PuodYmTiYDzEKMHBrCTC e3JHeaoQb0piZVVqUX58UWlOavEhRmkOFiVxXkPbk8lCAumJJanZqakFqUUwWSYOTqkGJl61 iYX7F8dtPcvQz7FyyXWlZo+t5uvnX19zbvsjw8LTHjFiB47OnnF/pXz4PxnuPtMACykRmRt8 jbK8TVNbJpmrP5rEva35XdD13h2rdkvcLLedzNpVsmvPXvkf2zKOZQeeOKx2grk70Ozuxy9M t09JTRNYYHLx8bqN+YWc5ccr3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sZsdrSw+Tbt 58yZU8NK+vf23vbNXd7WcVp5pmnCrFslPxn5XHb3PMo8fKKuMyZ5blpcmX3FukXNb3XVtsw4 4hEopsB+y1fTa7PF/wO/z/z0NT2lxFKckWioxVxUnAgAYpTLaCkDAAA= X-CMS-MailID: 20231213185829uscas1p2fc3ee6a9c92bff3cc9a043a9ff93bd27 CMS-TYPE: 301P X-CMS-RootMailID: 20231213185829uscas1p2fc3ee6a9c92bff3cc9a043a9ff93bd27 References: <CGME20231213185829uscas1p2fc3ee6a9c92bff3cc9a043a9ff93bd27@uscas1p2.samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:58:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785194267809033284 X-GMAIL-MSGID: 1785194267809033284 |
Series |
pci/iov: fix kobject_uevent() ordering in sriov_enable()
|
|
Commit Message
Jim Harris
Dec. 13, 2023, 6:58 p.m. UTC
Wait to call kobject_uevent() until all of the associated changes are done,
including updating the num_VFs value.
Suggested 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 Wed, Dec 13, 2023 at 06:58:28PM +0000, Jim Harris wrote: > Wait to call kobject_uevent() until all of the associated changes are done, > including updating the num_VFs value. This seems right to me. Can we add a little rationale to the commit log? E.g., something about how num_VFs is visible to userspace via sysfs and we don't want a race between (a) userspace reading num_VFs because of KOBJ_CHANGE and (b) the kernel updating num_VFs? (If that's the actual reason.) If there's a problem report about this, include that reference as well. > Suggested 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(-) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index 25dbe85c4217..3b768e20c7ab 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -683,8 +683,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 Wed, Dec 13, 2023 at 01:26:52PM -0600, Bjorn Helgaas wrote: > On Wed, Dec 13, 2023 at 06:58:28PM +0000, Jim Harris wrote: > > Wait to call kobject_uevent() until all of the associated changes are done, > > including updating the num_VFs value. > > This seems right to me. Can we add a little rationale to the commit > log? E.g., something about how num_VFs is visible to userspace via > sysfs and we don't want a race between (a) userspace reading num_VFs > because of KOBJ_CHANGE and (b) the kernel updating num_VFs? (If > that's the actual reason.) > > If there's a problem report about this, include that reference as > well. There's a second patch that I haven't pushed yet that has more of the rationale that led to this suggestion from Leon - see thread "Locking between vfio hot-remove..." I'll push the two patches as a series. The second patch will effectively revert 35ff867b7, since Leon felt the reasoning behind that patch was incorrect. I'll tie all of that into the cover letter. -Jim > > > Suggested 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(-) > > > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > > index 25dbe85c4217..3b768e20c7ab 100644 > > --- a/drivers/pci/iov.c > > +++ b/drivers/pci/iov.c > > @@ -683,8 +683,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; > > > >
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 25dbe85c4217..3b768e20c7ab 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -683,8 +683,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;