From a8539b43140c641d9efbc1846f024f908536a430 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 21 Apr 2025 10:26:59 +0800 Subject: [PATCH] Release 2.0.19-2 Resolves: https://issues.redhat.com/browse/RHEL-82013 Signed-off-by: Pingfan Liu --- ...bnuma.c-Introduce-numa_preferred_err.patch | 80 +++++++++++++++++++ ...oc-Update-man-for-numa_preferred_err.patch | 37 +++++++++ numactl.spec | 7 +- 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 0001-libnuma.c-Introduce-numa_preferred_err.patch create mode 100644 0002-doc-Update-man-for-numa_preferred_err.patch diff --git a/0001-libnuma.c-Introduce-numa_preferred_err.patch b/0001-libnuma.c-Introduce-numa_preferred_err.patch new file mode 100644 index 0000000..81b3454 --- /dev/null +++ b/0001-libnuma.c-Introduce-numa_preferred_err.patch @@ -0,0 +1,80 @@ +From 1159e00f4f8604fdbb36a8fb04a1c86ce3cdc054 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 23 Jan 2025 18:50:09 +0800 +Subject: [PATCH 1/2] libnuma.c: Introduce numa_preferred_err() + +After commit 87c6834 ( libnuma: Convert preferred node into a mask), +numa_preferred() returns -1 if no suitable node is found. Before that, +it returns 0. + +The users still expect the old behavior, and use 0 as an index to +an array. In order to avoid modifying the existing code, let's introduce +another API numa_preferred_err() to report error if no suitable node is +available and keep numa_preferred() in its original form. + +Signed-off-by: Pingfan Liu +--- + libnuma.c | 12 +++++++++++- + numa.h | 3 +++ + versions.ldscript | 1 + + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/libnuma.c b/libnuma.c +index 1ffe207..380e8a6 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -1947,7 +1947,7 @@ static struct bitmask *__numa_preferred(void) + return bmp; + } + +-int numa_preferred(void) ++int numa_preferred_err(void) + { + int first_node = 0; + struct bitmask *bmp; +@@ -1959,6 +1959,16 @@ int numa_preferred(void) + return first_node; + } + ++int numa_preferred(void) ++{ ++ int first_node = 0; ++ ++ first_node = numa_preferred_err(); ++ first_node = first_node >= 0 ? first_node : 0; ++ ++ return first_node; ++} ++ + static void __numa_set_preferred(struct bitmask *bmp) + { + int nodes = numa_bitmask_weight(bmp); +diff --git a/numa.h b/numa.h +index 51a6833..f0b550b 100644 +--- a/numa.h ++++ b/numa.h +@@ -140,6 +140,9 @@ int numa_max_node(void); + int numa_max_possible_node(void); + /* Return preferred node */ + int numa_preferred(void); ++/* If the preferred node is unavailable, return an error; ++ otherwise, return the preferred node */ ++int numa_preferred_err(void); + + /* Return node size and free memory */ + long long numa_node_size64(int node, long long *freep); +diff --git a/versions.ldscript b/versions.ldscript +index ee48e70..2fd6ebc 100644 +--- a/versions.ldscript ++++ b/versions.ldscript +@@ -45,6 +45,7 @@ libnuma_1.1 { + numa_parse_bitmap; + numa_police_memory; + numa_preferred; ++ numa_preferred_err; + numa_run_on_node; + numa_run_on_node_mask; + numa_sched_getaffinity; +-- +2.49.0 + diff --git a/0002-doc-Update-man-for-numa_preferred_err.patch b/0002-doc-Update-man-for-numa_preferred_err.patch new file mode 100644 index 0000000..0547922 --- /dev/null +++ b/0002-doc-Update-man-for-numa_preferred_err.patch @@ -0,0 +1,37 @@ +From 63e02235bdbcf5aa334903be2111a82b27c8c155 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Fri, 24 Jan 2025 11:33:32 +0800 +Subject: [PATCH 2/2] doc: Update man for numa_preferred_err() + +Signed-off-by: Pingfan Liu +--- + numa.3 | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/numa.3 b/numa.3 +index af24f66..e911953 100644 +--- a/numa.3 ++++ b/numa.3 +@@ -64,6 +64,8 @@ numa \- NUMA policy library + .sp + .B int numa_preferred(void); + .br ++.B int numa_preferred_err(void); ++.br + .B int numa_has_preferred_many(void); + .br + .B struct bitmask *numa_preferred_many(void); +@@ -448,6 +450,10 @@ allocates memory, unless some other policy overrides this. + .\" order of the current node's zonelist to return the correct + .\" node. Need to tighten this up with the syscall results. + ++.BR numa_preferred_err () ++Similiar to numa_preferred(), but If the preferred node is unavailable, ++return an error instead of zero. ++ + .BR numa_has_preferred_many () + Returns > 0 if the system supports multiple preferred nodes. + +-- +2.49.0 + diff --git a/numactl.spec b/numactl.spec index 257adeb..2e8d725 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,7 +1,7 @@ Name: numactl Summary: Library for tuning for Non Uniform Memory Access machines Version: 2.0.19 -Release: 1%{?dist} +Release: 2%{?dist} # libnuma is LGPLv2 and GPLv2 # numactl binaries are GPLv2 only License: GPL-2.0-only @@ -14,6 +14,8 @@ BuildRequires: libtool automake autoconf ExcludeArch: s390 %{arm} # Patch601: 0001-Fix-fallback-for-set_mempolicy_home_node-syscall.patch +Patch001: 0001-libnuma.c-Introduce-numa_preferred_err.patch +Patch002: 0002-doc-Update-man-for-numa_preferred_err.patch %description Simple NUMA policy support. It consists of a numactl program to run @@ -78,6 +80,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man3/*.3* %changelog +* Mon Apr 21 2025 Pingfan Liu - 2.0.19-2 +- Fix numa_preferred() returned value + * Mon Nov 18 2024 Pingfan Liu - 2.0.19-1 - Rebase to v2.0.19