memcg: mm_update_next_owner: move for_each_thread() into try_to_set_owner()
authorOleg Nesterov <oleg@redhat.com>
Wed, 26 Jun 2024 15:29:30 +0000 (17:29 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jul 2024 01:05:58 +0000 (18:05 -0700)
commitd73d00352145fb51d31771047aa939850d87fa50
treebc28ea0f7d5b5984f44fe73ab56d19fc222b3a81
parent2a22b773b15f5aa97c029acad79bda11ce5f2b4d
memcg: mm_update_next_owner: move for_each_thread() into try_to_set_owner()

mm_update_next_owner() checks the children / real_parent->children to
avoid the "everything else" loop in the likely case, but this won't work
if a child/sibling has a zombie leader with ->mm == NULL.

Move the for_each_thread() logic into try_to_set_owner(), if nothing else
this makes the children/siblings/everything searches more consistent.

Link: https://lkml.kernel.org/r/20240626152930.GA17936@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