]> www.infradead.org Git - users/dwmw2/linux.git/commit
memcg: mm_update_next_owner: kill the "retry" logic
authorOleg Nesterov <oleg@redhat.com>
Wed, 26 Jun 2024 15:29:24 +0000 (17:29 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jul 2024 01:05:57 +0000 (18:05 -0700)
commit2a22b773b15f5aa97c029acad79bda11ce5f2b4d
tree74e0d41bb17f63affc2201d6d8016e5d79a2d0fe
parent1419ff984aad4c08d121793f71a520b432ead88a
memcg: mm_update_next_owner: kill the "retry" logic

Add the new helper, try_to_set_owner(), which tries to update mm->owner
once we see c->mm == mm.  This way mm_update_next_owner() doesn't need to
restart the list_for_each_entry/for_each_process loops from the very
beginning if it races with exit/exec, it can just continue.

Unlike the current code, try_to_set_owner() re-checks tsk->mm == mm before
it drops tasklist_lock, so it doesn't need get/put_task_struct().

Link: https://lkml.kernel.org/r/20240626152924.GA17933@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jinliang Zheng <alexjlzheng@tencent.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Tycho Andersen <tandersen@netflix.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/exit.c