• Kinsey Ho's avatar
    mm: increment gen # before restarting traversal · 3d150e31
    Kinsey Ho authored
    The generation number in struct mem_cgroup_reclaim_iter should be
    incremented on every round-trip.  Currently, it is possible for a
    concurrent reclaimer to jump in at the end of the hierarchy, causing a
    traversal restart (resetting the iteration position) without incrementing
    the generation number.
    
    By resetting the position without incrementing the generation, it's
    possible for another ongoing mem_cgroup_iter() thread to walk the tree
    twice.
    
    Move the traversal restart such that the generation number is
    incremented before the restart.
    
    Link: https://lkml.kernel.org/r/20240905003058.1859929-4-kinseyho@google.comSigned-off-by: default avatarKinsey Ho <kinseyho@google.com>
    Reviewed-by: default avatarT.J. Mercier <tjmercier@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Michal Koutný <mkoutny@suse.com>
    Cc: Muchun Song <muchun.song@linux.dev>
    Cc: Roman Gushchin <roman.gushchin@linux.dev>
    Cc: Shakeel Butt <shakeel.butt@linux.dev>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Yosry Ahmed <yosryahmed@google.com>
    Cc: Zefan Li <lizefan.x@bytedance.com>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    3d150e31
memcontrol.c 141 KB