• Eric W. Biederman's avatar
    [PATCH] task: RCU protect task->usage · 8c7904a0
    Eric W. Biederman authored
    A big problem with rcu protected data structures that are also reference
    counted is that you must jump through several hoops to increase the reference
    count.  I think someone finally implemented atomic_inc_not_zero(&count) to
    automate the common case.  Unfortunately this means you must special case the
    rcu access case.
    
    When data structures are only visible via rcu in a manner that is not
    determined by the reference count on the object (i.e.  tasks are visible until
    their zombies are reaped) there is a much simpler technique we can employ.
    Simply delaying the decrement of the reference count until the rcu interval is
    over.
    
    What that means is that the proc code that looks up a task and later
    wants to sleep can now do:
    
    rcu_read_lock();
    task = find_task_by_pid(some_pid);
    if (task) {
    	get_task_struct(task);
    }
    rcu_read_unlock();
    
    The effect on the rest of the kernel is that put_task_struct becomes cheaper
    and immediate, and in the case where the task has been reaped it f...
    8c7904a0
exit.c 41.3 KB