Skip to contentSkip to conversation

genirq: Add default affinity mask command line option

PATCH In review Thomas Gleixner 3 participants 5 messages Feb 3, 2016 – Feb 8, 2016

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

PATCH 1/1 genirq: Add default affinity mask command line option

From: Thomas Gleixner <[email protected]>
Date: Fri May 25 16:59:47 2012 +0200
Subject: genirq: Add default affinity mask command line option

If we isolate CPUs, then we don't want random device interrupts on them. Even w/o the user space irq balancer enabled we can end up with irqs on non boot cpus and chasing newly requested interrupts is a tedious task.

Allow to restrict the default irq affinity mask.

---
 Documentation/kernel-parameters.txt |    9 +++++++++
 kernel/irq/irqdesc.c                |   21 +++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +9 -0
@@ -1682,6 +1682,15 @@ bytes respectively. Such letter suffixes
 	ip=		[IP_PNP]
 			See Documentation/filesystems/nfs/nfsroot.txt.
 
+	irqaffinity=	[SMP] Set the default irq affinity mask
+			Format:
+			<cpu number>,...,<cpu number>
+			or
+			<cpu number>-<cpu number>
+			(must be a positive range in ascending order)
+			or a mixture
+			<cpu number>,...,<cpu number>-<cpu number>
+
 	irqfixup	[HW]
 			When an interrupt is not handled search all handlers
 			for it. Intended to get systems with badly broken
kernel/irq/irqdesc.c +19 -2
@@ -24,10 +24,27 @@
 static struct lock_class_key irq_desc_lock_class;
 
 #if defined(CONFIG_SMP)
+static int __init irq_affinity_setup(char *str)
+{
+	zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+	cpulist_parse(str, irq_default_affinity);
+	/*
+	 * Set at least the boot cpu. We don't want to end up with
+	 * bugreports caused by random comandline masks
+	 */
+	cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
+	return 1;
+}
+__setup("irqaffinity=", irq_affinity_setup);
+
 static void __init init_irq_default_affinity(void)
 {
-	alloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
-	cpumask_setall(irq_default_affinity);
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!irq_default_affinity)
+		zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+#endif
+	if (cpumask_empty(irq_default_affinity))
+		cpumask_setall(irq_default_affinity);
 }
 #else
 static void __init init_irq_default_affinity(void)
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 8 lines · Thomas Gleixner

From: Thomas Gleixner <[email protected]> Date: Fri May 25 16:59:47 2012 +0200 Subject: genirq: Add default affinity mask command line option

If we isolate CPUs, then we don't want random device interrupts on them. Even w/o the user space irq balancer enabled we can end up with irqs on non boot cpus and chasing newly requested interrupts is a tedious task.

The userspace irqbalance daemon has code nowadays to prevent it from putting irqs on isolated CPUs.

Quoted 1 line

Allow to restrict the default irq affinity mask.

However, not placing them on there at boot time is a great enhancement, too.

Quoted 17 lines

--- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -24,10 +24,27 @@ static struct lock_class_key irq_desc_lock_class;

#if defined(CONFIG_SMP) +static int __init irq_affinity_setup(char
*str) +{ + zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT); +
cpulist_parse(str, irq_default_affinity); + /* + * Set at least
the boot cpu. We don't want to end up with + * bugreports caused
by random comandline masks + */ +
cpumask_set_cpu(smp_processor_id(), irq_default_affinity); + return
1; +} +__setup("irqaffinity=", irq_affinity_setup); + static void __init init_irq_default_affinity(void) { - alloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT); - cpumask_setall(irq_default_affinity); +#ifdef
CONFIG_CPUMASK_OFFSTACK + if (!irq_default_affinity) +
zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT); +#endif + if
(cpumask_empty(irq_default_affinity)) + cpumask_setall(irq_default_affinity); }

Would it make sense to key off the isolated_cpus mask if isolated_cpus= was specified, but no irqaffinity mask was specified?

Is there any use case where we would want irqs on isolated cpus by default, and could not bear the cost of reassigning them from userspace after boot?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWslEWAAoJEM553pKExN6Dju0IAKDxqU2zS3rcC5jGfogfN9Q7 4XFOksNJ2VLfpDR/tSw6LTIkrDyl4BvhWv0WXcathfl3yVh1TEPsSWLUi1/ctL8U SbxK1+zZvja9UXjPL/KDoJLeaQTd9C8nA+lhP+UUkR/A3g23WezFcJVB+a8CYaqg pBQ4G1pz2xSfzraRe9HzzIb076QuieVUDllc+rdVxjBQRhmTBJ40MIxspTdRpNCY wx7PadVP5UiY/gPX7Q+KrQNlybBs3x0dq4DenaOmpULeBa1sdpgeRJX8K01OcXgE 1wcKk8RYmzgw2SPNvkO97Gyl8Acj24+ceHerzMmV2aUiWS98LU3faISQgB2ZUwg= =+ZYl
-----END PGP SIGNATURE-----

#2 lore raw
Quoted 5 lines · Rik van Riel
Quoted 4 lines · Thomas Gleixner

From: Thomas Gleixner <[email protected]> Date: Fri May 25 16:59:47 2012 +0200 Subject: genirq: Add default affinity mask command line option

Quoted 7 lines
Quoted 4 lines

If we isolate CPUs, then we don't want random device interrupts on them. Even w/o the user space irq balancer enabled we can end up with irqs on non boot cpus and chasing newly requested interrupts is a tedious task.

The userspace irqbalance daemon has code nowadays to prevent it from putting irqs on isolated CPUs.

I know, but a lot of systems do not enable it at all.

Quoted 4 lines
Quoted 1 line

Allow to restrict the default irq affinity mask.

However, not placing them on there at boot time is a great enhancement, too.

That's the main plan :)

Quoted 3 lines

Would it make sense to key off the isolated_cpus mask if isolated_cpus= was specified, but no irqaffinity mask was specified?

That might be an add on.

Quoted 3 lines

Is there any use case where we would want irqs on isolated cpus by default, and could not bear the cost of reassigning them from userspace after boot?

I don't think so. Those interrupts you want on an isolated cpu are obviously hand selected.

Thanks,

tglx

#3 lore raw
In reply to Thomas Gleixner
genirq: Add default affinity mask command line option
Commit-ID:  35fdd6e4bf0868ed9b1d8662fc9fca766d6963d1
Gitweb:     http://git.kernel.org/tip/35fdd6e4bf0868ed9b1d8662fc9fca766d6963d1
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Wed, 3 Feb 2016 19:52:23 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 8 Feb 2016 11:45:22 +0100

genirq: Add default affinity mask command line option

If we isolate CPUs, then we don't want random device interrupts on them. Even w/o the user space irq balancer enabled we can end up with irqs on non boot cpus and chasing newly requested interrupts is a tedious task.

Allow to restrict the default irq affinity mask.

---
 Documentation/kernel-parameters.txt |  9 +++++++++
 kernel/irq/irqdesc.c                | 21 +++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +9 -0
index 551ecf0..87298f8 100644
@@ -1687,6 +1687,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	ip=		[IP_PNP]
 			See Documentation/filesystems/nfs/nfsroot.txt.
 
+	irqaffinity=	[SMP] Set the default irq affinity mask
+			Format:
+			<cpu number>,...,<cpu number>
+			or
+			<cpu number>-<cpu number>
+			(must be a positive range in ascending order)
+			or a mixture
+			<cpu number>,...,<cpu number>-<cpu number>
+
 	irqfixup	[HW]
 			When an interrupt is not handled search all handlers
 			for it. Intended to get systems with badly broken
kernel/irq/irqdesc.c +19 -2
index 0409da0..0ccd028 100644
@@ -24,10 +24,27 @@
 static struct lock_class_key irq_desc_lock_class;
 
 #if defined(CONFIG_SMP)
+static int __init irq_affinity_setup(char *str)
+{
+	zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+	cpulist_parse(str, irq_default_affinity);
+	/*
+	 * Set at least the boot cpu. We don't want to end up with
+	 * bugreports caused by random comandline masks
+	 */
+	cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
+	return 1;
+}
+__setup("irqaffinity=", irq_affinity_setup);
+
 static void __init init_irq_default_affinity(void)
 {
-	alloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
-	cpumask_setall(irq_default_affinity);
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!irq_default_affinity)
+		zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+#endif
+	if (cpumask_empty(irq_default_affinity))
+		cpumask_setall(irq_default_affinity);
 }
 #else
 static void __init init_irq_default_affinity(void)
#4 lore raw
In reply to Thomas Gleixner
genirq: Add default affinity mask command line option
Commit-ID:  fbf198030e0b027538c290300cfaf9e2efdce122
Gitweb:     http://git.kernel.org/tip/fbf198030e0b027538c290300cfaf9e2efdce122
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Wed, 3 Feb 2016 19:52:23 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 8 Feb 2016 15:03:42 +0100

genirq: Add default affinity mask command line option

If we isolate CPUs, then we don't want random device interrupts on them. Even w/o the user space irq balancer enabled we can end up with irqs on non boot cpus and chasing newly requested interrupts is a tedious task.

Allow to restrict the default irq affinity mask.

---
 Documentation/kernel-parameters.txt |  9 +++++++++
 kernel/irq/irqdesc.c                | 21 +++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +9 -0
index 551ecf0..87298f8 100644
@@ -1687,6 +1687,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 	ip=		[IP_PNP]
 			See Documentation/filesystems/nfs/nfsroot.txt.
 
+	irqaffinity=	[SMP] Set the default irq affinity mask
+			Format:
+			<cpu number>,...,<cpu number>
+			or
+			<cpu number>-<cpu number>
+			(must be a positive range in ascending order)
+			or a mixture
+			<cpu number>,...,<cpu number>-<cpu number>
+
 	irqfixup	[HW]
 			When an interrupt is not handled search all handlers
 			for it. Intended to get systems with badly broken
kernel/irq/irqdesc.c +19 -2
index 0409da0..0ccd028 100644
@@ -24,10 +24,27 @@
 static struct lock_class_key irq_desc_lock_class;
 
 #if defined(CONFIG_SMP)
+static int __init irq_affinity_setup(char *str)
+{
+	zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+	cpulist_parse(str, irq_default_affinity);
+	/*
+	 * Set at least the boot cpu. We don't want to end up with
+	 * bugreports caused by random comandline masks
+	 */
+	cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
+	return 1;
+}
+__setup("irqaffinity=", irq_affinity_setup);
+
 static void __init init_irq_default_affinity(void)
 {
-	alloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
-	cpumask_setall(irq_default_affinity);
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!irq_default_affinity)
+		zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT);
+#endif
+	if (cpumask_empty(irq_default_affinity))
+		cpumask_setall(irq_default_affinity);
 }
 #else
 static void __init init_irq_default_affinity(void)