From: Bjorn Helgaas <helgaas@kernel.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, lukas@wunner.de,
kwilczynski@kernel.org, mani@kernel.org,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
Shuan He <heshuan@bytedance.com>
Subject: Re: [PATCH v2] PCI: Remove redudant call to pci_proc_attach_device()
Date: Mon, 9 Mar 2026 17:50:18 -0500 [thread overview]
Message-ID: <20260309225018.GA636900@bhelgaas> (raw)
In-Reply-To: <20260228072129.10445-1-manivannan.sadhasivam@oss.qualcomm.com>
On Sat, Feb 28, 2026 at 12:51:29PM +0530, Manivannan Sadhasivam wrote:
> pci_proc_init() should just initialize the top level procfs directory for
> PCI devices and let pci_bus_add_device() add the device specific procfs
> attributes later.
>
> But it is also calling pci_proc_attach_device() for each PCI device. This
> causes a race condition with pci_bus_add_device(), which may run in
> parallel, calling the same API, leading to the below warning spat:
>
> proc_dir_entry '000c:00/00.0' already registered
> WARNING: CPU: 2 PID: 179 at fs/proc/generic.c:375 proc_register+0xf6/0x180
> proc_register+0xf6/0x180
> proc_create_data+0x3e/0x60
> pci_proc_attach_device+0x74/0x130
> pci_bus_add_device+0x42/0x100
> pci_bus_add_devices+0xc6/0x110
>
> Hence, remove the call to pci_proc_attach_device() from pci_proc_init().
Seems plausible, but given that this code has been this way basically
forever, I'd sure like to figure out what's different about Shuan and
Lorenzo's system that makes this issue show up now.
> Reported-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Reported-by: Shuan He <heshuan@bytedance.com>
> Closes: https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
>
> Changes in v2:
>
> * Dropped the sysfs change as it is supposed to be replaced by static resources
> change.
v1: https://lore.kernel.org/linux-pci/20250723111124.13694-1-manivannan.sadhasivam@oss.qualcomm.com/
> NOTE: I don't know if there is any reason to call pci_proc_attach_device()
> before pci_bus_add_device(), but it definitely causes a race.
>
> drivers/pci/proc.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index ce36e35681e8..de894ae70e9a 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -463,13 +463,10 @@ int pci_proc_detach_bus(struct pci_bus *bus)
>
> static int __init pci_proc_init(void)
> {
> - struct pci_dev *dev = NULL;
> proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
> proc_create_seq("devices", 0, proc_bus_pci_dir,
> &proc_bus_pci_devices_op);
> proc_initialized = 1;
> - for_each_pci_dev(dev)
> - pci_proc_attach_device(dev);
>
> return 0;
> }
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-03-09 22:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 7:21 [PATCH v2] PCI: Remove redudant call to pci_proc_attach_device() Manivannan Sadhasivam
2026-03-09 22:50 ` Bjorn Helgaas [this message]
2026-05-01 2:08 ` Krzysztof Wilczyński
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260309225018.GA636900@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=heshuan@bytedance.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=lukas@wunner.de \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.