From: Yu Watanabe Date: Fri, 1 Aug 2025 17:48:34 +0000 (+0900) Subject: sd-event: drop cgroupv1 support in memory pressure event source X-Git-Tag: v259-rc1~543 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7472ca8744e80818e73204bc6cc9b45d9d18158c;p=thirdparty%2Fsystemd.git sd-event: drop cgroupv1 support in memory pressure event source --- 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