diff options
author | Joe Perches <joe@perches.com> | 2014-01-27 20:07:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 00:02:40 -0500 |
commit | 2e702b9f6cba4eb87d90e2a2d425a1fc05eec803 (patch) | |
tree | ade4a3bcec477ced2780f1841e7c06f547effe84 /kernel/softirq.c | |
parent | a19428e5c3f4f39c302cb97b847dfd23613145c1 (diff) |
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: Joe 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/softirq.c')
-rw-r--r-- | kernel/softirq.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/kernel/softirq.c b/kernel/softirq.c index 8a1e6e104892..ba79bbfe380e 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c | |||
@@ -229,6 +229,7 @@ asmlinkage void __do_softirq(void) | |||
229 | struct softirq_action *h; | 229 | struct softirq_action *h; |
230 | bool in_hardirq; | 230 | bool in_hardirq; |
231 | __u32 pending; | 231 | __u32 pending; |
232 | int softirq_bit; | ||
232 | int cpu; | 233 | int cpu; |
233 | 234 | ||
234 | /* | 235 | /* |
@@ -253,30 +254,30 @@ restart: | |||
253 | 254 | ||
254 | h = softirq_vec; | 255 | h = softirq_vec; |
255 | 256 | ||
256 | do { | 257 | while ((softirq_bit = ffs(pending))) { |
257 | if (pending & 1) { | 258 | unsigned int vec_nr; |
258 | unsigned int vec_nr = h - softirq_vec; | 259 | int prev_count; |
259 | int prev_count = preempt_count(); | 260 | |
260 | 261 | h += softirq_bit - 1; | |
261 | kstat_incr_softirqs_this_cpu(vec_nr); | 262 | |
262 | 263 | vec_nr = h - softirq_vec; | |
263 | trace_softirq_entry(vec_nr); | 264 | prev_count = preempt_count(); |
264 | h->action(h); | ||
265 | trace_softirq_exit(vec_nr); | ||
266 | if (unlikely(prev_count != preempt_count())) { | ||
267 | printk(KERN_ERR "huh, entered softirq %u %s %p" | ||
268 | "with preempt_count %08x," | ||
269 | " exited with %08x?\n", vec_nr, | ||
270 | softirq_to_name[vec_nr], h->action, | ||
271 | prev_count, preempt_count()); | ||
272 | preempt_count_set(prev_count); | ||
273 | } | ||
274 | 265 | ||
275 | rcu_bh_qs(cpu); | 266 | kstat_incr_softirqs_this_cpu(vec_nr); |
267 | |||
268 | trace_softirq_entry(vec_nr); | ||
269 | h->action(h); | ||
270 | trace_softirq_exit(vec_nr); | ||
271 | if (unlikely(prev_count != preempt_count())) { | ||
272 | printk(KERN_ERR "huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n", | ||
273 | vec_nr, softirq_to_name[vec_nr], h->action, | ||
274 | prev_count, preempt_count()); | ||
275 | preempt_count_set(prev_count); | ||
276 | } | 276 | } |
277 | rcu_bh_qs(cpu); | ||
277 | h++; | 278 | h++; |
278 | pending >>= 1; | 279 | pending >>= softirq_bit; |
279 | } while (pending); | 280 | } |
280 | 281 | ||
281 | local_irq_disable(); | 282 | local_irq_disable(); |
282 | 283 | ||