Re: [PATCH v6 2/6] memcontrol: allows mem_cgroup_iter() to check for onlineness

Andrew Morton
2023-11-27T21:43:06Z

On Mon, 27 Nov 2023 11:36:59 -0800 Nhat Pham <nphamcs@gmail.com> wrote:

> The new zswap writeback scheme requires an online-only memcg hierarchy
> traversal. Add a new parameter to mem_cgroup_iter() to check for
> onlineness before returning.

I get a few build errors, perhaps because of patch timing issues...

mm/shrinker_debug.c: In function 'shrinker_debugfs_count_show':
mm/shrinker_debug.c:64:17: error: too few arguments to function 'mem_cgroup_iter'
64 | memcg = mem_cgroup_iter(NULL, NULL, NULL);
| ^~~~~~~~~~~~~~~
In file included from mm/shrinker_debug.c:7:
./include/linux/memcontrol.h:833:20: note: declared here
833 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
| ^~~~~~~~~~~~~~~
mm/shrinker_debug.c:89:27: error: too few arguments to function 'mem_cgroup_iter'
89 | } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL);
| ^~~~~~~~~~~~~~~
./include/linux/memcontrol.h:833:20: note: declared here
833 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
| ^~~~~~~~~~~~~~~
mm/damon/sysfs-schemes.c: In function 'damon_sysfs_memcg_path_to_id':
mm/damon/sysfs-schemes.c:1594:22: error: too few arguments to function 'mem_cgroup_iter'
1594 | for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg;
| ^~~~~~~~~~~~~~~
In file included from ./include/linux/damon.h:11,
from mm/damon/sysfs-common.h:8,
from mm/damon/sysfs-schemes.c:10:
./include/linux/memcontrol.h:833:20: note: declared here
833 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
| ^~~~~~~~~~~~~~~
mm/damon/sysfs-schemes.c:1595:33: error: too few arguments to function 'mem_cgroup_iter'
1595 | memcg = mem_cgroup_iter(NULL, memcg, NULL)) {
| ^~~~~~~~~~~~~~~
./include/linux/memcontrol.h:833:20: note: declared here
833 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
| ^~~~~~~~~~~~~~~

> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -832,7 +832,7 @@ static inline void mem_cgroup_put(struct mem_cgroup *memcg)
>
> struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *,
> struct mem_cgroup *,
> - struct mem_cgroup_reclaim_cookie *);
> + struct mem_cgroup_reclaim_cookie *, bool online);

How many callsites do we expect to utilize the new `online' argument?
Few, I suspect.

How about we fix the above and simplify the patch by adding a new
mem_cgroup_iter_online() and make mem_cgroup_iter() a one-line wrapper
which calls that and adds the online=false argument?

I also saw this, didn't investigate.

drivers/android/binder_alloc.c: In function 'binder_update_page_range':
drivers/android/binder_alloc.c:237:34: error: too few arguments to function 'list_lru_del'
237 | on_lru = list_lru_del(&binder_alloc_lru, &page->lru);