From 7cde5f65e5416f7d0c2d36022b4b0c49b9e3f6fa Mon Sep 17 00:00:00 2001 From: wangzhe Date: Thu, 26 Dec 2024 17:26:01 +0800 Subject: [PATCH] [Bug] Save and restore errno when probing for SET_PREFERRED_MANY to #62158694 backport from upstream 6c14bd59d438ebb5ef828e393e8563ba18f59cb2 Signed-off-by: wangzhe --- ...-errno-when-probing-for-SET_PREFERRE.patch | 44 +++++++++++++++++++ numactl.spec | 7 ++- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 1001-Save-and-restore-errno-when-probing-for-SET_PREFERRE.patch diff --git a/1001-Save-and-restore-errno-when-probing-for-SET_PREFERRE.patch b/1001-Save-and-restore-errno-when-probing-for-SET_PREFERRE.patch new file mode 100644 index 0000000..9ccb484 --- /dev/null +++ b/1001-Save-and-restore-errno-when-probing-for-SET_PREFERRE.patch @@ -0,0 +1,44 @@ +From 6c14bd59d438ebb5ef828e393e8563ba18f59cb2 Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Tue, 17 Sep 2024 06:43:23 -0700 +Subject: [PATCH] Save and restore errno when probing for SET_PREFERRED_MANY + +Otherwise a stray errno may leak out of other calls, which can cause +numactl to fail. + +Fixes #231. + +Signed-off-by: Andi Kleen +--- + libnuma.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/libnuma.c b/libnuma.c +index 5d99e81..f10d127 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -627,10 +627,13 @@ set_preferred_many(void) + { + int oldp; + struct bitmask *bmp, *tmp; ++ int old_errno; + + if (has_preferred_many >= 0) + return; + ++ old_errno = errno; ++ + has_preferred_many = 0; + + bmp = numa_allocate_nodemask(); +@@ -650,6 +653,7 @@ set_preferred_many(void) + out: + numa_bitmask_free(tmp); + numa_bitmask_free(bmp); ++ errno = old_errno; + } + + /* +-- +2.43.5 + diff --git a/numactl.spec b/numactl.spec index 38e508a..76071db 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 Name: numactl Summary: Library for tuning for Non Uniform Memory Access machines Version: 2.0.18 @@ -47,7 +47,7 @@ Patch605: 0005-numactl-Add-documentation-for-weighted-interleave.patch Patch606: 0006-Don-t-fail-build-when-set_mempolicy_home_node-syscal.patch Patch607: 0007-numastat-eliminate-hard-coded-tables.patch Patch608: 0008-Update-numactl.c.patch - +Patch1001: 1001-Save-and-restore-errno-when-probing-for-SET_PREFERRE.patch %description @@ -126,6 +126,9 @@ rm -rf $RPM_BUILD_ROOT %doc README.md %changelog +* Thu Dec 26 2024 wangzhe - 2.0.18-1.0.2 +- Save and restore errno when probing for SET_PREFERRED_MANY + * Fri Nov 29 2024 Bo Ren - 2.0.18-1.0.1 - Add doc sub package -- Gitee