Skip to contentSkip to conversation

mm/vmpressure: reduce CPU, memory and code overhead on cgroup v2

PATCH Superseded Usama Arif 3 participants 13 messages Jun 6 – Jun 29

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Usama Arif

author
#0 lore raw

cover mm/vmpressure: reduce CPU, memory and code overhead on cgroup v2

The vmpressure subsystem has two distinct consumers, gated by the @tree argument:

tree=false : in-kernel socket pressure, consumed by TCP/SCTP. This

               is cgroup v2 only; v1 sockets read memcg->tcpmem_pressure
               instead.

tree=true : cgroup v1 userspace eventfd notifications via the
memory.pressure_level / cgroup.event_control interface. v2 has no equivalent (userspace gets reclaim signals through memory.pressure / PSI, which doesn't touch vmpressure).

So of the four (hierarchy, tree) combinations, only two carry data that anyone reads. The existing early return in vmpressure() covered v1 + tree=false; the symmetric v2 + tree=true case was falling through and doing the full lock / accumulate / schedule_work / parent-walk dance, even though the events list it eventually iterates is empty on cgroup v2 (vmpressure_register_event() is wired up only through the v1 cftype "memory.pressure_level" and can't be reached from a v2 memcg).

Patch 1 extends the existing early return to also skip v2 + tree=true. On a v2-only host this eliminates a contended path where reclaimers can serialize on a single global sr_lock. bpftrace on a 176-core production host (cgroup v2, 285 memcgs, sustained reclaim) showed ~16,200 such calls per minute with tree = true.

Patch 2 follows up with a cleanup: it splits the v1 userspace eventfd interface (struct vmpressure_event, the events list and its mutex, the work_struct and its handler, the parent walk, vmpressure_register_event / unregister_event, and vmpressure_prio) into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y, behind small no-op stubs in the header. mm/vmpressure.c keeps the shared bits and the tree=false socket-pressure path. The size of vmpressure.c goes down to half and the code is much more simpler. The only #ifdef CONFIG_MEMCG_V1 remaining in source is around the v1-only fields inside struct vmpressure itself. Memory savings on CONFIG_MEMCG_V1=n:
struct vmpressure : 112B -> 24B
struct mem_cgroup : 1664B -> 1536B

Usama Arif (2):
mm/vmpressure: skip tree=true accounting on cgroup v2 mm/vmpressure: split v1 userspace eventfd code into vmpressure-v1.c

 include/linux/vmpressure.h |  46 +++++-
 mm/Makefile                |   2 +-
 mm/vmpressure-v1.c         | 305 +++++++++++++++++++++++++++++++++++++
 mm/vmpressure.c            | 303 +++---------------------------------
 4 files changed, 364 insertions(+), 292 deletions(-)
 create mode 100644 mm/vmpressure-v1.c
Signature · 1 line
2.52.0
author
#1 lore raw

PATCH 1/2 mm/vmpressure: skip tree=true accounting on cgroup v2

vmpressure() has two outputs gated by the @tree argument:

@tree=false drives in-kernel socket pressure (mem_cgroup_set_
socket_pressure), consumed by TCP/SCTP. This only applies on cgroup v2; on v1 socket memory is charged separately via tcpmem and the consumer reads memcg->tcpmem_pressure instead.

@tree=true drives userspace eventfd notifications via the v1
memory.pressure_level / cgroup.event_control interface. v2 has no equivalent: userspace gets reclaim signals through memory.pressure (PSI), which does not touch vmpressure.

The existing early return covered v1 + @tree=false. The symmetric v2 + @tree=true case was falling through and doing the full lock / accumulate / schedule_work / parent-walk dance for an events list that can never be populated. bpftrace on a 176-core production host (cgroup v2, CONFIG_MEMCG_V1=n, 285 memcgs, sustained reclaim) showed ~16,200 @tree=true vmpressure() calls per minute. Add an early return that skips cgroup v2 + tree = true which avoids us doing all this work. On a v2-only host this also eliminates a lock contention path that can serialise reclaimers on a single global sr_lock.

---
 mm/vmpressure.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
mm/vmpressure.c +6 -4
index f053554e5826..c82cee1ab43b 100644
@@ -246,11 +246,13 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		return;
 
 	/*
-	 * The in-kernel users only care about the reclaim efficiency
-	 * for this @memcg rather than the whole subtree, and there
-	 * isn't and won't be any in-kernel user in a legacy cgroup.
+	 * Only two combinations have a consumer:
+	 *   cgroup v2 + tree=false -> in-kernel socket pressure
+	 *   cgroup v1 + tree=true  -> userspace eventfds (memory.pressure_level)
+	 * Skip the other two: nothing consumes the result.
 	 */
-	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !tree)
+	if ((!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !tree) ||
+	    (cgroup_subsys_on_dfl(memory_cgrp_subsys) && tree))
 		return;
 
 	vmpr = memcg_to_vmpressure(memcg);
Signature · 1 line
2.52.0
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mm/vmpressure: skip tree=true accounting on cgroup v2

Quoted 24 lines · Usama Arif

vmpressure() has two outputs gated by the @tree argument:

@tree=false drives in-kernel socket pressure (mem_cgroup_set_
socket_pressure), consumed by TCP/SCTP. This only applies on cgroup v2; on v1 socket memory is charged separately via tcpmem and the consumer reads memcg->tcpmem_pressure instead.

@tree=true drives userspace eventfd notifications via the v1
memory.pressure_level / cgroup.event_control interface. v2 has no equivalent: userspace gets reclaim signals through memory.pressure (PSI), which does not touch vmpressure.

The existing early return covered v1 + @tree=false. The symmetric v2 + @tree=true case was falling through and doing the full lock / accumulate / schedule_work / parent-walk dance for an events list that can never be populated. bpftrace on a 176-core production host (cgroup v2, CONFIG_MEMCG_V1=n, 285 memcgs, sustained reclaim) showed ~16,200 @tree=true vmpressure() calls per minute. Add an early return that skips cgroup v2 + tree = true which avoids us doing all this work. On a v2-only host this also eliminates a lock contention path that can serialise reclaimers on a single global sr_lock.

Quoted 1 line
#3 lore raw

Re: [PATCH 1/2] mm/vmpressure: skip tree=true accounting on cgroup v2

In reply to Usama Arif

Hello Usama.

mm/vmpressure.c void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree, · line 252

Quoted 13 lines · Usama Arif
mm/vmpressure.c +4 -3
@@ -246,11 +246,13 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		return;
 
 	/*
-	 * The in-kernel users only care about the reclaim efficiency
-	 * for this @memcg rather than the whole subtree, and there
-	 * isn't and won't be any in-kernel user in a legacy cgroup.
+	 * Only two combinations have a consumer:
+	 *   cgroup v2 + tree=false -> in-kernel socket pressure
+	 *   cgroup v1 + tree=true  -> userspace eventfds (memory.pressure_level)
+	 * Skip the other two: nothing consumes the result.

This is a good finding, I had some troubles convincing myself that the v2 has really only the memcg->socket_pressure. I think swapping the order of the patches would make it easier to comprehend.

Michal

author
#4 lore raw

Re: [PATCH 1/2] mm/vmpressure: skip tree=true accounting on cgroup v2

Quoted 8 lines · On Thu, 25 Jun 2026 11:04:15 +0200 Michal Koutný <[email protected]> wrote:

Hello Usama.

Quoted 5 lines · Usama Arif
mm/vmpressure.c +0 -0
@@ -246,11 +246,13 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		return;
 
Quoted 12 lines

mm/vmpressure.c void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree, · line 252

Quoted 8 lines
mm/vmpressure.c +4 -3
 	/*
-	 * The in-kernel users only care about the reclaim efficiency
-	 * for this @memcg rather than the whole subtree, and there
-	 * isn't and won't be any in-kernel user in a legacy cgroup.
+	 * Only two combinations have a consumer:
+	 *   cgroup v2 + tree=false -> in-kernel socket pressure
+	 *   cgroup v1 + tree=true  -> userspace eventfds (memory.pressure_level)
+	 * Skip the other two: nothing consumes the result.

This is a good finding, I had some troubles convincing myself that the v2 has really only the memcg->socket_pressure. I think swapping the order of the patches would make it easier to comprehend.

Thanks Michal! I realized when trying to swap the order that the splitting off v1 commit will end up doing more that what I think it should do (just splitting off v1 specific code), as the tree = true code will not get compiled in at all for cgroup v2, and it then ends up changing more behaviour. I am sending the next revision with the current order, but if you have a strong preference, I will respin with the order reversed.

Quoted 4 lines

Michal

author
#5 lore raw

PATCH 2/2 mm/vmpressure: split v1 userspace eventfd code into vmpressure-v1.c

In reply to Usama Arif

Clean up mm/vmpressure.c by separating the cgroup v1 userspace eventfd interface from the shared and v2 in-kernel code.

Currently, almost half of mm/vmpressure.c exists to serve tree=true:
struct vmpressure_event, the events list and its mutex, the work_struct and vmpressure_work_fn that drains tree_scanned/tree_reclaimed, the parent walk, vmpressure_event(), vmpressure_register_event(), vmpressure_unregister_event(), and vmpressure_prio() (which always calls vmpressure() with tree=true).

Move it all into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y (following the existing memcontrol-v1.o pattern).

vmpressure.c keeps the shared bits (constants, vmpressure_calc_level, the runtime hierarchy check, the tree=false body, init/cleanup plumbing) and calls into three small v1 hooks for the tree=true accumulator and the v1 portions of init/cleanup. The hooks have static-inline no-op stubs in include/linux/vmpressure.h for the !MEMCG_V1 case, so callers don't need ifdefs. vmpressure_prio() gets the same treatment, which means vmscan.c's call site disappears at compile time on v2-only kernels.

The only #ifdef CONFIG_MEMCG_V1 in source remains around the v1-only fields inside struct vmpressure itself.

Memory savings on CONFIG_MEMCG_V1=n (measured with pahole):

struct vmpressure : 112B -> 24B
struct mem_cgroup : 1664B -> 1536B

---
 include/linux/vmpressure.h |  46 +++++-
 mm/Makefile                |   2 +-
 mm/vmpressure-v1.c         | 305 +++++++++++++++++++++++++++++++++++++
 mm/vmpressure.c            | 293 ++---------------------------------
 4 files changed, 358 insertions(+), 288 deletions(-)
 create mode 100644 mm/vmpressure-v1.c
include/linux/vmpressure.h +41 -5
index faecd5522401..e5e6b68d0dc4 100644
@@ -13,18 +13,31 @@
 struct vmpressure {
 	unsigned long scanned;
 	unsigned long reclaimed;
+	/* The lock is used to keep the scanned/reclaimed in sync. */
+	spinlock_t sr_lock;
 
+#ifdef CONFIG_MEMCG_V1
+	/*
+	 * tree=true accumulators feed the v1 userspace eventfd interface
+	 * (memory.pressure_level). Drained by @work. v2 has no equivalent
+	 * interface, so this state is omitted on CONFIG_MEMCG_V1=n builds.
+	 */
 	unsigned long tree_scanned;
 	unsigned long tree_reclaimed;
-	/* The lock is used to keep the scanned/reclaimed above in sync. */
-	spinlock_t sr_lock;
-
 	/* The list of vmpressure_event structs. */
 	struct list_head events;
 	/* Have to grab the lock on events traversal or modifications. */
 	struct mutex events_lock;
 
 	struct work_struct work;
+#endif
+};
+
+enum vmpressure_levels {
+	VMPRESSURE_LOW = 0,
+	VMPRESSURE_MEDIUM,
+	VMPRESSURE_CRITICAL,
+	VMPRESSURE_NUM_LEVELS,
 };
 
 struct mem_cgroup;
@@ -32,18 +45,41 @@ struct mem_cgroup;
 #ifdef CONFIG_MEMCG
 void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		unsigned long scanned, unsigned long reclaimed);
-extern void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio);
-
 extern void vmpressure_init(struct vmpressure *vmpr);
 extern void vmpressure_cleanup(struct vmpressure *vmpr);
 extern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg);
 extern struct mem_cgroup *vmpressure_to_memcg(struct vmpressure *vmpr);
+
+/* Shared with mm/vmpressure-v1.c. */
+extern const unsigned long vmpressure_win;
+extern enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
+						    unsigned long reclaimed);
+
+#ifdef CONFIG_MEMCG_V1
+extern void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio);
 extern int vmpressure_register_event(struct mem_cgroup *memcg,
 				     struct eventfd_ctx *eventfd,
 				     const char *args);
 extern void vmpressure_unregister_event(struct mem_cgroup *memcg,
 					struct eventfd_ctx *eventfd);
+
+/* v1 hooks called from mm/vmpressure.c; no-ops below when !MEMCG_V1. */
+extern void vmpressure_v1_init(struct vmpressure *vmpr);
+extern void vmpressure_v1_cleanup(struct vmpressure *vmpr);
+extern void vmpressure_v1_account_tree(struct vmpressure *vmpr,
+				       unsigned long scanned,
+				       unsigned long reclaimed);
 #else
+static inline void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg,
+				   int prio) {}
+static inline void vmpressure_v1_init(struct vmpressure *vmpr) {}
+static inline void vmpressure_v1_cleanup(struct vmpressure *vmpr) {}
+static inline void vmpressure_v1_account_tree(struct vmpressure *vmpr,
+					      unsigned long scanned,
+					      unsigned long reclaimed) {}
+#endif /* CONFIG_MEMCG_V1 */
+
+#else /* !CONFIG_MEMCG */
 static inline void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg,
 			      bool tree, unsigned long scanned,
 			      unsigned long reclaimed) {}
mm/Makefile +1 -1
index eff9f9e7e061..282688f6a543 100644
@@ -101,7 +101,7 @@ obj-$(CONFIG_DEVICE_MIGRATION) += migrate_device.o
 obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o
 obj-$(CONFIG_PAGE_COUNTER) += page_counter.o
 obj-$(CONFIG_LIVEUPDATE_MEMFD) += memfd_luo.o
-obj-$(CONFIG_MEMCG_V1) += memcontrol-v1.o
+obj-$(CONFIG_MEMCG_V1) += memcontrol-v1.o vmpressure-v1.o
 obj-$(CONFIG_MEMCG) += memcontrol.o vmpressure.o
 ifdef CONFIG_BPF_SYSCALL
 obj-$(CONFIG_MEMCG) += bpf_memcontrol.o
mm/vmpressure-v1.c new file +305 -0

305 lines not on this page · raw message

mm/vmpressure.c +11 -282

350 lines not on this page · raw message

Signature · 1 line
2.52.0
#6 lore raw

Re: [PATCH 2/2] mm/vmpressure: split v1 userspace eventfd code into vmpressure-v1.c

Quoted 10 lines · Usama Arif

Clean up mm/vmpressure.c by separating the cgroup v1 userspace eventfd interface from the shared and v2 in-kernel code.

Currently, almost half of mm/vmpressure.c exists to serve tree=true:
struct vmpressure_event, the events list and its mutex, the work_struct and vmpressure_work_fn that drains tree_scanned/tree_reclaimed, the parent walk, vmpressure_event(), vmpressure_register_event(), vmpressure_unregister_event(), and vmpressure_prio() (which always calls vmpressure() with tree=true).

Quoted 2 lines

Move it all into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y (following the existing memcontrol-v1.o pattern).

Thanks for this dissection.

Quoted 7 lines
mm/vmpressure.c +0 -3
@@ -283,14 +152,8 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		return;
 
 	if (tree) {
-		spin_lock(&vmpr->sr_lock);
-		scanned = vmpr->tree_scanned += scanned;
-		vmpr->tree_reclaimed += reclaimed;

mm/vmpressure.c void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree, · line 159

Quoted 10 lines
mm/vmpressure.c +2 -5
-		spin_unlock(&vmpr->sr_lock);
-
-		if (scanned < vmpressure_win)
-			return;
-		schedule_work(&vmpr->work);
+		vmpressure_v1_account_tree(vmpr, scanned, reclaimed);
+		return;
 	} else {
 		enum vmpressure_levels level;
 

This return; looks weird, I'd either
a) drop it or
b) keep it + de-indent the rest of the vmpressure().

author
#7 lore raw

Re: [PATCH 2/2] mm/vmpressure: split v1 userspace eventfd code into vmpressure-v1.c

Quoted 29 lines · Michal Koutný
Quoted 10 lines · Usama Arif

Clean up mm/vmpressure.c by separating the cgroup v1 userspace eventfd interface from the shared and v2 in-kernel code.

Currently, almost half of mm/vmpressure.c exists to serve tree=true:
struct vmpressure_event, the events list and its mutex, the work_struct and vmpressure_work_fn that drains tree_scanned/tree_reclaimed, the parent walk, vmpressure_event(), vmpressure_register_event(), vmpressure_unregister_event(), and vmpressure_prio() (which always calls vmpressure() with tree=true).

Quoted 2 lines

Move it all into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y (following the existing memcontrol-v1.o pattern).

Thanks for this dissection.

Quoted 13 lines
mm/vmpressure.c +1 -8
@@ -283,14 +152,8 @@ void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree,
 		return;
 
 	if (tree) {
-		spin_lock(&vmpr->sr_lock);
-		scanned = vmpr->tree_scanned += scanned;
-		vmpr->tree_reclaimed += reclaimed;
-		spin_unlock(&vmpr->sr_lock);
-
-		if (scanned < vmpressure_win)
-			return;
-		schedule_work(&vmpr->work);
+		vmpressure_v1_account_tree(vmpr, scanned, reclaimed);
Quoted 8 lines

mm/vmpressure.c void vmpressure(gfp_t gfp, int order, struct mem_cgroup *memcg, bool tree, · line 159

Quoted 4 lines
mm/vmpressure.c +1 -0
+		return;
 	} else {
 		enum vmpressure_levels level;
 

This return; looks weird, I'd either
a) drop it or
b) keep it + de-indent the rest of the vmpressure().

Thanks! Will do.

#8 lore raw
In reply to Usama Arif
Quoted 6 lines · Usama Arif

The vmpressure subsystem has two distinct consumers, gated by the @tree argument:

tree=false : in-kernel socket pressure, consumed by TCP/SCTP. This

               is cgroup v2 only; v1 sockets read memcg->tcpmem_pressure
               instead.

We should really move v2 away from vmpressure.

Quoted 15 lines

tree=true : cgroup v1 userspace eventfd notifications via the
memory.pressure_level / cgroup.event_control interface. v2 has no equivalent (userspace gets reclaim signals through memory.pressure / PSI, which doesn't touch vmpressure).

So of the four (hierarchy, tree) combinations, only two carry data that anyone reads. The existing early return in vmpressure() covered v1 + tree=false; the symmetric v2 + tree=true case was falling through and doing the full lock / accumulate / schedule_work / parent-walk dance, even though the events list it eventually iterates is empty on cgroup v2 (vmpressure_register_event() is wired up only through the v1 cftype "memory.pressure_level" and can't be reached from a v2 memcg).

Quoted 5 lines

Patch 1 extends the existing early return to also skip v2 + tree=true. On a v2-only host this eliminates a contended path where reclaimers can serialize on a single global sr_lock. bpftrace on a 176-core production host (cgroup v2, 285 memcgs, sustained reclaim) showed ~16,200 such calls per minute with tree = true.

This is good.

Quoted 14 lines

Patch 2 follows up with a cleanup: it splits the v1 userspace eventfd interface (struct vmpressure_event, the events list and its mutex, the work_struct and its handler, the parent walk, vmpressure_register_event / unregister_event, and vmpressure_prio) into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y, behind small no-op stubs in the header. mm/vmpressure.c keeps the shared bits and the tree=false socket-pressure path. The size of vmpressure.c goes down to half and the code is much more simpler. The only #ifdef CONFIG_MEMCG_V1 remaining in source is around the v1-only fields inside struct vmpressure itself. Memory savings on CONFIG_MEMCG_V1=n:
struct vmpressure : 112B -> 24B
struct mem_cgroup : 1664B -> 1536B

For this, I am wondering if we should just go ahead and work towards making vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed for that and only then patch 2 makes sense.

author
#9 lore raw
Quoted 25 lines · Shakeel Butt
Quoted 6 lines · Usama Arif

The vmpressure subsystem has two distinct consumers, gated by the @tree argument:

tree=false : in-kernel socket pressure, consumed by TCP/SCTP. This

               is cgroup v2 only; v1 sockets read memcg->tcpmem_pressure
               instead.

We should really move v2 away from vmpressure.

Quoted 15 lines

tree=true : cgroup v1 userspace eventfd notifications via the
memory.pressure_level / cgroup.event_control interface. v2 has no equivalent (userspace gets reclaim signals through memory.pressure / PSI, which doesn't touch vmpressure).

So of the four (hierarchy, tree) combinations, only two carry data that anyone reads. The existing early return in vmpressure() covered v1 + tree=false; the symmetric v2 + tree=true case was falling through and doing the full lock / accumulate / schedule_work / parent-walk dance, even though the events list it eventually iterates is empty on cgroup v2 (vmpressure_register_event() is wired up only through the v1 cftype "memory.pressure_level" and can't be reached from a v2 memcg).

Quoted 8 lines
Quoted 5 lines

Patch 1 extends the existing early return to also skip v2 + tree=true. On a v2-only host this eliminates a contended path where reclaimers can serialize on a single global sr_lock. bpftrace on a 176-core production host (cgroup v2, 285 memcgs, sustained reclaim) showed ~16,200 such calls per minute with tree = true.

This is good.

Thanks!

Quoted 15 lines
Quoted 14 lines

Patch 2 follows up with a cleanup: it splits the v1 userspace eventfd interface (struct vmpressure_event, the events list and its mutex, the work_struct and its handler, the parent walk, vmpressure_register_event / unregister_event, and vmpressure_prio) into a new mm/vmpressure-v1.c built only when CONFIG_MEMCG_V1=y, behind small no-op stubs in the header. mm/vmpressure.c keeps the shared bits and the tree=false socket-pressure path. The size of vmpressure.c goes down to half and the code is much more simpler. The only #ifdef CONFIG_MEMCG_V1 remaining in source is around the v1-only fields inside struct vmpressure itself. Memory savings on CONFIG_MEMCG_V1=n:
struct vmpressure : 112B -> 24B
struct mem_cgroup : 1664B -> 1536B

Quoted 4 lines

For this, I am wondering if we should just go ahead and work towards making vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed for that and only then patch 2 makes sense.

I think there might be a transition needed? Because vmpressure and PSI do not work out to be the same and people might notice a regression with increased memory usage or a hit in networking performance and might want to opt out? A solution might be to switch socket pressure to PSI while keeping vmpressure around gated by a defconfig. And then in a few releases remove it completely for cgroup v2 if no one complaints. If we go down that path, we would need patch 2 for the medium term.

#10 lore raw
Quoted 8 lines · Usama Arif
Quoted 7 lines

For this, I am wondering if we should just go ahead and work towards making vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed for that and only then patch 2 makes sense.

Quoted 7 lines

I think there might be a transition needed? Because vmpressure and PSI do not work out to be the same and people might notice a regression with increased memory usage or a hit in networking performance and might want to opt out? A solution might be to switch socket pressure to PSI while keeping vmpressure around gated by a defconfig. And then in a few releases remove it completely for cgroup v2 if no one complaints. If we go down that path, we would need patch 2 for the medium term.

Yeah the reasoning that PSI is not an exact replacement for vmpressure makes sense and it will take couple of iterations to transition v2 (networking) away from vmpressure. Can you please update your commit message with this and about the midterm or transition plan.

I assume eventually we will just have vmpressure-v1.c file which will be behind MEMCG_V1 flag, correct?

author
#11 lore raw
Quoted 17 lines · Shakeel Butt
Quoted 8 lines · Usama Arif
Quoted 7 lines

For this, I am wondering if we should just go ahead and work towards making vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed for that and only then patch 2 makes sense.

Quoted 7 lines

I think there might be a transition needed? Because vmpressure and PSI do not work out to be the same and people might notice a regression with increased memory usage or a hit in networking performance and might want to opt out? A solution might be to switch socket pressure to PSI while keeping vmpressure around gated by a defconfig. And then in a few releases remove it completely for cgroup v2 if no one complaints. If we go down that path, we would need patch 2 for the medium term.

Quoted 7 lines

Yeah the reasoning that PSI is not an exact replacement for vmpressure makes sense and it will take couple of iterations to transition v2 (networking) away from vmpressure. Can you please update your commit message with this and about the midterm or transition plan.

I assume eventually we will just have vmpressure-v1.c file which will be behind MEMCG_V1 flag, correct?

Yes.

How about something like below in the commit message? :

This split is the first step toward eventually making vmpressure CONFIG_MEMCG_V1 only. The v2 in-kernel socket pressure path (tree=false) cannot be removed today immediately: PSI is not an exact replacement for vmpressure, and switching networking socket-buffer back-off to PSI may regress networking performance or increase memory pressure in workloads that today rely on vmpressure's hysteresis. The medium-term plan is to introduce a PSI-based socket-pressure path, keep vmpressure available for v2 behind a defconfig as an opt-out for several releases, and only then drop the tree=false path entirely, at which point everything that remains in mm/vmpressure-v1.c is the whole subsystem.

#12 lore raw
Quoted 32 lines · Usama Arif
Quoted 17 lines · Shakeel Butt
Quoted 8 lines · Usama Arif
Quoted 7 lines

For this, I am wondering if we should just go ahead and work towards making vmpressure memcg-v1 only unless we foresee a lot of or complex work is needed for that and only then patch 2 makes sense.

Quoted 7 lines

I think there might be a transition needed? Because vmpressure and PSI do not work out to be the same and people might notice a regression with increased memory usage or a hit in networking performance and might want to opt out? A solution might be to switch socket pressure to PSI while keeping vmpressure around gated by a defconfig. And then in a few releases remove it completely for cgroup v2 if no one complaints. If we go down that path, we would need patch 2 for the medium term.

Quoted 7 lines

Yeah the reasoning that PSI is not an exact replacement for vmpressure makes sense and it will take couple of iterations to transition v2 (networking) away from vmpressure. Can you please update your commit message with this and about the midterm or transition plan.

I assume eventually we will just have vmpressure-v1.c file which will be behind MEMCG_V1 flag, correct?

Yes.

How about something like below in the commit message? :

Quoted 11 lines

This split is the first step toward eventually making vmpressure CONFIG_MEMCG_V1 only. The v2 in-kernel socket pressure path (tree=false) cannot be removed today immediately: PSI is not an exact replacement for vmpressure, and switching networking socket-buffer back-off to PSI may regress networking performance or increase memory pressure in workloads that today rely on vmpressure's hysteresis. The medium-term plan is to introduce a PSI-based socket-pressure path, keep vmpressure available for v2 behind a defconfig as an opt-out for several releases, and only then drop the tree=false path entirely, at which point everything that remains in mm/vmpressure-v1.c is the whole subsystem.

This looks good to me.