Messages in this thread Patch in this message | | | Subject | [PATCH 2/4] exit: Use rcu instead of get_task_struct() in mm_update_next_owner() | From | Kirill Tkhai <> | Date | Thu, 26 Apr 2018 14:00:49 +0300 |
| |
Since release_task() puts final task_struct::usage counter at least one rcu grace period after removing from task list:
__exit_signal() __unhash_process() call_rcu(&p->rcu, delayed_put_task_struct)
rcu_read_lock() guarantees nobody release task_struct memory. So, it's possible to use this primitive instead of get_task_struct().
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> --- kernel/exit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c index 9fb7b699bdeb..5c42a9b9c1d7 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -464,7 +464,7 @@ void mm_update_next_owner(struct mm_struct *mm) return; assign_new_owner: - get_task_struct(c); + rcu_read_lock(); read_unlock(&tasklist_lock); BUG_ON(c == p); @@ -475,12 +475,12 @@ void mm_update_next_owner(struct mm_struct *mm) task_lock(c); if (c->mm != mm) { task_unlock(c); - put_task_struct(c); + rcu_read_unlock(); goto retry; } mm->owner = c; task_unlock(c); - put_task_struct(c); + rcu_read_unlock(); } #endif /* CONFIG_MEMCG */
| |