mm, memcg: isolate deprecated v1 state from struct mem_cgroup
Subsystems (7)
cover mm, memcg: isolate deprecated v1 state from struct mem_cgroup
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (mm/memcontrol-v1.c) and at the Kconfig level (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside struct mem_cgroup, guarded by #ifdefs.
This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated struct mem_cgroup_v1, and every access goes through memcg->v1.X.
With this in place the v1 implementation is self-contained: its interface in mm/memcontrol-v1.c, its state in struct mem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together with mm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.
Patch 1 introduces the substruct behind a transitional union whose anonymous side preserves the historical layout, so the patch is semantically empty. Patch 2 converts the access sites and drops the anonymous side. Patch 3 documents the boundary.
This demonstrates one possible pattern for isolating deprecated cgroup v1 implementation from shared structures.
As a validation detail, this does not regress the layout: the member order is preserved, so offsetof(struct mem_cgroup, v1.swappiness) and sizeof(struct mem_cgroup) are unchanged (verified with pahole), and the generated code of hot paths such as mem_cgroup_swappiness() is identical. Build-tested with CONFIG_MEMCG_V1 both enabled and disabled, and boot-tested with both a v1 and a v2 hierarchy.
Tao Cui (3):
mm, memcg: introduce struct mem_cgroup_v1
mm, memcg: move v1-only members into mem_cgroup_v1
docs: cgroup-v1: note the v1 memory controller implementation boundary
.../admin-guide/cgroup-v1/memory.rst | 7 + include/linux/memcontrol.h | 74 +++++------ include/net/sock.h | 2 +- mm/memcontrol-v1.c | 122 +++++++++--------- mm/memcontrol-v1.h | 4 +- mm/memcontrol.c | 22 ++-- mm/swap.h | 2 +- 7 files changed, 121 insertions(+), 112 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 mm, memcg: introduce struct mem_cgroup_v1
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller keeps its state as individual members guarded by CONFIG_MEMCG_V1 inside struct mem_cgroup. While the v1 implementation already lives in mm/memcontrol-v1.c and its interface is behind CONFIG_MEMCG_V1, its data is still intermixed with the shared layout of struct mem_cgroup.
Group the v1-only members into a dedicated struct mem_cgroup_v1 and embed it via a union whose anonymous side reproduces the historical layout. All existing memcg->X accesses keep compiling and the binary layout is unchanged. The anonymous side is dropped by the next patch once the access sites are converted.
No functional change.
--- include/linux/memcontrol.h | 97 ++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 26 deletions(-)
include/linux/memcontrol.h +71 -26
@@ -193,6 +193,43 @@ struct obj_cgroup {* statistics based on the statistics developed by Rik Van Riel for clock-pro, * to help the administrator determine what knobs to tune. */ +/* +* Legacy cgroup v1 memory controller state, used only by the v1 +* interface (mm/memcontrol-v1.c). +*/ +struct mem_cgroup_v1 { +struct page_counter kmem; +struct page_counter tcpmem; + +struct memcg1_events_percpu __percpu *events_percpu; + +/* protected by memcg_oom_lock */ +bool oom_lock; +int under_oom; + +int oom_kill_disable; + +struct mutex thresholds_lock; + +/* RCU-protected */ +struct mem_cgroup_thresholds thresholds; + +/* RCU-protected */ +struct mem_cgroup_thresholds memsw_thresholds; + +/* For oom notifier event fd */ +struct list_head oom_notify; + +bool tcpmem_active; +int tcpmem_pressure; + +/* List of events which userspace want to receive */ +struct list_head event_list; +spinlock_t event_list_lock; + +int swappiness; +}; +struct mem_cgroup {struct cgroup_subsys_state css;
@@ -271,42 +308,50 @@ struct mem_cgroup {__cacheline_group_end_aligned (memcg_cold);#ifdef CONFIG_MEMCG_V1 -/* v1 only. Not grouped: v1 is legacy, sorting it is not worth it. */ +/* +* Transitional: the anonymous struct reproduces the historical layout +* so existing memcg->X accesses keep compiling; it is removed once the +* access sites are converted to memcg->v1.X. +*/ +union { +struct mem_cgroup_v1 v1; +struct { +/* Legacy consumer-oriented counters */ +struct page_counter kmem;/* v1 only */ +struct page_counter tcpmem;/* v1 only */ -/* Legacy consumer-oriented counters */ -struct page_counter kmem;/* v1 only */ -struct page_counter tcpmem;/* v1 only */ +struct memcg1_events_percpu __percpu *events_percpu; -struct memcg1_events_percpu __percpu *events_percpu; +/* protected by memcg_oom_lock */ +bool oom_lock; +int under_oom; -/* protected by memcg_oom_lock */ -bool oom_lock; -int under_oom; +/* OOM-Killer disable */ +int oom_kill_disable; -/* OOM-Killer disable */ -int oom_kill_disable; +/* protect arrays of thresholds */ +struct mutex thresholds_lock; -/* protect arrays of thresholds */ -struct mutex thresholds_lock; +/* thresholds for memory usage. RCU-protected */ +struct mem_cgroup_thresholds thresholds; -/* thresholds for memory usage. RCU-protected */ -struct mem_cgroup_thresholds thresholds; - -/* thresholds for mem+swap usage. RCU-protected */ -struct mem_cgroup_thresholds memsw_thresholds; +/* thresholds for mem+swap usage. RCU-protected */ +struct mem_cgroup_thresholds memsw_thresholds; -/* For oom notifier event fd */ -struct list_head oom_notify; +/* For oom notifier event fd */ +struct list_head oom_notify; -/* Legacy tcp memory accounting */ -bool tcpmem_active; -int tcpmem_pressure; +/* Legacy tcp memory accounting */ +bool tcpmem_active; +int tcpmem_pressure; -/* List of events which userspace want to receive */ -struct list_head event_list; -spinlock_t event_list_lock; +/* List of events which userspace want to receive */ +struct list_head event_list; +spinlock_t event_list_lock; -int swappiness; +int swappiness; + }; + };#endif /* CONFIG_MEMCG_V1 */ /*
Signature · 1 line
2.43.0
PATCH 2/3 mm, memcg: move v1-only members into mem_cgroup_v1
In reply to Tao CuiFrom: Tao Cui <[email protected]>
Convert all access sites of the v1-only members to go through the new mem_cgroup_v1 substruct (memcg->v1.X) and drop the transitional anonymous union side introduced by the previous patch.
The member order inside struct mem_cgroup_v1 is identical to the historical order of these members inside struct mem_cgroup, so the shared layout does not change: offsetof(struct mem_cgroup, v1.swappiness) and the total size of struct mem_cgroup are unchanged, and the generated code in the hot paths (e.g. mem_cgroup_swappiness) is the same.
No functional change.
--- include/linux/memcontrol.h | 45 +------------- include/net/sock.h | 2 +- mm/memcontrol-v1.c | 122 ++++++++++++++++++------------------- mm/memcontrol-v1.h | 4 +- mm/memcontrol.c | 22 +++---- mm/swap.h | 2 +- 6 files changed, 77 insertions(+), 120 deletions(-)
include/linux/memcontrol.h +1 -44
@@ -308,50 +308,7 @@ struct mem_cgroup {__cacheline_group_end_aligned (memcg_cold);#ifdef CONFIG_MEMCG_V1 -/* -* Transitional: the anonymous struct reproduces the historical layout -* so existing memcg->X accesses keep compiling; it is removed once the -* access sites are converted to memcg->v1.X. -*/ -union { -struct mem_cgroup_v1 v1; -struct { -/* Legacy consumer-oriented counters */ -struct page_counter kmem;/* v1 only */ -struct page_counter tcpmem;/* v1 only */ - -struct memcg1_events_percpu __percpu *events_percpu; - -/* protected by memcg_oom_lock */ -bool oom_lock; -int under_oom; - -/* OOM-Killer disable */ -int oom_kill_disable; - -/* protect arrays of thresholds */ -struct mutex thresholds_lock; - -/* thresholds for memory usage. RCU-protected */ -struct mem_cgroup_thresholds thresholds; - -/* thresholds for mem+swap usage. RCU-protected */ -struct mem_cgroup_thresholds memsw_thresholds; - -/* For oom notifier event fd */ -struct list_head oom_notify; - -/* Legacy tcp memory accounting */ -bool tcpmem_active; -int tcpmem_pressure; - -/* List of events which userspace want to receive */ -struct list_head event_list; -spinlock_t event_list_lock; - -int swappiness; - }; - }; +struct mem_cgroup_v1 v1;#endif /* CONFIG_MEMCG_V1 */ /*
include/net/sock.h +1 -1
@@ -2707,7 +2707,7 @@ static inline bool mem_cgroup_sk_under_memory_pressure(const struct sock *sk)#ifdef CONFIG_MEMCG_V1 if (!cgroup_subsys_on_dfl (memory_cgrp_subsys)) -return !!memcg->tcpmem_pressure; +return !!memcg->v1.tcpmem_pressure;#endif /* CONFIG_MEMCG_V1 */ do {
mm/memcontrol-v1.c +61 -61
362 lines not on this page · raw message
mm/memcontrol-v1.h +2 -2
@@ -73,13 +73,13 @@ void reparent_memcg_lruvec_state_local(struct mem_cgroup *memcg,void memcg1_account_kmem (struct mem_cgroup *memcg,int nr_pages);static inline bool memcg1_tcpmem_active (struct mem_cgroup *memcg) { -return memcg->tcpmem_active; +return memcg->v1.tcpmem_active; }bool memcg1_charge_skmem (struct mem_cgroup *memcg,unsigned int nr_pages,gfp_t gfp_mask);static inline void memcg1_uncharge_skmem (struct mem_cgroup *memcg,unsigned int nr_pages) { -page_counter_uncharge (&memcg->tcpmem, nr_pages); +page_counter_uncharge (&memcg->v1.tcpmem, nr_pages); }extern struct cftype memsw_files[];
mm/memcontrol.c +11 -11
@@ -1867,8 +1867,8 @@ void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)K ((u64 )page_counter_read (&memcg->memsw)), K((u64)memcg->memsw.max), memcg->memsw.failcnt);pr_info ("kmem: usage %llukB, limit %llukB, failcnt %lu\n" , -K ((u64 )page_counter_read (&memcg->kmem)), - K((u64)memcg->kmem.max), memcg->kmem.failcnt); +K ((u64 )page_counter_read (&memcg->v1.kmem)), + K((u64)memcg->v1.kmem.max), memcg->v1.kmem.failcnt); }#endif
@@ -4285,13 +4285,13 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)page_counter_init (&memcg->memory, &parent->memory, memcg_on_dfl);page_counter_init (&memcg->swap, &parent->swap, false);#ifdef CONFIG_MEMCG_V1 -WRITE_ONCE (memcg->swappiness,mem_cgroup_swappiness (parent)); +WRITE_ONCE (memcg->v1.swappiness,mem_cgroup_swappiness (parent)); memcg->memory.track_failcnt = !memcg_on_dfl; memcg->memsw.track_failcnt = !memcg_on_dfl; -WRITE_ONCE (memcg->oom_kill_disable,READ_ONCE (parent->oom_kill_disable)); -page_counter_init (&memcg->kmem, &parent->kmem, false); -page_counter_init (&memcg->tcpmem, &parent->tcpmem, false); - memcg->tcpmem.track_failcnt = !memcg_on_dfl; +WRITE_ONCE (memcg->v1.oom_kill_disable,READ_ONCE (parent->v1.oom_kill_disable)); +page_counter_init (&memcg->v1.kmem, &parent->v1.kmem, false); +page_counter_init (&memcg->v1.tcpmem, &parent->v1.tcpmem, false); + memcg->v1.tcpmem.track_failcnt = !memcg_on_dfl;#endif }else {init_memcg_stats ();
@@ -4299,8 +4299,8 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)page_counter_init (&memcg->memory,NULL , true);page_counter_init (&memcg->swap,NULL , false);#ifdef CONFIG_MEMCG_V1 -page_counter_init (&memcg->kmem,NULL , false); -page_counter_init (&memcg->tcpmem,NULL , false); +page_counter_init (&memcg->v1.kmem,NULL , false); +page_counter_init (&memcg->v1.tcpmem,NULL , false);#endif root_mem_cgroup = memcg;return &memcg->css;
@@ -4477,8 +4477,8 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)WRITE_ONCE (memcg->zswap_writeback, true);#endif #ifdef CONFIG_MEMCG_V1 -page_counter_set_max (&memcg->kmem,PAGE_COUNTER_MAX ); -page_counter_set_max (&memcg->tcpmem,PAGE_COUNTER_MAX ); +page_counter_set_max (&memcg->v1.kmem,PAGE_COUNTER_MAX ); +page_counter_set_max (&memcg->v1.tcpmem,PAGE_COUNTER_MAX );#endif page_counter_set_min (&memcg->memory,0 );page_counter_set_low (&memcg->memory,0 );
mm/swap.h +1 -1
@@ -87,7 +87,7 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)#ifdef CONFIG_MEMCG_V1 if (!cgroup_subsys_on_dfl (memory_cgrp_subsys) && !mem_cgroup_disabled () && !mem_cgroup_is_root (memcg)) -return READ_ONCE (memcg->swappiness); +return READ_ONCE (memcg->v1.swappiness);#endif return READ_ONCE (vm_swappiness); }
Signature · 1 line
2.43.0
PATCH 3/3 docs: cgroup-v1: note the v1 memory controller implementation boundary
In reply to Tao CuiFrom: Tao Cui <[email protected]>
Document that the legacy memory controller is now isolated behind CONFIG_MEMCG_V1, with its state in struct mem_cgroup_v1, and that new functionality belongs to the v2 memory controller.
--- Documentation/admin-guide/cgroup-v1/memory.rst | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/admin-guide/cgroup-v1/memory.rst +7 -0
@@ -8,6 +8,13 @@ Memory Resource Controller here but make sure to check the current code if you need a deeper understanding. +.. note:: + The legacy (v1) memory controller implementation is isolated behind + ``CONFIG_MEMCG_V1``: its interface lives in ``mm/memcontrol-v1.c`` and + its per-cgroup state in ``struct mem_cgroup_v1`` (see + ``include/linux/memcontrol.h``). New functionality belongs to the + cgroup v2 memory controller. + .. note:: The Memory Resource Controller has generically been referred to as the memory controller in this document. Do not confuse memory controller
Signature · 1 line
2.43.0
Shakeel Butt
maintainerQuoted 12 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.
Quoted 5 lines
With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
Quoted 13 lines · Shakeel Butt
Quoted 12 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.
Quoted 8 lines
Quoted 5 lines
With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar). I am not convinced this is sufficient to justify the churn either.
Signature · 2 lines
Michal Hocko SUSE Labs
Hi Shakeel, Michal,
Quoted 20 lines · Michal Hocko
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.
Quoted 6 lines
Quoted 2 lines
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar). I am not convinced this is sufficient to justify the churn either.
Thanks for taking a look.
You are right that the file and Kconfig layers already isolate the v1 implementation at build time, and =n builds get nothing from this series. The benefit is only for =y builds.
In a =y build today, the deprecated controller's state is still embedded directly in struct mem_cgroup and common code accesses it directly. This series moves that state behind a single struct mem_cgroup_v1, complementing the existing file- and Kconfig-level separation at the data structure level. The layout is unchanged, so there is no runtime cost.
My intention was to explore whether this could serve as a general pattern for isolating the remaining cgroup v1-only state, rather than as a standalone memcg cleanup. I should have made that context clearer in the cover letter.
If that isn't sufficient to justify the churn, I understand.
Thanks,
Tao
Johannes Weiner
maintainerQuoted 20 lines · Michal Hocko
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.
Quoted 5 lines
Quoted 2 lines
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar).
I had the same thought. It's kiiind of nice to see which members are completely specific to memcg1.
Quoted 1 line
I am not convinced this is sufficient to justify the churn either.
IMO it helps that it's mostly in memcontrol-v1.c where the chances of interfering with other work are pretty slim.
The patch 1 + patch 2 split is a bit bothersome: indenting everything into a union, only to then move it out in the next patch.
Tao, if you folded these two patches to make it one clean extraction and changed over the sites at the same time, I would probably lean supportive on this.
Hi Johannes, Shakeel, Michal,
Quoted 35 lines · Johannes Weiner
Quoted 20 lines · Michal Hocko
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.Quoted 5 lines
Quoted 2 lines
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar).
I had the same thought. It's kiiind of nice to see which members are completely specific to memcg1.
Quoted 1 line
I am not convinced this is sufficient to justify the churn either.
IMO it helps that it's mostly in
memcontrol-v1.cwhere the chances of interfering with other work are pretty slim.
Quoted 6 lines
The patch 1 + patch 2 split is a bit bothersome: indenting everything into a union, only to then move it out in the next patch.
Tao, if you folded these two patches to make it one clean extraction and changed over the sites at the same time, I would probably lean supportive on this.
Sorry for the late reply.
Thanks for the feedback. Looking back, I think Johannes' point about the patch split is fair. I split the first two patches to keep the initial step semantically neutral, but it also made the series look like churn for the sake of churn.
I'll fold the first two patches into a single extraction in the next revision. That should present the change more directly and hopefully make it easier to judge whether the resulting boundary is worthwhile.
Thanks,
Tao
Roman Gushchin
maintainerI believe we want to delete this code sooner than later, why would we rewrite it before that?
Quoted 62 lines · Tao Cui
Hi Johannes, Shakeel, Michal,
Quoted 36 lines · Johannes Weiner
Quoted 21 lines · Michal Hocko
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.Quoted 5 lines
Quoted 2 lines
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar).
I had the same thought. It's kiiind of nice to see which members are completely specific to memcg1.
Quoted 1 line
I am not convinced this is sufficient to justify the churn either.
IMO it helps that it's mostly in
memcontrol-v1.cwhere the chances of interfering with other work are pretty slim.Quoted 6 lines
The patch 1 + patch 2 split is a bit bothersome: indenting everything into a union, only to then move it out in the next patch.
Tao, if you folded these two patches to make it one clean extraction and changed over the sites at the same time, I would probably lean supportive on this.
Sorry for the late reply.
Thanks for the feedback. Looking back, I think Johannes' point about the patch split is fair. I split the first two patches to keep the initial step semantically neutral, but it also made the series look like churn for the sake of churn.
I'll fold the first two patches into a single extraction in the next revision. That should present the change more directly and hopefully make it easier to judge whether the resulting boundary is worthwhile.
Thanks,
Tao
Hi Roman,
Quoted 2 lines · Roman Gushchin
I believe we want to delete this code sooner than later, why would we rewrite it before that?
My assumption was that v1 would still be maintained for some time before its eventual removal, and the goal was to reduce the coupling between the remaining v1 code and the shared core structures during that period, rather than to rewrite the implementation for its own sake.
If the expectation is that the remaining v1 implementation will be removed in the near future, then I agree this work becomes much harder to justify.
Am I being too optimistic about how long the remaining v1 code is expected to stay around?
Thanks,
Tao
Quoted 62 lines
Quoted 62 lines · Tao Cui
Hi Johannes, Shakeel, Michal,
Quoted 36 lines · Johannes Weiner
Quoted 21 lines · Michal Hocko
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Tao Cui
From: Tao Cui <[email protected]>
The legacy cgroup v1 memory controller has already been moved out of the shared implementation at the file level (
mm/memcontrol-v1.c) and at theKconfiglevel (CONFIG_MEMCG_V1, default n since 6.11). Its per-cgroup state, however, still sits as individual members inside structmem_cgroup, guarded by #ifdefs.This series isolates the deprecated implementation from the shared hot
structure: all v1-only members are grouped into a dedicated structmem_cgroup_v1, and every access goes throughmemcg->v1.X.With this in place the v1 implementation is self-contained: its interface in
mm/memcontrol-v1.c, its state in structmem_cgroup_v1, and its eventual removal becomes a localized deletion of this struct together withmm/memcontrol-v1.c, instead of unwinding ifdef-scattered members across the shared header.Quoted 5 lines
Quoted 2 lines
Sorry I don't see any benefit of this code churn. The code is already behind config. What exactly this code churn is giving us?
The only arguable upside is that this would make it ever so slightly easier to track v1 specific stuff (once that s@v1@memcg1@ or similar).
I had the same thought. It's kiiind of nice to see which members are completely specific to memcg1.
Quoted 1 line
I am not convinced this is sufficient to justify the churn either.
IMO it helps that it's mostly in
memcontrol-v1.cwhere the chances of interfering with other work are pretty slim.Quoted 6 lines
The patch 1 + patch 2 split is a bit bothersome: indenting everything into a union, only to then move it out in the next patch.
Tao, if you folded these two patches to make it one clean extraction and changed over the sites at the same time, I would probably lean supportive on this.
Sorry for the late reply.
Thanks for the feedback. Looking back, I think Johannes' point about the patch split is fair. I split the first two patches to keep the initial step semantically neutral, but it also made the series look like churn for the sake of churn.
I'll fold the first two patches into a single extraction in the next revision. That should present the change more directly and hopefully make it easier to judge whether the resulting boundary is worthwhile.
Thanks,
Tao
Roman Gushchin
maintainerQuoted 11 lines · Tao Cui
Hi Roman,
Quoted 2 lines · Roman Gushchin
I believe we want to delete this code sooner than later, why would we rewrite it before that?
My assumption was that v1 would still be maintained for some time before its eventual removal, and the goal was to reduce the coupling between the remaining v1 code and the shared core structures during that period, rather than to rewrite the implementation for its own sake.
I understand. But personally I don't see big issues with the current code caused by the v1 stuff. Maybe I miss something...
The proposed changes on the other hand create difficulties for those who use v1 and maintain some local changes or simple backport upstream fixes. Of course, it's not a reason to not change the upstream code if it's justified, but in this case I'm hardly convinced.
Quoted 6 lines
If the expectation is that the remaining v1 implementation will be removed in the near future, then I agree this work becomes much harder to justify.
Am I being too optimistic about how long the remaining v1 code is expected to stay around?
Well, Idk, it was considered deprecated for quite some time already, so maybe announcing that it will be deleted in a year is reasonable?
Shakeel, Johannes, Michal, wdyt?
Quoted 26 lines · Roman Gushchin
Quoted 11 lines · Tao Cui
Hi Roman,
Quoted 2 lines · Roman Gushchin
I believe we want to delete this code sooner than later, why would we rewrite it before that?
My assumption was that v1 would still be maintained for some time before its eventual removal, and the goal was to reduce the coupling between the remaining v1 code and the shared core structures during that period, rather than to rewrite the implementation for its own sake.
I understand. But personally I don't see big issues with the current code caused by the v1 stuff. Maybe I miss something...
The proposed changes on the other hand create difficulties for those who use v1 and maintain some local changes or simple backport upstream fixes. Of course, it's not a reason to not change the upstream code if it's justified, but in this case I'm hardly convinced.
Quoted 4 lines
If the expectation is that the remaining v1 implementation will be removed in the near future, then I agree this work becomes much harder to justify.
Quoted 7 lines
Quoted 2 lines
Am I being too optimistic about how long the remaining v1 code is expected to stay around?
Well, Idk, it was considered deprecated for quite some time already, so maybe announcing that it will be deleted in a year is reasonable?
Shakeel, Johannes, Michal, wdyt?
As I've said up in the thread I am not really convinced this is something we should merge.
Signature · 2 lines
Michal Hocko SUSE Labs
Johannes Weiner
maintainerQuoted 26 lines · Roman Gushchin
Quoted 11 lines · Tao Cui
Hi Roman,
Quoted 2 lines · Roman Gushchin
I believe we want to delete this code sooner than later, why would we rewrite it before that?
My assumption was that v1 would still be maintained for some time before its eventual removal, and the goal was to reduce the coupling between the remaining v1 code and the shared core structures during that period, rather than to rewrite the implementation for its own sake.
I understand. But personally I don't see big issues with the current code caused by the v1 stuff. Maybe I miss something...
The proposed changes on the other hand create difficulties for those who use v1 and maintain some local changes or simple backport upstream fixes. Of course, it's not a reason to not change the upstream code if it's justified, but in this case I'm hardly convinced.
Quoted 4 lines
If the expectation is that the remaining v1 implementation will be removed in the near future, then I agree this work becomes much harder to justify.
Quoted 5 lines
Quoted 2 lines
Am I being too optimistic about how long the remaining v1 code is expected to stay around?
Well, Idk, it was considered deprecated for quite some time already, so maybe announcing that it will be deleted in a year is reasonable?
That might be tougher for v1 users than the member placement :-)
My understanding is that there are still a few heavy v1 users out there. I'm not sure they can move within that timeframe. Personally I think the cost of the v1 code now is kind of negligible now?
Quoted 1 line
Shakeel, Johannes, Michal, wdyt?
I was a weak yes on Tao's patch. Happy to keep it out with you and Michal not being fans of it.
Quoted 30 lines · Johannes Weiner
Quoted 29 lines · Roman Gushchin
Quoted 11 lines · Tao Cui
Hi Roman,
Quoted 2 lines · Roman Gushchin
I believe we want to delete this code sooner than later, why would we rewrite it before that?
My assumption was that v1 would still be maintained for some time before its eventual removal, and the goal was to reduce the coupling between the remaining v1 code and the shared core structures during that period, rather than to rewrite the implementation for its own sake.
I understand. But personally I don't see big issues with the current code caused by the v1 stuff. Maybe I miss something...
The proposed changes on the other hand create difficulties for those who use v1 and maintain some local changes or simple backport upstream fixes. Of course, it's not a reason to not change the upstream code if it's justified, but in this case I'm hardly convinced.
Quoted 6 lines
If the expectation is that the remaining v1 implementation will be removed in the near future, then I agree this work becomes much harder to justify.
Am I being too optimistic about how long the remaining v1 code is expected to stay around?
Quoted 8 lines
Quoted 2 lines
Well, Idk, it was considered deprecated for quite some time already, so maybe announcing that it will be deleted in a year is reasonable?
That might be tougher for v1 users than the member placement :-)
My understanding is that there are still a few heavy v1 users out there. I'm not sure they can move within that timeframe. Personally I think the cost of the v1 code now is kind of negligible now?
Fully agreed.
Signature · 2 lines
Michal Hocko SUSE Labs