]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI: Flush PCI probe workqueue on cpuset isolated partition change
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 30 Sep 2025 13:21:33 +0000 (15:21 +0200)
committerFrederic Weisbecker <frederic@kernel.org>
Tue, 3 Feb 2026 14:23:34 +0000 (15:23 +0100)
The HK_TYPE_DOMAIN housekeeping cpumask is now modifiable at runtime. In
order to synchronize against PCI probe works and make sure that no
asynchronous probing is still pending or executing on a newly isolated
CPU, the housekeeping subsystem must flush the PCI probe works.

However the PCI probe works can't be flushed easily since they are
queued to the main per-CPU workqueue pool.

Solve this with creating a PCI probe-specific pool and provide and use
the appropriate flushing API.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Marco Crivellari <marco.crivellari@suse.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Waiman Long <longman@redhat.com>
Cc: linux-pci@vger.kernel.org
drivers/pci/pci-driver.c
include/linux/pci.h
kernel/sched/isolation.c

index a6111140755c7f85bc1774dd0e35079ef769bc9c..b902d8adf9a584d85c337db2e6ee9d1818b46076 100644 (file)
@@ -337,6 +337,8 @@ static int local_pci_probe(struct drv_dev_and_id *ddi)
        return 0;
 }
 
+static struct workqueue_struct *pci_probe_wq;
+
 struct pci_probe_arg {
        struct drv_dev_and_id *ddi;
        struct work_struct work;
@@ -407,7 +409,11 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
                cpu = cpumask_any_and(cpumask_of_node(node),
                                      wq_domain_mask);
                if (cpu < nr_cpu_ids) {
-                       schedule_work_on(cpu, &arg.work);
+                       struct workqueue_struct *wq = pci_probe_wq;
+
+                       if (WARN_ON_ONCE(!wq))
+                               wq = system_percpu_wq;
+                       queue_work_on(cpu, wq, &arg.work);
                        rcu_read_unlock();
                        flush_work(&arg.work);
                        error = arg.ret;
@@ -425,6 +431,11 @@ out:
        return error;
 }
 
+void pci_probe_flush_workqueue(void)
+{
+       flush_workqueue(pci_probe_wq);
+}
+
 /**
  * __pci_device_probe - check if a driver wants to claim a specific PCI device
  * @drv: driver to call to check if it wants the PCI device
@@ -1762,6 +1773,10 @@ static int __init pci_driver_init(void)
 {
        int ret;
 
+       pci_probe_wq = alloc_workqueue("sync_wq", WQ_PERCPU, 0);
+       if (!pci_probe_wq)
+               return -ENOMEM;
+
        ret = bus_register(&pci_bus_type);
        if (ret)
                return ret;
index 864775651c6fae125972cdfb062fd4d684cf294c..f14f467e50deb4b3e385b19dddb5ac8c0fff48c4 100644 (file)
@@ -1206,6 +1206,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
                                    struct pci_ops *ops, void *sysdata,
                                    struct list_head *resources);
 int pci_host_probe(struct pci_host_bridge *bridge);
+void pci_probe_flush_workqueue(void);
 int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
 int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
 void pci_bus_release_busn_res(struct pci_bus *b);
@@ -2079,6 +2080,8 @@ static inline int pci_has_flag(int flag) { return 0; }
 _PCI_NOP_ALL(read, *)
 _PCI_NOP_ALL(write,)
 
+static inline void pci_probe_flush_workqueue(void) { }
+
 static inline struct pci_dev *pci_get_device(unsigned int vendor,
                                             unsigned int device,
                                             struct pci_dev *from)
index 160b3fcab209fec1852bc3f6662bbf20a70e396f..1e4c3154b0a4c6b716d4a77c820014d44df82653 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 #include <linux/sched/isolation.h>
+#include <linux/pci.h>
 #include "sched.h"
 
 enum hk_flags {
@@ -144,6 +145,7 @@ int housekeeping_update(struct cpumask *isol_mask)
 
        synchronize_rcu();
 
+       pci_probe_flush_workqueue();
        mem_cgroup_flush_workqueue();
        vmstat_flush_workqueue();