From: sashiko-bot@kernel.org
To: "Waiman Long" <longman@redhat.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH RESEND v4 2/2] PCI: Call local_pci_probe() directly in pci_call_probe() if affined to the right node
Date: Wed, 02 Dec 2026 19:15:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-246537@kernel.org> (raw)
In-Reply-To: <20261202190007.1852337-3-longman@redhat.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] PCI: cpumask_subset() in pci_call_probe() misses unbound
async_wq workers
- [Medium] PCI: affine_to_node check in pci_call_probe() bypasses
HK_TYPE_DOMAIN
- [Low] PCI: pci_call_probe() checks node state and affinity before
disabling hotplug
--
commit 9f7bc4a2d73c970ab760b19214b180be397319cb
Author: Waiman Long <longman@redhat.com>
PCI: Call local_pci_probe() directly in pci_call_probe() if affined to the right node
This commit modifies pci_call_probe() to invoke local_pci_probe() directly
instead of queueing work when current->cpus_ptr is a subset of the target
NUMA node's cpumask.
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 57c52dd292ea6..13f4312e74f7d 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -398,6 +398,8 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
> {
> int error, node, cpu;
> struct drv_dev_and_id ddi = { drv, dev, id };
> + bool node_invalid, affine_to_node;
> + const struct cpumask *node_cpus;
>
> /*
> * Execute driver initialization on node where the device is
> @@ -406,14 +408,24 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
> */
> node = dev_to_node(&dev->dev);
> dev->is_probed = 1;
> + node_invalid = node < 0 || node >= MAX_NUMNODES || !node_online(node);
> +
> + if (node_invalid) {
> + node_cpus = cpu_online_mask;
> + affine_to_node = false;
> + } else {
> + node_cpus = cpumask_of_node(node);
> + /* Check if the current task is affined to the right node */
> + affine_to_node = cpumask_subset(current->cpus_ptr, node_cpus);
> + }
[Severity: Medium]
Does cpumask_subset(current->cpus_ptr, node_cpus) ever match workers from
async_schedule_dev() on multi-node NUMA systems?
async_schedule_dev() queues work onto async_wq, which is allocated with
WQ_UNBOUND and default non-strict affinity (affn_strict == false):
kernel/workqueue.c:pool_allowed_cpus() {
if (!is_percpu_pool(pool) && pool->attrs->affn_strict)
return pool->attrs->__pod_cpumask;
else
return pool->attrs->cpumask;
}
create_worker() binds unbound workers to pool_allowed_cpus(pool), so an
async_wq worker's current->cpus_ptr spans wq_unbound_cpumask across all
NUMA nodes rather than a single node. On multi-node systems,
affine_to_node is always false for async_wq workers, so they still allocate
a dynamic lockdep key and serialize probing via queue_work_on() on
pci_probe_wq.
>
> cpu_hotplug_disable();
[Severity: Low]
Can evaluating node_online(node), cpumask_of_node(node), and
cpumask_subset(current->cpus_ptr, node_cpus) before cpu_hotplug_disable()
race with CPU hotplug?
If the CPUs in current->cpus_ptr are taken offline before
cpu_hotplug_disable() is reached, current's affinity is broken and the task
is migrated to another node, while pci_call_probe() proceeds with the stale
affine_to_node == true result and runs local_pci_probe() on the wrong NUMA
node.
> /*
> - * Prevent nesting work_on_cpu() for the case where a Virtual Function
> - * device is probed from work_on_cpu() of the Physical device.
> + * Prevent nesting queue_work_on() for the case where a Virtual Function
> + * device is probed from queue_work_on() of the Physical function or
> + * when the current task is affined to the right node.
> */
> - if (node < 0 || node >= MAX_NUMNODES || !node_online(node) ||
> - pci_physfn_is_probed(dev)) {
> + if (node_invalid || affine_to_node || pci_physfn_is_probed(dev)) {
> error = local_pci_probe(&ddi);
> } else {
[Severity: Medium]
Can the affine_to_node fast path run local_pci_probe() on domain-isolated
CPUs and bypass housekeeping_update() synchronization?
node_cpus is cpumask_of_node(node), which includes isolated CPUs excluded
from housekeeping_cpumask(HK_TYPE_DOMAIN). When current->cpus_ptr is a
subset of cpumask_of_node(node) (for example, a task with default affinity
on a single-node system or a task affined to a node that contains isolated
CPUs), affine_to_node is true even if current->cpus_ptr includes isolated
CPUs. Calling local_pci_probe() directly here skips the RCU-protected
housekeeping_cpumask(HK_TYPE_DOMAIN) check and pci_probe_wq execution that
608fedd2f303 ("PCI: Prepare to protect against concurrent isolated cpuset
change") and 29b306c44eb5 ("PCI: Flush PCI probe workqueue on cpuset
isolated partition change") rely on when flushing in-flight probes during
cpuset isolation updates.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202190007.1852337-1-longman@redhat.com?part=2
next prev parent reply other threads:[~2026-12-02 19:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 19:00 [PATCH RESEND v4 0/2] PCI: Suppress lockdep warning & make pci_call_probe() more efficient Waiman Long
2026-12-02 19:00 ` [PATCH RESEND v4 1/2] PCI: Suppress false positive lockdep warning in pci_call_probe() Waiman Long
2026-12-02 19:00 ` [PATCH RESEND v4 2/2] PCI: Call local_pci_probe() directly in pci_call_probe() if affined to the right node Waiman Long
2026-12-02 19:15 ` sashiko-bot [this message]
2026-12-02 19:15 ` [PATCH RESEND v4 0/2] PCI: Suppress lockdep warning & make pci_call_probe() more efficient sashiko-bot
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=sashiko-outbox-246537@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=longman@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox