From 7472ca8744e80818e73204bc6cc9b45d9d18158c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 2 Aug 2025 02:48:34 +0900 Subject: [PATCH] sd-event: drop cgroupv1 support in memory pressure event source --- src/libsystemd/sd-event/sd-event.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 6cb496c5418..d8cd1ba7dfe 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -1968,27 +1968,19 @@ _public_ int sd_event_add_memory_pressure( /* By default we want to watch memory pressure on the local cgroup, but we'll fall back on * the system wide pressure if for some reason we cannot (which could be: memory controller - * not delegated to us, or PSI simply not available in the kernel). On legacy cgroupv1 we'll - * only use the system-wide logic. */ - r = cg_all_unified(); + * not delegated to us, or PSI simply not available in the kernel). */ + + _cleanup_free_ char *cg = NULL; + r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &cg); if (r < 0) return r; - if (r == 0) - watch = "/proc/pressure/memory"; - else { - _cleanup_free_ char *cg = NULL; - - r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &cg); - if (r < 0) - return r; - w = path_join("/sys/fs/cgroup", cg, "memory.pressure"); - if (!w) - return -ENOMEM; + w = path_join("/sys/fs/cgroup", cg, "memory.pressure"); + if (!w) + return -ENOMEM; - watch = w; - watch_fallback = "/proc/pressure/memory"; - } + watch = w; + watch_fallback = "/proc/pressure/memory"; /* Android uses three levels in its userspace low memory killer logic: * some 70000 1000000 -- 2.47.3