mm: clean up and clarify lruvec lookup procedure
authorJohannes Weiner <hannes@cmpxchg.org>
Sun, 1 Dec 2019 01:55:34 +0000 (17:55 -0800)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 17 Jan 2024 17:15:52 +0000 (18:15 +0100)
commit54171bdfd60124b32c4766da2d50a787b134a9e1
treef2c636da6e1289ff5ff06b5137730623fe09c856
parent849589bbbd30600b79124aba4298d122f99843bb
mm: clean up and clarify lruvec lookup procedure

There is a per-memcg lruvec and a NUMA node lruvec.  Which one is being
used is somewhat confusing right now, and it's easy to make mistakes -
especially when it comes to global reclaim.

How it works: when memory cgroups are enabled, we always use the
root_mem_cgroup's per-node lruvecs.  When memory cgroups are not compiled
in or disabled at runtime, we use pgdat->lruvec.

Document that in a comment.

Due to the way the reclaim code is generalized, all lookups use the
mem_cgroup_lruvec() helper function, and nobody should have to find the
right lruvec manually right now.  But to avoid future mistakes, rename the
pgdat->lruvec member to pgdat->__lruvec and delete the convenience wrapper
that suggests it's a commonly accessed member.

While in this area, swap the mem_cgroup_lruvec() argument order.  The name
suggests a memcg operation, yet it takes a pgdat first and a memcg second.
I have to double take every time I call this.  Fix that.

Link: http://lkml.kernel.org/r/20191022144803.302233-3-hannes@cmpxchg.org
Change-Id: Ibe111f47294a8067dbc57683a84583a33477847b
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 2230dc207a325970d54c3ca1efe896a57ea82499 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
include/linux/memcontrol.h
include/linux/mmzone.h
mm/memcontrol.c
mm/page_alloc.c
mm/slab.h
mm/vmscan.c
mm/workingset.c