lkml.org 
[lkml]   [2013]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] kernel/softirq.c: delete 'while' looping to improve a little performance and beautify code

After finish the internal 'while', need not test TASKLET_STATE_SCHED
again, so looping back to outside 'while' is only for set_bit().

When use 'if' and set_bit() instead of 'while', it will save at least
one running conditional instruction, and also will be clearer for readers
(although the binary size will be a little bigger).

The related patch is "1da177e Linux-2.6.12-rc2"


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
kernel/softirq.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index a5f8836..52da25f 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -540,10 +540,11 @@ void tasklet_kill(struct tasklet_struct *t)
if (in_interrupt())
printk("Attempt to kill tasklet from interrupt\n");

- while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
+ if (test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
do {
yield();
} while (test_bit(TASKLET_STATE_SCHED, &t->state));
+ set_bit(TASKLET_STATE_SCHED, &t->state);
}
tasklet_unlock_wait(t);
clear_bit(TASKLET_STATE_SCHED, &t->state);
--
1.7.7.6

\
 
 \ /
  Last update: 2013-06-09 14:41    [W:0.056 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site