[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m1r62ew5ug.fsf@fess.ebiederm.org>
Date: Wed, 04 Feb 2009 07:59:35 -0800
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Rusty Russell <rusty@...tcorp.com.au>
Cc: paulmck@...ux.vnet.ibm.com,
Andrew Morton <akpm@...ux-foundation.org>,
Christoph Hellwig <hch@....de>, Ingo Molnar <mingo@...e.hu>,
Pavel Emelyanov <xemul@...nvz.org>,
Vitaliy Gusev <vgusev@...nvz.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] kthreads: rework kthread_stop()
Rusty Russell <rusty@...tcorp.com.au> writes:
> On Wednesday 04 February 2009 15:40:06 Eric W. Biederman wrote:
>> static struct kthread *to_kthread(struct task_struct *tsk)
>> {
>> void *stack = task_stack_page(tsk);
>> return (struct kthread *)(stack + kthread_offset);
>>
>> }
> ...
>> It would remove the test and be simple and obviously correct.
>
> Clever? Sure. Neat? Yes.
>
> But you are using a definition of obvious with which I was not previously
> familiar :)
Well the way you compute kthread_offset is:
struct kthread kthread;
void *stack = task_stack_page(current);
kthread_offset = (void *)&kthread - stack;
Now Rusty I don't know about you but after I learned to do
addition and subtraction it has always been obvious to me that
one is the opposite of the other.
Further I think the rest of that code becomes a lot clearer if
we can remove that stupid, unnecessary conditional. As worrying
if the process has exited implies we care about a lot of things
that we really don't and seem to make the code generally less
comprehensible.
I am slightly concerned that using task_stack_page(tsk) may be
overly clever, but compared to ACCESS_ONCE(), memory barriers,
or not letting kthread_stop be called on a thread that may exit
I think I am ahead of the game.
Eric
--
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