From 886c078702380686e036b05c54f182305d89182c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 29 Oct 2025 16:30:07 +0100 Subject: [PATCH] mount-setup: Add memory_hugetlb_accounting to cgroupfs mount MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This mount option will count HugeTLB memory usage towards the cgroup’s overall memory usage for the memory controller. See https://lore.kernel.org/all/20231006184629.155543-4-nphamcs@gmail.com/T/#u for the patch introducing the new mount option. --- NEWS | 5 +++++ README | 3 ++- src/shared/mount-setup.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b50a1e123e9..19894d6c187 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ systemd System and Service Manager CHANGES WITH 259 in spe: + * The cgroup2 file system is now mounted with the + "memory_hugetlb_accounting" mount option, supported since kernel 6.6. + This means that HugeTLB memory usage is now counted towards the + cgroup’s overall memory usage for the memory controller. + * homectl's --recovery-key= option may now be used with the "update" command to add recovery keys to existing user accounts. Previously, recovery keys could only be configured during initial user creation. diff --git a/README b/README index 2e3acdd9070..89a9623cdc8 100644 --- a/README +++ b/README @@ -68,7 +68,8 @@ REQUIREMENTS: ≥ 6.3 for MFD_EXEC/MFD_NOEXEC_SEAL and tmpfs noswap option ≥ 6.5 for name_to_handle_at() AT_HANDLE_FID, SO_PEERPIDFD/SO_PASSPIDFD, and MOVE_MOUNT_BENEATH - ≥ 6.6 for quota support on tmpfs + ≥ 6.6 for quota support on tmpfs and cgroup2fs memory_hugetlb_accounting + option ≥ 6.9 for pidfs ≥ 6.10 for fcntl(F_DUPFD_QUERY), unprivileged linkat(AT_EMPTY_PATH), and block device 'partscan' sysfs attribute diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c index cd2b732b9ba..cbd3e1d1076 100644 --- a/src/shared/mount-setup.c +++ b/src/shared/mount-setup.c @@ -50,7 +50,7 @@ static int cgroupfs_mount_options(int priority, const char *type, char **ret) { assert(ret); _cleanup_free_ char *opts = NULL; - FOREACH_STRING(o, "memory_recursiveprot") { + FOREACH_STRING(o, "memory_recursiveprot", "memory_hugetlb_accounting") { r = mount_option_supported("cgroup2", o, /* value = */ NULL); if (r < 0) log_full_errno(priority, r, "Failed to determine whether cgroupfs supports '%s' mount option, assuming not: %m", o); -- 2.47.3