From bc7ffa2148e05b0502e4c1f3fb3c77c16ed1e823 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Fri, 14 Jun 2024 13:55:33 +0200 Subject: [PATCH] linux/bind: more verbose error if the MPOL_PREFERRED_MANY isn't supported Old kernels such as 5.14 in RHEL9 don't support MPOL_PREFERRED_MANY, we fallback to MPOL_PREFERRED which uses only the first given node, leading to less performance. Change the warning into a non-critical error and clarify it. Refs #668 Signed-off-by: Brice Goglin (cherry picked from commit 05a143561bb5d5722fd9ac41b1ad4c0cf2ae6ce9) --- hwloc/topology-linux.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c index af7125341..0842b0b81 100644 --- a/hwloc/topology-linux.c +++ b/hwloc/topology-linux.c @@ -1745,6 +1745,18 @@ hwloc_linux_membind_mask_to_nodeset(hwloc_topology_t topology __hwloc_attribute_ hwloc_bitmap_set_ith_ulong(nodeset, i, linuxmask[i]); } +static __hwloc_inline void +warn_preferred_many_fallback(hwloc_const_bitmap_t nodeset) +{ + static int warned = 0; + if (!warned && HWLOC_SHOW_ALL_ERRORS() && hwloc_bitmap_weight(nodeset) > 1) { + fprintf(stderr, "[hwloc/membind] MPOL_PREFERRED_MANY not supported by the kernel.\n"); + fprintf(stderr, "If *all* given nodes must be used, use strict binding or the interleave policy.\n"); + fprintf(stderr, "Otherwise the old MPOL_PREFERRED will only use the first given node.\n"); + warned = 1; + } +} + static int hwloc_linux_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) { @@ -1801,7 +1813,7 @@ hwloc_linux_set_area_membind(hwloc_topology_t topology, const void *addr, size_t err = hwloc_mbind((void *) addr, len, MPOL_PREFERRED, linuxmask, max_os_index+1, linuxflags); if (!err) { /* worked fine, MPOL_PREFERRED_MANY isn't supported */ - hwloc_debug("MPOL_PREFERRED_MANY not supported, reverting to MPOL_PREFERRED (with a single node)\n"); + warn_preferred_many_fallback(nodeset); preferred_many_notsupported = 1; } } @@ -1894,7 +1906,7 @@ hwloc_linux_set_thisthread_membind(hwloc_topology_t topology, hwloc_const_nodese err = hwloc_set_mempolicy(MPOL_PREFERRED, linuxmask, max_os_index+1); if (!err) { /* worked fine, MPOL_PREFERRED_MANY isn't supported */ - hwloc_debug("MPOL_PREFERRED_MANY not supported, reverting to MPOL_PREFERRED (with a single node)\n"); + warn_preferred_many_fallback(nodeset); preferred_many_notsupported = 1; } }