[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51B929AB.3040201@asianux.com>
Date: Thu, 13 Jun 2013 10:08:43 +0800
From: Chen Gang <gang.chen@...anux.com>
To: paulmck@...ux.vnet.ibm.com
CC: Frederic Weisbecker <fweisbec@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Sedat Dilek <sedat.dilek@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel/softirq.c: delete 'while' looping to improve a
little performance and beautify code
On 06/10/2013 08:25 PM, Paul E. McKenney wrote:
> On Sun, Jun 09, 2013 at 08:30:19PM +0800, Chen Gang wrote:
>> >
>> > 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@...anux.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);
> This replaces an atomic test-and-set with two operations, a test and
> a set. Is this safe?
Oh, it seems not safe, at least it is not the original author's willing.
It is my fault, and also sorry for replying late.
Thanks.
--
Chen Gang
Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists