lkml.org 
[lkml]   [2009]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/4] kthreads: rework kthread_stop()
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com> writes:

> ACCESS_ONCE() suffices in many cases, but if the pointer being accessed
> points to a structure that might recently have been initialized, then
> rcu_dereference() will be required on Alpha. Though perhaps the
> discussion below removes the need entirely, but cannot say that I fully
> understand this part of the kernel.

Thanks. I had overlooked the addition of ACCESS_ONCE() into our set of
tricks. I thought Oleg was referring to a hypothetical construct.

Currently Oleg's implementation is fine because of an explicit
memory barrier and two dereferences of the pointer. It just isn't
especially clear.

ACCESS_ONCE would help.

Hmm.

I wonder if it would be better/clearer to define to_kthread as:

static struct kthread *to_kthread(struct task_struct *tsk)
{
void *stack = task_stack_page(tsk);
return (struct kthread *)(stack + kthread_offset);
}
And to measure kthread_offset the first time kthread() was
called. I would love to have a fixed compile time offset but
I don't know how to measure it at compile time reliably.

Oleg what do you think. It would remove the test and be simple and
obviously correct.

Eric





\
 
 \ /
  Last update: 2009-02-04 06:13    [from the cache]
©2003-2011 Jasper Spaans