mount-setup: Add memory_hugetlb_accounting to cgroupfs mount

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.
This commit is contained in:
Daan De Meyer
2025-10-29 16:30:07 +01:00
parent 5ce388aec8
commit 886c078702
3 changed files with 8 additions and 2 deletions

5
NEWS
View File

@@ -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
cgroups 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.

3
README
View File

@@ -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

View File

@@ -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);