aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <dmarion@me.com>2022-10-17 17:27:28 +0200
committerDave Wallace <dwallacelf@gmail.com>2022-10-18 15:41:23 +0000
commitfecb2524ab71b105422a9a4377429c1871220234 (patch)
tree3690b39bf6c92daa8c3d5effd96eb6bc824424df
parent1cc592b17c3264963995c37f268ef96da88856a3 (diff)
vppinfra: send minimal needed mask to the set_mempolicy syscall
Type: fix fixes: 561ae5d Change-Id: I0d98f5b43bc9ab5d31463b285177a11a10b864d2 Signed-off-by: Damjan Marion <dmarion@me.com>
-rw-r--r--src/vppinfra/linux/mem.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 4365281ce8c..5c12cb573b1 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -28,6 +28,7 @@
#include <vppinfra/mem.h>
#include <vppinfra/lock.h>
#include <vppinfra/time.h>
+#include <vppinfra/bitmap.h>
#include <vppinfra/format.h>
#include <vppinfra/clib_error.h>
#include <vppinfra/linux/sysfs.h>
@@ -608,8 +609,8 @@ __clib_export int
clib_mem_set_numa_affinity (u8 numa_node, int force)
{
clib_mem_main_t *mm = &clib_mem_main;
- long unsigned int mask[16] = { 0 };
- int mask_len = sizeof (mask) * 8 + 1;
+ clib_bitmap_t *bmp = 0;
+ int rv;
/* no numa support */
if (mm->numa_node_bitmap == 0)
@@ -625,19 +626,21 @@ clib_mem_set_numa_affinity (u8 numa_node, int force)
return 0;
}
- mask[0] = 1 << numa_node;
+ bmp = clib_bitmap_set (bmp, numa_node, 1);
- if (syscall (__NR_set_mempolicy, force ? MPOL_BIND : MPOL_PREFERRED, mask,
- mask_len))
- goto error;
+ rv = syscall (__NR_set_mempolicy, force ? MPOL_BIND : MPOL_PREFERRED, bmp,
+ vec_len (bmp) * sizeof (bmp[0] * 8) + 1);
+ clib_bitmap_free (bmp);
vec_reset_length (mm->error);
- return 0;
-error:
- vec_reset_length (mm->error);
- mm->error = clib_error_return_unix (mm->error, (char *) __func__);
- return CLIB_MEM_ERROR;
+ if (rv)
+ {
+ mm->error = clib_error_return_unix (mm->error, (char *) __func__);
+ return CLIB_MEM_ERROR;
+ }
+
+ return 0;
}
__clib_export int