As HK_TYPE_MANAGED_IRQ cpumask is going to be changeable at run time,
use RCU to protect access to the cpumask.

To enable the new HK_TYPE_MANAGED_IRQ cpumask to take effect, the
following steps can be done.

 1) Update the HK_TYPE_MANAGED_IRQ cpumask to take out the newly isolated
    CPUs and add back the de-isolated CPUs.
 2) Tear down the affected CPUs to cause irq_migrate_all_off_this_cpu()
    to be called on the affected CPUs to migrate the irqs to other
    HK_TYPE_MANAGED_IRQ housekeeping CPUs.
 3) Bring up the previously offline CPUs to invoke
    irq_affinity_online_cpu() to allow the newly de-isolated CPUs to
    be used for managed irqs.

Signed-off-by: Waiman Long <[email protected]>
---
 kernel/irq/cpuhotplug.c | 1 +
 kernel/irq/manage.c     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
index cd5689e383b0..86437c78f1f2 100644
--- a/kernel/irq/cpuhotplug.c
+++ b/kernel/irq/cpuhotplug.c
@@ -196,6 +196,7 @@ static bool hk_should_isolate(struct irq_data *data, 
unsigned int cpu)
        if (!housekeeping_enabled(HK_TYPE_MANAGED_IRQ))
                return false;
 
+       guard(rcu)();
        hk_mask = housekeeping_cpumask(HK_TYPE_MANAGED_IRQ);
        if (cpumask_subset(irq_data_get_effective_affinity_mask(data), hk_mask))
                return false;
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 2e8072437826..8270c4de260b 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -263,6 +263,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct 
cpumask *mask, bool
            housekeeping_enabled(HK_TYPE_MANAGED_IRQ)) {
                const struct cpumask *hk_mask;
 
+               guard(rcu)();
                hk_mask = housekeeping_cpumask(HK_TYPE_MANAGED_IRQ);
 
                cpumask_and(tmp_mask, mask, hk_mask);
-- 
2.53.0


Reply via email to