Expose default irq affinity mask
Subsystems (2)
PATCH 1/1 Expose default irq affinity mask
Current IRQ affinity interface does not provide a way to set affinity for the IRQs that will be allocated/activated in the future. This patch creates /proc/irq/default_smp_affinity that lets users set default affinity mask for the newly allocated IRQs. Changing default does not affect affinity masks for the currently active IRQs, they have to be changed explicitly.
--- arch/alpha/kernel/irq.c | 5 +-- include/linux/irq.h | 14 ++++------- kernel/irq/manage.c | 28 +++++++++++++++++++++- kernel/irq/proc.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 15 deletions(-)
arch/alpha/kernel/irq.c +2 -3
@@ -42,8 +42,7 @@ void ack_bad_irq(unsigned int irq)#ifdef CONFIG_SMP static char irq_user_affinity[NR_IRQS ]; -int -select_smp_affinity (unsigned int irq) +int irq_select_affinity (unsigned int irq) {static int last_cpu;int cpu = last_cpu +1 ;
@@ -51,7 +50,7 @@ select_smp_affinity(unsigned int irq)if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])return 1 ; -while (!cpu_possible (cpu)) +while (!cpu_possible (cpu) || !cpu_isset (cpu, irq_default_affinity)) cpu = (cpu < (NR_CPUS -1 ) ? cpu +1 :0 ); last_cpu = cpu;
include/linux/irq.h +5 -9
@@ -228,8 +228,11 @@ static inline void set_pending_irq(unsigned int irq, cpumask_t mask)#endif /* CONFIG_GENERIC_PENDING_IRQ */ +extern cpumask_t irq_default_affinity; +extern int irq_set_affinity (unsigned int irq,cpumask_t cpumask);extern int irq_can_set_affinity (unsigned int irq); +extern int irq_select_affinity (unsigned int irq);#else /* CONFIG_SMP */
@@ -243,6 +246,8 @@ static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)static inline int irq_can_set_affinity (unsigned int irq) {return 0 ; } +static inline int irq_select_affinity (unsigned int irq) {return 0 ; } +#endif /* CONFIG_SMP */ #ifdef CONFIG_IRQBALANCE
@@ -253,15 +258,6 @@ static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) }#endif -#ifdef CONFIG_AUTO_IRQ_AFFINITY -extern int select_smp_affinity (unsigned int irq); -#else -static inline int select_smp_affinity (unsigned int irq) -{ -return 1 ; -} -#endif -extern int no_irq_affinity;static inline int irq_balancing_disabled (unsigned int irq)
kernel/irq/manage.c +26 -2
@@ -16,6 +16,8 @@#ifdef CONFIG_SMP +cpumask_t irq_default_affinity =CPU_MASK_ALL ; +/** * synchronize_irq - wait for pending IRQ handlers (on other CPUs) * @irq: interrupt number to wait for
@@ -94,6 +96,27 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask) return 0; } +#ifndef CONFIG_AUTO_IRQ_AFFINITY +/** +* Generic version of the affinity autoselector. +*/ +int irq_select_affinity (unsigned int irq) +{ +cpumask_t mask; + +if (!irq_can_set_affinity (irq)) +return 0 ; + +cpus_and (mask, cpu_online_map, irq_default_affinity); + + irq_desc[irq].affinity = mask; + irq_desc[irq].chip->set_affinity (irq, mask); + +set_balance_irq_affinity (irq, mask); +return 0 ; +} +#endif +#endif /**
@@ -376,6 +399,9 @@ int setup_irq(unsigned int irq, struct irqaction *new) }else /* Undo nested disables: */ desc->depth =1 ; + +/* Set default affinity mask once everything is setup */ +irq_select_affinity (irq); }/* Reset broken irq detection when installing new handler */ desc->irq_count =0 ;
@@ -555,8 +581,6 @@ int request_irq(unsigned int irq, irq_handler_t handler, action->next =NULL ; action->dev_id = dev_id; -select_smp_affinity (irq); -#ifdef CONFIG_DEBUG_SHIRQ if (irqflags &IRQF_SHARED ) {/*
kernel/irq/proc.c +56 -1
81 lines not on this page · raw message
Signature · 1 line
1.5.4.5
Quoted 6 lines · On Fri, 23 May 2008 12:46:35 -0700 Max Krasnyansky wrote:
Current IRQ affinity interface does not provide a way to set affinity for the IRQs that will be allocated/activated in the future. This patch creates
/proc/irq/default_smp_affinitythat lets users set default affinity mask for the newly allocated IRQs. Changing default does not affect affinity masks for the currently active IRQs, they have to be changed explicitly.
Documentation, perhaps an update to Documentation/filesystems/proc.txt ?
Quoted 22 lines
Signed-off-by Max Krasnyansky <[email protected]>--- arch/alpha/kernel/irq.c | 5 +-- include/linux/irq.h | 14 ++++------- kernel/irq/manage.c | 28 +++++++++++++++++++++- kernel/irq/proc.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 15 deletions(-)kernel/irq/manage.c +2
-0@@ -16,6 +16,8 @@#ifdef CONFIG_SMP +cpumask_t irq_default_affinity =CPU_MASK_ALL ; +/** * synchronize_irq - wait for pending IRQ handlers (on other CPUs) * @irq: interrupt number to wait for
kernel/irq/manage.c int irq_set_affinity(unsigned int irq, cpumask_t cpumask) · line 102
Quoted 7 lines
kernel/irq/manage.c +4
-0@@ -94,6 +96,27 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask)return 0 ; } +#ifndef CONFIG_AUTO_IRQ_AFFINITY +/** +* Generic version of the affinity autoselector. +*/
Please don't use /** as the beginning of a comment block unless that comment block is in kernel-doc format (this one is not).
Quoted 6 lines
kernel/irq/manage.c +6
-0+int irq_select_affinity (unsigned int irq) +{ +cpumask_t mask; + +if (!irq_can_set_affinity (irq)) +return 0 ;
kernel/irq/manage.c int irq_set_affinity(unsigned int irq, cpumask_t cpumask) · line 118
Quoted 10 lines
kernel/irq/manage.c +10
-0+ +cpus_and (mask, cpu_online_map, irq_default_affinity); + + irq_desc[irq].affinity = mask; + irq_desc[irq].chip->set_affinity (irq, mask); + +set_balance_irq_affinity (irq, mask); + return 0; +} +#endif
---
~Randy
Quoted 10 lines · Randy Dunlap
Quoted 6 lines · On Fri, 23 May 2008 12:46:35 -0700 Max Krasnyansky wrote:
Current IRQ affinity interface does not provide a way to set affinity for the IRQs that will be allocated/activated in the future. This patch creates
/proc/irq/default_smp_affinitythat lets users set default affinity mask for the newly allocated IRQs. Changing default does not affect affinity masks for the currently active IRQs, they have to be changed explicitly.Documentation, perhaps an update to
Documentation/filesystems/proc.txt?
Absolutely. I wanted to see if it gets accepted first.
Quoted 26 lines
Quoted 26 lines
Signed-off-by Max Krasnyansky <[email protected]>--- arch/alpha/kernel/irq.c | 5 +-- include/linux/irq.h | 14 ++++------- kernel/irq/manage.c | 28 +++++++++++++++++++++- kernel/irq/proc.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 15 deletions(-)kernel/irq/manage.c +2
-0@@ -16,6 +16,8 @@#ifdef CONFIG_SMP +cpumask_t irq_default_affinity =CPU_MASK_ALL ; +/** * synchronize_irq - wait for pending IRQ handlers (on other CPUs) * @irq: interrupt number to wait for @@ -94,6 +96,27 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask)return 0 ; }
Quoted 7 lines
kernel/irq/manage.c int irq_set_affinity(unsigned int irq, cpumask_t cpumask) · line 102
Quoted 4 lines
kernel/irq/manage.c +4
-0+#ifndef CONFIG_AUTO_IRQ_AFFINITY +/** +* Generic version of the affinity autoselector. +*/ Please don't use /** as the beginning of a comment block unless that comment block is in kernel-doc format (this one is not).
Oops, my bad. Did it again. Will fix.
Max
Max, replying to Randy:
Quoted 2 lines
Quoted 1 line
Documentation, perhaps an update to
Documentation/filesystems/proc.txt?Absolutely. I wanted to see if it gets accepted first.
For new features such as this, documentation is helpful in reviewing.
(For me at least, documentation is even helpful in -writing- the code, as I find that if I can't explain something in words clearly and accurately, then my code is probably confused as well. However, I'm obviously weird, and not just in this regard.)
Quoted 1 line
From what I can tell, it's ok. I look forward to seeing the Documentation,
and will review it again at that time.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214Quoted 6 lines · Paul Jackson
Max, replying to Randy:
Quoted 2 lines
Quoted 1 line
Documentation, perhaps an update to
Documentation/filesystems/proc.txt?Absolutely. I wanted to see if it gets accepted first.
For new features such as this, documentation is helpful in reviewing.
Quoted 8 lines
(For me at least, documentation is even helpful in -writing- the code, as I find that if I can't explain something in words clearly and accurately, then my code is probably confused as well. However, I'm obviously weird, and not just in this regard.)
Quoted 1 line
From what I can tell, it's ok. I look forward to seeing the Documentation,
and will review it again at that time.
There is not going to be whole a lot of documentation for this. Basically the commit comment is what will be in the documentation. In other words I do not think it'll help you with the review.
Max
Quoted 1 line
In other words I do not think it'll help you with the review.
I really do prefer to encourage people to include the Doc changes in their submitted patches. It does make it easier to review, and the Doc changes are part of what needs to be reviewed.
I will do my best to complete my review, and I will most likely ack this patch, once it is complete.
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214