All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: weipengliang <weipengliang@xiaomi.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] PCI: Avoid unnecessary cpu_hotplug_disable() for non-NUMA devices
Date: Fri, 22 May 2026 08:32:14 +0000	[thread overview]
Message-ID: <20260522083215.904881F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522075453.473-1-weipengliang@xiaomi.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch removes CPU hotplug protection during PCI device driver probing, exposing drivers to concurrent hotplug races, breaking NUMA locality, and violating CPU isolation.
--

commit d0d4eccba5faab11b523664a86d8feec90710056
Author: weipengliang <weipengliang@xiaomi.com>

PCI: Avoid unnecessary cpu_hotplug_disable() for non-NUMA devices

This commit avoids taking the CPU hotplug lock when probing non-NUMA PCI
devices or VFs being probed from a PF context. It also adjusts the scope of
the hotplug lock in the NUMA path to cover a smaller region around the target
CPU selection and work queueing.

> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index d10ece0889f0f..8a7da7bf24580 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
[ ... ]
> @@ -377,7 +377,6 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>  	node = dev_to_node(&dev->dev);
>  	dev->is_probed = 1;
>  
> -	cpu_hotplug_disable();
>  	/*
>  	 * Prevent nesting work_on_cpu() for the case where a Virtual Function
>  	 * device is probed from work_on_cpu() of the Physical device.
> @@ -385,10 +384,13 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>  	if (node < 0 || node >= MAX_NUMNODES || !node_online(node) ||
>  	    pci_physfn_is_probed(dev)) {
>  		error = local_pci_probe(&ddi);

[Severity: High]
Does bypassing cpu_hotplug_disable() here expose the driver probe path to
concurrent CPU hotplug events?

Historically, cpu_hotplug_disable() wrapped the entirety of PCI probing to
prevent hotplug events from causing race conditions or deadlocks inside
driver probe functions.

> +		dev->is_probed = 0;
> +		return error;
>  	} else {
>  		struct pci_probe_arg arg = { .ddi = &ddi };
>  
>  		INIT_WORK_ONSTACK(&arg.work, local_pci_probe_callback);
> +		cpu_hotplug_disable();
[ ... ]
> @@ -407,10 +409,12 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>  				wq = system_percpu_wq;
>  			queue_work_on(cpu, wq, &arg.work);
>  			rcu_read_unlock();
> +			cpu_hotplug_enable();
>  			flush_work(&arg.work);

[Severity: High]
Does enabling CPU hotplug before flush_work() defeat the protection for the
actual probe execution?

If the targeted CPU goes offline while flush_work() is waiting, the workqueue
core might unbind the worker pool and migrate the pending probe work. Because
unbound workers fall back to cpu_possible_mask, the probe might execute on an
incorrect NUMA node or an isolated CPU, violating the housekeeping_cpumask
constraints evaluated earlier.

>  			error = arg.ret;
>  		} else {
>  			rcu_read_unlock();
> +			cpu_hotplug_enable();
>  			error = local_pci_probe(&ddi);

[Severity: High]
Similar to the workqueue path, does calling local_pci_probe() after
cpu_hotplug_enable() leave the driver initialization unprotected against
concurrent CPU hotplug events?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522075453.473-1-weipengliang@xiaomi.com?part=1

      parent reply	other threads:[~2026-05-22  8:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  6:11 [PATCH] PCI: Avoid unnecessary cpu_hotplug_disable() for non-NUMA devices weipengliang
2026-05-22  7:12 ` Lukas Wunner
2026-05-22  7:54   ` [PATCH v2] " weipengliang
2026-05-22  8:02     ` Lukas Wunner
2026-05-22  8:11       ` weipengliang
2026-05-22  8:22       ` weipengliang
2026-05-22  8:42       ` weipengliang
2026-05-22  8:48         ` [PATCH v3] " weipengliang
2026-05-22  9:56           ` sashiko-bot
2026-05-22 10:53           ` [PATCH v4] " weipengliang
2026-05-22  8:32     ` sashiko-bot [this message]

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=20260522083215.904881F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=weipengliang@xiaomi.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.