Skip to content

Commit

Permalink
linux/bind: more verbose error if the MPOL_PREFERRED_MANY isn't suppo…
Browse files Browse the repository at this point in the history
…rted

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 <Brice.Goglin@inria.fr>
(cherry picked from commit 05a1435)
  • Loading branch information
bgoglin committed Jun 14, 2024
1 parent fa732df commit bc7ffa2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions hwloc/topology-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit bc7ffa2

Please sign in to comment.