diff --git a/0004-fix-wrong-nodemask_sz-when-CONFIG_NODES_SHIFT-is-les.patch b/0004-fix-wrong-nodemask_sz-when-CONFIG_NODES_SHIFT-is-les.patch new file mode 100644 index 0000000000000000000000000000000000000000..6481fae7893317525192f29ba007ea902df9089f --- /dev/null +++ b/0004-fix-wrong-nodemask_sz-when-CONFIG_NODES_SHIFT-is-les.patch @@ -0,0 +1,61 @@ +From eeb3d396ee5401114bf0d486d200dffb03f54ac5 Mon Sep 17 00:00:00 2001 +From: Chunsheng Luo +Date: Tue, 15 Nov 2022 15:21:31 +0800 +Subject: [PATCH] fix wrong nodemask_sz when CONFIG_NODES_SHIFT is less than 5 + +Signed-off-by: buque +--- + libnuma.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +diff --git a/libnuma.c b/libnuma.c +index b8e5603..896e995 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -370,13 +370,11 @@ set_configured_nodes(void) + } + } + +-/* +- * Convert the string length of an ascii hex mask to the number +- * of bits represented by that mask. +- */ +-static int s2nbits(const char *s) ++static inline int is_digit(char s) + { +- return strlen(s) * 32 / 9; ++ return (s >= '0' && s <= '9') ++ || (s >= 'a' && s <= 'f') ++ || (s >= 'A' && s <= 'F'); + } + + /* Is string 'pre' a prefix of string 's'? */ +@@ -398,6 +396,8 @@ set_nodemask_size(void) + { + FILE *fp; + char *buf = NULL; ++ char *tmp_buf = NULL; ++ int digit_len = 0; + size_t bufsize = 0; + + if ((fp = fopen(mask_size_file, "r")) == NULL) +@@ -405,8 +405,14 @@ set_nodemask_size(void) + + while (getline(&buf, &bufsize, fp) > 0) { + if (strprefix(buf, nodemask_prefix)) { +- nodemask_sz = s2nbits(buf + strlen(nodemask_prefix)); +- break; ++ tmp_buf = buf; ++ tmp_buf += strlen(nodemask_prefix); ++ while (*tmp_buf != '\n' && *tmp_buf != '\0') { ++ if (is_digit(*tmp_buf)) ++ digit_len++; ++ tmp_buf++; ++ } ++ nodemask_sz = digit_len * 4; + } + } + free(buf); +-- +2.33.0 + diff --git a/numactl.spec b/numactl.spec index f7d34b0432472cf7a18d07d9ca9ccdd1c77b7e19..33dfdb67ba9d923ac9b3568712f0535ac846b20e 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,6 +1,6 @@ Name: numactl Version: 2.0.16 -Release: 3 +Release: 4 Summary: Library for tuning for Non Uniform Memory Access machines License: GPLv2 URL: https://github.com/numactl/numactl @@ -10,6 +10,7 @@ BuildRequires: libtool automake autoconf Patch0001: 0001-libnuma-clear-errno-at-the-end-of-numa_init.patch Patch0002: 0002-numactl-Fix-shm-verfiy-for-preferred-policy.patch Patch0003: 0003-numactl-numactl-length-xxx-shm-xxx-px-doesn-t-work.patch +Patch0004: 0004-fix-wrong-nodemask_sz-when-CONFIG_NODES_SHIFT-is-les.patch %description Simple NUMA policy support. It consists of a numactl program to run other @@ -78,6 +79,9 @@ LD_LIBRARY_PATH=$(pwd)/.libs make check %{_mandir}/man3/*.3* %changelog +* Mon Jun 19 2023 wuxu - 2.0.16-4 +- fix wrong nodemask_sz when CONFIG_NODES_SHIFT is less than 5 + * Fri Dec 16 2022 lijianglin - 2.0.16-3 - fix the problem of some commands of memhog, migspeed and numactl failed to execute