numa: add support for preferred-many and weighted-interleave policies

Add support for two newer NUMA memory policies:

- MPOL_PREFERRED_MANY (Linux 5.15): like MPOL_PREFERRED but accepts
  a set of nodes instead of a single node, falling back to all nodes
  if preferred nodes cannot satisfy the allocation.

- MPOL_WEIGHTED_INTERLEAVE (Linux 6.9): like MPOL_INTERLEAVE but
  distributes pages across nodes proportionally to per-node weights
  configured via /sys/kernel/mm/mempolicy/weighted_interleave/.

On kernels that do not support the requested policy, set_mempolicy()
returns EINVAL. We convert EINVAL to EOPNOTSUPP only for the two new
policies (MPOL_PREFERRED_MANY, MPOL_WEIGHTED_INTERLEAVE), so that a
bad NUMAMask= for already-supported policies still fails the service
rather than being silently ignored.

The NUMA subsystem being absent (ENOSYS) continues to be handled
silently at debug level, as before.

Varlink serialization uses json_underscorify() on an owned copy of
the policy name string to convert hyphenated names to the underscore
form declared in the IDL enum, avoiding mutation of the read-only
static string table.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
This commit is contained in:
dongshengyuan
2026-06-28 13:40:07 +09:00
committed by Yu Watanabe
parent 5a03efc9c1
commit c99674a408
9 changed files with 100 additions and 17 deletions
+3 -2
View File
@@ -67,13 +67,14 @@ REQUIREMENTS:
of systemd. Taint flag 'old-kernel' will be set. systemd will most likely
still function, but upstream support and testing are limited.
Linux kernel ≥ 6.3 for MFD_EXEC/MFD_NOEXEC_SEAL and tmpfs noswap option
Linux kernel ≥ 5.15 for MPOL_PREFERRED_MANY NUMA policy
≥ 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.7 for cgroup2fs memory_hugetlb_accounting option
≥ 6.8 for STATX_MNT_ID_UNIQUE
≥ 6.9 for pidfs
≥ 6.9 for pidfs and MPOL_WEIGHTED_INTERLEAVE NUMA policy
≥ 6.10 for fcntl(F_DUPFD_QUERY), unprivileged linkat(AT_EMPTY_PATH),
and block device 'partscan' sysfs attribute
≥ 6.12 for AT_HANDLE_MNT_ID_UNIQUE