From f17df4f64d68ccaa0bfd37f8d57839011123dada Mon Sep 17 00:00:00 2001 From: lijianglin Date: Fri, 16 Dec 2022 16:43:45 +0800 Subject: [PATCH] fix the problem of some commands of memhog, migspeed and numactl failed to execute (cherry picked from commit d81184f055d6f766d4da9f86c9714cf7c39b0f28) --- ...-clear-errno-at-the-end-of-numa_init.patch | 30 ++++++++++++++++ ...-Fix-shm-verfiy-for-preferred-policy.patch | 36 +++++++++++++++++++ ...l-length-xxx-shm-xxx-px-doesn-t-work.patch | 29 +++++++++++++++ numactl.spec | 9 ++++- 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 0001-libnuma-clear-errno-at-the-end-of-numa_init.patch create mode 100644 0002-numactl-Fix-shm-verfiy-for-preferred-policy.patch create mode 100644 0003-numactl-numactl-length-xxx-shm-xxx-px-doesn-t-work.patch diff --git a/0001-libnuma-clear-errno-at-the-end-of-numa_init.patch b/0001-libnuma-clear-errno-at-the-end-of-numa_init.patch new file mode 100644 index 0000000..d334485 --- /dev/null +++ b/0001-libnuma-clear-errno-at-the-end-of-numa_init.patch @@ -0,0 +1,30 @@ +From 097e362c628a8d884fab15f84872810ae0cd41d6 Mon Sep 17 00:00:00 2001 +From: Chunsheng Luo +Date: Sat, 10 Dec 2022 17:53:36 +0800 +Subject: [PATCH] libnuma: clear errno at the end of numa_init + +The construct function numa_init may change errno value +before main function, which can be confuse. + +Fixes: d538c645("libnuma: Query upcoming MPOL_PREFERRED_MANY support") +--- + libnuma.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libnuma.c b/libnuma.c +index e1a8001..b8e5603 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -106,6 +106,9 @@ numa_init(void) + for (i = 0; i < max; i++) + nodemask_set_compat((nodemask_t *)&numa_all_nodes, i); + memset(&numa_no_nodes, 0, sizeof(numa_no_nodes)); ++ ++ /* clear errno */ ++ errno = 0; + } + + static void cleanup_node_cpu_mask_v2(void); +-- +2.33.0 + diff --git a/0002-numactl-Fix-shm-verfiy-for-preferred-policy.patch b/0002-numactl-Fix-shm-verfiy-for-preferred-policy.patch new file mode 100644 index 0000000..d354194 --- /dev/null +++ b/0002-numactl-Fix-shm-verfiy-for-preferred-policy.patch @@ -0,0 +1,36 @@ +From 44f9cc0e66b12b8ed2e65734c5e7a6a9e2948189 Mon Sep 17 00:00:00 2001 +From: Chunsheng Luo +Date: Sat, 10 Dec 2022 22:41:25 +0800 +Subject: [PATCH] numactl: Fix shm verfiy for preferred policy + +The following command can report verify bug: + + numactl --length=4096 --shm abc -p0 --verify + +when policy uses perferred, set_policy isn't set. + +Fixes: 0c844d8c("Update to support multiple nodes") +--- + numactl.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/numactl.c b/numactl.c +index 83a741b..d3c7cea 100755 +--- a/numactl.c ++++ b/numactl.c +@@ -549,6 +549,12 @@ int main(int ac, char **av) + numa_set_bind_policy(0); + if (shmfd >= 0) { + numa_tonode_memory(shmptr, shmlen, node); ++ /* Correspond to numa_set_bind_policy function */ ++ if (numa_has_preferred_many()) { ++ setpolicy(MPOL_PREFERRED_MANY); ++ } else { ++ setpolicy(MPOL_PREFERRED); ++ } + } else if (c == 'p') { + if (numa_bitmask_weight(mask) != 1) + usage(); +-- +2.33.0 + diff --git a/0003-numactl-numactl-length-xxx-shm-xxx-px-doesn-t-work.patch b/0003-numactl-numactl-length-xxx-shm-xxx-px-doesn-t-work.patch new file mode 100644 index 0000000..63ed7a3 --- /dev/null +++ b/0003-numactl-numactl-length-xxx-shm-xxx-px-doesn-t-work.patch @@ -0,0 +1,29 @@ +From afa25454aec135a40ebeafa8f25321e63822bed8 Mon Sep 17 00:00:00 2001 +From: Chunsheng Luo +Date: Mon, 12 Dec 2022 17:10:05 +0800 +Subject: [PATCH] numactl: 'numactl --length=xxx --shm xxx -px' doesn't work + +When preferred is used for shm, no value is assigned to the variable node, +As a result, it does not take effect. + +fixes: 5862e0e4("numactl: Simplify preferred selection") +--- + numactl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/numactl.c b/numactl.c +index d3c7cea..79b323b 100755 +--- a/numactl.c ++++ b/numactl.c +@@ -548,7 +548,7 @@ int main(int ac, char **av) + did_node_cpu_parse = 1; + numa_set_bind_policy(0); + if (shmfd >= 0) { +- numa_tonode_memory(shmptr, shmlen, node); ++ numa_tonode_memory(shmptr, shmlen, find_first(mask)); + /* Correspond to numa_set_bind_policy function */ + if (numa_has_preferred_many()) { + setpolicy(MPOL_PREFERRED_MANY); +-- +2.33.0 + diff --git a/numactl.spec b/numactl.spec index 8cce0cd..f7d34b0 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,12 +1,16 @@ Name: numactl Version: 2.0.16 -Release: 2 +Release: 3 Summary: Library for tuning for Non Uniform Memory Access machines License: GPLv2 URL: https://github.com/numactl/numactl Source0: https://github.com/numactl/numactl/releases/download/v%{version}/numactl-%{version}.tar.gz 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 + %description Simple NUMA policy support. It consists of a numactl program to run other programs with a specific NUMA policy and a libnuma shared library to set @@ -74,6 +78,9 @@ LD_LIBRARY_PATH=$(pwd)/.libs make check %{_mandir}/man3/*.3* %changelog +* Fri Dec 16 2022 lijianglin - 2.0.16-3 +- fix the problem of some commands of memhog, migspeed and numactl failed to execute + * Wed Nov 9 2022 Chunsheng Luo - 2.0.16-2 - delete unused patches -- Gitee