Received: by 2002:a17:90a:37e8:0:0:0:0 with SMTP id v95csp362433pjb; Fri, 4 Oct 2019 00:27:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxytgsoCg57wSuGzxoPqCH0gEBcDtKmswKvbJ7G0fCw6YacZqpqfbuZz2ggI87YLZ2KKSbh X-Received: by 2002:a50:fa09:: with SMTP id b9mr13784177edq.165.1570174049675; Fri, 04 Oct 2019 00:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570174049; cv=none; d=google.com; s=arc-20160816; b=qXq7vTnCzXEZh79mJLrTedoT6XYhCin7QfdzH1/fCPFZY1HrSzdtgOecOUAnbHBle/ vFZXLpj4doHUvW27pA7gFrHjzXxhLLCuMqsH1JzG4v8t2bA5K6QrqzNwTBN6e1JTSJ5g vKW1xTxzc818bqA2zk3VEip476/xMe/jytRMMXxUUiBwr2UAT2ZAS1EBDOM+cdIZcS/9 17ZY63yehR6tjvq9LwfR/VjP4dh/YrMTdeINzearjPHvQAxxUoCo/BjiiIABPwkg5lVA unJvPkS3ahsmLiSHMvvGHI7rlq78nIvQ/fSukP4LCedTvfTXgLc13VY3W7jlr6TvYS+1 sSPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=itG42API114huksgPQAHb88tSFIwWsAom19B6aoA+Qs=; b=GP44Ob+lvthLRD3sGr0QDTNcxrB3OrLq1voZWnK3I90jxgQV5IuPwIq6NzkzetqbYd bh7Gq3KnrJbkY2r69E/MRPjghGt/liyMUM9vFsXoDZ+U9IQqkangreM/xhTHRCtmfliW NfRo0N4yt5wG37GbHNGtz3jc5gaWUCFP5v5L1Wh8I8d5xohWMneh5FdF4pTjj/badhPf lL6bxFEYK9Q6TBzJxh4sluXaqhRI0bMSfjceJZU5dRA9hHC64P0OtJXc3RgPLHoQmxaX ZxmLbZjyNQ9Yx3XMPmaKA6FzLeJ9xDgavwHZJmfd2+5wIGhIE8t3dKtH5F6E0VCAQidO 04Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=gIprMk8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23si2420777ejk.186.2019.10.04.00.27.05; Fri, 04 Oct 2019 00:27:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=gIprMk8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729742AbfJCWg5 (ORCPT + 99 others); Thu, 3 Oct 2019 18:36:57 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:39962 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727302AbfJCWg5 (ORCPT ); Thu, 3 Oct 2019 18:36:57 -0400 Received: by mail-qt1-f196.google.com with SMTP id f7so5947687qtq.7 for ; Thu, 03 Oct 2019 15:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=itG42API114huksgPQAHb88tSFIwWsAom19B6aoA+Qs=; b=gIprMk8LelWg0uG/qfXeYCxNyxqYw9kTOe6Nwb6sO/SKr/62XIGhhY97GPaeuHbUU7 v8spLpK53iQXvC1sP3v/H2kNGQeNpcWMJUGYEHwVu58UrT8XfD+luRiWfjNXgmCtn7IT 6+AqMtubm/j7ah9AjiC+XqFP0+FgcIIgXmRkNrkGJCYibolqgVlaPPPzRDuZXlVjQMMd Gf9zH3b4ebzGoAKIBFnVWPg1zL41TQlPX2rcCwJpR/HjE5sP8kOjOnMm+BeZOzav1D4W 1Xr1mcYvDlrs6gVvscSeoUqioGBkx77gfq+z6Mdl3OGExL73lZ+QlO4PXKdq0Agi2Nzb iYqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=itG42API114huksgPQAHb88tSFIwWsAom19B6aoA+Qs=; b=hnjNw/EL632YO/rg6Tzi0RShQwsAYXR1qJEtYPXmL4xMYM22U0J/lWqSjL+FXjZ+RG u+Orw/J3qB4WQT3HWM3VptTcMVFOFEVFEcRixQUsrdjWoot5g73xcNoru6/F9adllXyA FQoeD3UuPUS8S4ARXW9D1GZzZluU+yM9j1qOzsuHsDhkOQCRMFUGwcN07uESIt6CB1Rk SocbGwUIsx84p1Fr835NagAKhcGj5svKDcQA6eo4cwQlvO/JYRU9uZCgR75PJFeKsfI6 /hn+7WNfJraU/asn7S/CwzlrkUUovrQeAdoC6phOlKZzdXlGGMfpIqCsggNTWMjbXb/7 +G1Q== X-Gm-Message-State: APjAAAVw+O0MeY/fKRV3Dl3CDDt6t+1UaI9cYxDD3LAKB6wIRYWYG4V7 ddOT8dvd3wHry9j9Nw+HnUv43Q== X-Received: by 2002:ac8:5543:: with SMTP id o3mr12730023qtr.129.1570142215973; Thu, 03 Oct 2019 15:36:55 -0700 (PDT) Received: from cakuba.hsd1.ca.comcast.net ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id z20sm2088520qtu.91.2019.10.03.15.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 15:36:55 -0700 (PDT) Date: Thu, 3 Oct 2019 15:36:48 -0700 From: Jakub Kicinski To: Bjorn Helgaas Cc: CREGUT Pierre IMT/OLN , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Donald Dutile , Alexander Duyck Subject: Re: [PATCH] PCI/IOV: update num_VFs earlier Message-ID: <20191003153648.786ad0bf@cakuba.hsd1.ca.comcast.net> In-Reply-To: <20191003221007.GA209602@google.com> References: <49b0ad6d-7b6f-adbd-c4a3-5f9328a7ad9d@orange.com> <20191003221007.GA209602@google.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Oct 2019 17:10:07 -0500, Bjorn Helgaas wrote: > On Thu, Oct 03, 2019 at 11:04:45AM +0200, CREGUT Pierre IMT/OLN wrote: > > Le 02/10/2019 =C3=A0 01:45, Bjorn Helgaas a =C3=A9crit=C2=A0: =20 > > > On Fri, Apr 26, 2019 at 10:11:54AM +0200, CREGUT Pierre IMT/OLN wrote= : =20 > > > > I also initially thought that kobject_uevent generated the netlink = event > > > > but this is not the case. This is generated by the specific driver = in use. > > > > For the Intel i40e driver, this is the call to i40e_do_reset_safe in > > > > i40e_pci_sriov_configure that sends the event. > > > > It is followed by i40e_pci_sriov_enable that calls i40e_alloc_vfs t= hat > > > > finally calls the generic pci_enable_sriov function. =20 > > > I don't know anything about netlink. The script from the bugzilla > > > (https://bugzilla.kernel.org/show_bug.cgi?id=3D202991) looks like it > > > runs > > >=20 > > > ip monitor dev enp9s0f2 > > >=20 > > > What are the actual netlink events you see? Are they related to a > > > device being removed? =20 > >=20 > > We have netlink events both when num_vfs goes from 0 to N and from N to= 0. > > Indeed you have to go to 0 before going to M with M !=3D N. =20 >=20 > Right. FWIW I think this netlink event is an artefact of i40e implementation, and is not something the networking stack generates. Hopefully Alex can correct me if I'm wrong, but I don't think most drivers will generate such an event. > commit 0940fc95da45 > Author: Pierre Cr=C3=A9gut > Date: Wed Sep 11 09:27:36 2019 +0200 >=20 > PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes > =20 > When sriov_numvfs is being updated, drivers may notify about new devi= ces > before they are reflected in sriov->num_VFs, so concurrent sysfs reads > previously returned stale values. > =20 > Serialize the sysfs read vs the write so the read returns the correct > num_VFs value. > =20 > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D202991 > Link: https://lore.kernel.org/r/20190911072736.32091-1-pierre.cregut@= orange.com > Signed-off-by: Pierre Cr=C3=A9gut > Signed-off-by: Bjorn Helgaas >=20 > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index b3f972e8cfed..e77562aabbae 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -254,8 +254,14 @@ static ssize_t sriov_numvfs_show(struct device *dev, > char *buf) > { > struct pci_dev *pdev =3D to_pci_dev(dev); > + u16 num_vfs; > + > + /* Serialize vs sriov_numvfs_store() so readers see valid num_VFs */ > + device_lock(&pdev->dev); > + num_vfs =3D pdev->sriov->num_VFs; > + device_lock(&pdev->dev); > =20 > - return sprintf(buf, "%u\n", pdev->sriov->num_VFs); > + return sprintf(buf, "%u\n", num_vfs); > } > =20 > /* The change makes sense to me!