public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: paulmck@linux.vnet.ibm.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>, Ingo Molnar <mingo@elte.hu>,
	Pavel Emelyanov <xemul@openvz.org>,
	Vitaliy Gusev <vgusev@openvz.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] kthreads: rework kthread_stop()
Date: Wed, 04 Feb 2009 07:59:35 -0800	[thread overview]
Message-ID: <m1r62ew5ug.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <200902042134.32346.rusty@rustcorp.com.au> (Rusty Russell's message of "Wed\, 4 Feb 2009 21\:34\:31 +1030")

Rusty Russell <rusty@rustcorp.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

  reply	other threads:[~2009-02-04 15:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-30 12:33 [PATCH 3/4] kthreads: rework kthread_stop() Oleg Nesterov
2009-01-30 12:50 ` Oleg Nesterov
2009-01-31 12:16   ` Rusty Russell
2009-02-01 10:21     ` Oleg Nesterov
2009-02-02 17:57       ` Eric W. Biederman
2009-02-02 19:41         ` Oleg Nesterov
2009-02-03  3:25           ` Eric W. Biederman
2009-02-03 13:41             ` Paul E. McKenney
2009-02-04  5:10               ` Eric W. Biederman
2009-02-04 11:04                 ` Rusty Russell
2009-02-04 15:59                   ` Eric W. Biederman [this message]
2009-02-05  1:03                     ` Rusty Russell
2009-02-04 20:46                   ` Jon Masters
2009-01-30 21:47 ` Andrew Morton
2009-02-01 10:49   ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1r62ew5ug.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --cc=vgusev@openvz.org \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox