On Tue, 2009-12-08 at 17:31 +0100, Oleg Nesterov wrote:

> > If you take a task ref you can write the much saner:
> >
> > utrace_control()
> > {
> >   ...
> >   spin_lock(&utrace->lock);
> >   ...
> >   if (reset)
> >     utrace_reset(utrace);
> >
> >   spin_unlock(&utrace->lock);
> > }
> 
> No, get_task_struct() in utrace_reset() can't help, we should move
> it into utrace_control() then. And in this case it becomes even more
> subtle: it is needed because ->utrace_flags may be cleared inside
> utrace_reset() and after that utrace_control()->spin_unlock() becomes
> unsafe.

The task->utrace pointer is cleaned up on
free_task()->tracehook_free_task()->utrace_free_task(), so by holding a
ref on the task, we ensure ->utrace stays around, and we can do
spin_unlock(), right?

> Also. utrace_reset() drops utrace->lock to call put_detached_list()
> lockless. If we want to avoid the assymetric locking, every caller
> should pass "struct list_head *detached" to utrace_reset(), drop
> utrace->lock, and call put_detached_list().

All that seems to do is call ->release() and kmem_cache_free()s the
utrace_engine thing, why can't that be done with utrace->lock held?

But yeah, passing that list along does seem like a better solution.

Reply via email to