Skip to contentSkip to conversation

genirq: Make sure the affinity to be set is not empty

PATCH In review Srinivas Ramana 2 participants 3 messages Dec 20, 2018 – Jan 15, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genirq: Make sure the affinity to be set is not empty

If the default_affinity is managed/initialized by a system and all the cpus present in irq_default_affinity are hotplugged out we may end up passing a cpumask of 0 to irq_do_set_affinity().

Fix this by falling back to cpu_online_mask in case the calculated affinity becomes zero.

---
 kernel/irq/manage.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/irq/manage.c +3 -0
index 9dbdccab3b6a..5c0ba5ca5930 100644
@@ -393,6 +393,9 @@ int irq_setup_affinity(struct irq_desc *desc)
 	}
 
 	cpumask_and(&mask, cpu_online_mask, set);
+	if (cpumask_empty(&mask))
+		cpumask_copy(&mask, cpu_online_mask);
+
 	if (node != NUMA_NO_NODE) {
 		const struct cpumask *nodemask = cpumask_of_node(node);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., 
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#1 lore raw
Quoted 18 lines · Srinivas Ramana

If the default_affinity is managed/initialized by a system and all the cpus present in irq_default_affinity are hotplugged out we may end up passing a cpumask of 0 to irq_do_set_affinity().

Fix this by falling back to cpu_online_mask in case the calculated affinity becomes zero.

---
  kernel/irq/manage.c | 3 +++
  1 file changed, 3 insertions(+)
kernel/irq/manage.c +0 -0
index 9dbdccab3b6a..5c0ba5ca5930 100644

kernel/irq/manage.c int irq_setup_affinity(struct irq_desc *desc) · line 401

Quoted 9 lines
kernel/irq/manage.c +3 -0
@@ -393,6 +393,9 @@ int irq_setup_affinity(struct irq_desc *desc)
  	}
 
  	cpumask_and(&mask, cpu_online_mask, set);
+	if (cpumask_empty(&mask))
+		cpumask_copy(&mask, cpu_online_mask);
+
  	if (node != NUMA_NO_NODE) {
  		const struct cpumask *nodemask = cpumask_of_node(node);
 

Hi,

Can you provide your feedback on this?

Thanks,
-- Srinivas R

Signature · 3 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation
Center, Inc., is a member of Code Aurora Forum, a Linux Foundation
Collaborative Project
#2 lore raw

[tip:irq/urgent] genirq: Make sure the initial affinity is not empty

In reply to Srinivas Ramana
genirq: Make sure the initial affinity is not empty
Commit-ID:  bddda606ec76550dd63592e32a6e87e7d32583f7
Gitweb:     https://git.kernel.org/tip/bddda606ec76550dd63592e32a6e87e7d32583f7
Author:     Srinivas Ramana <[email protected]>
AuthorDate: Thu, 20 Dec 2018 19:05:57 +0530
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 15 Jan 2019 11:23:27 +0100

genirq: Make sure the initial affinity is not empty

If all CPUs in the irq_default_affinity mask are offline when an interrupt is initialized then irq_setup_affinity() can set an empty affinity mask for a newly allocated interrupt.

Fix this by falling back to cpu_online_mask in case the resulting affinity mask is zero.

---
 kernel/irq/manage.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/irq/manage.c +3 -0
index a4888ce4667a..84b54a17b95d 100644
@@ -393,6 +393,9 @@ int irq_setup_affinity(struct irq_desc *desc)
 	}
 
 	cpumask_and(&mask, cpu_online_mask, set);
+	if (cpumask_empty(&mask))
+		cpumask_copy(&mask, cpu_online_mask);
+
 	if (node != NUMA_NO_NODE) {
 		const struct cpumask *nodemask = cpumask_of_node(node);