On Tue, Mar 14, 2017 at 04:37:05PM +0100, Oleg Nesterov wrote: > On 03/14, Peter Zijlstra wrote: > > > > Do we want a WARN_ON_ONCE(atomic_read(&tsk->usage)); in free_task()? > > Because in the above scenario we're freeing it with references on. > > Not sure, in this case copy_process() should decrement tsk->usage > before free_task(), note the atomic_set(&tsk->usage, 2) in > dup_task_struct(). > > Perhaps we should just add WARN_ON(tsk->usage != 2) into copy_process() > right before free_task() ?
Sure; that works. I'll try that once I'm back home again, to see if there's unexpected fail because other things increment it.

