Commit 2e702b9f authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

softirq: use ffs() in __do_softirq()

Possible speed improvement of __do_softirq() by using ffs() instead of
using a while loop with an & 1 test then single bit shift.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a19428e5
...@@ -229,6 +229,7 @@ asmlinkage void __do_softirq(void) ...@@ -229,6 +229,7 @@ asmlinkage void __do_softirq(void)
struct softirq_action *h; struct softirq_action *h;
bool in_hardirq; bool in_hardirq;
__u32 pending; __u32 pending;
int softirq_bit;
int cpu; int cpu;
/* /*
...@@ -253,30 +254,30 @@ asmlinkage void __do_softirq(void) ...@@ -253,30 +254,30 @@ asmlinkage void __do_softirq(void)
h = softirq_vec; h = softirq_vec;
do { while ((softirq_bit = ffs(pending))) {
if (pending & 1) { unsigned int vec_nr;
unsigned int vec_nr = h - softirq_vec; int prev_count;
int prev_count = preempt_count();
h += softirq_bit - 1;
kstat_incr_softirqs_this_cpu(vec_nr);
vec_nr = h - softirq_vec;
trace_softirq_entry(vec_nr); prev_count = preempt_count();
h->action(h);
trace_softirq_exit(vec_nr);
if (unlikely(prev_count != preempt_count())) {
printk(KERN_ERR "huh, entered softirq %u %s %p"
"with preempt_count %08x,"
" exited with %08x?\n", vec_nr,
softirq_to_name[vec_nr], h->action,
prev_count, preempt_count());
preempt_count_set(prev_count);
}
rcu_bh_qs(cpu); kstat_incr_softirqs_this_cpu(vec_nr);
trace_softirq_entry(vec_nr);
h->action(h);
trace_softirq_exit(vec_nr);
if (unlikely(prev_count != preempt_count())) {
printk(KERN_ERR "huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
vec_nr, softirq_to_name[vec_nr], h->action,
prev_count, preempt_count());
preempt_count_set(prev_count);
} }
rcu_bh_qs(cpu);
h++; h++;
pending >>= 1; pending >>= softirq_bit;
} while (pending); }
local_irq_disable(); local_irq_disable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment