Re: [PATCH 3/4] kthreads: rework kthread_stop()

From: Eric W. Biederman
Date: Wed Feb 04 2009 - 00:10:09 EST


"Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> 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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/