numactl.c: Fix merging of neighboring pages' policies in dump_shm

In addition to checking that the policies are equal, also check that
the nodes are equal, since the policies may be the same but apply to
different nodes.

Fixes #170
This commit is contained in:
buque 2023-06-19 20:26:20 +08:00
parent 214d7b07a5
commit 229e261e91
3 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From c09fefddf5474b393f262f92659134355d98c550 Mon Sep 17 00:00:00 2001
From: Honggyu Kim <honggyu.kp@gmail.com>
Date: Sat, 24 Dec 2022 03:19:14 +0000
Subject: [PATCH] numactl.c: Remove unused variable
This patch is to remove the following unused variable warning.
numactl.c: In function 'main':
numactl.c:425:14: warning: unused variable 'node' [-Wunused-variable]
425 | long node=-1;
| ^~~~
Since node is used nowhere inside the function so remove it.
Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>
Signed-off-by: buque <wuxu.wu@huawei.com>
---
numactl.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/numactl.c b/numactl.c
index 79b323b..47cbf39 100755
--- a/numactl.c
+++ b/numactl.c
@@ -422,7 +422,6 @@ static struct bitmask *numactl_parse_nodestring(char *s, int flag)
int main(int ac, char **av)
{
int c;
- long node=-1;
char *end;
char shortopts[array_len(opts)*2 + 1];
struct bitmask *mask = NULL;
--
2.33.0

View File

@ -0,0 +1,39 @@
From 6587ed2e4b8ce6d1eb0812f89709101f2bfdd1f1 Mon Sep 17 00:00:00 2001
From: Ackerley Tng <ackerleytng@google.com>
Date: Wed, 15 Mar 2023 00:23:14 +0000
Subject: [PATCH] numactl.c: Fix merging of neighboring pages' policies in
dump_shm
In addition to checking that the policies are equal, also check that
the nodes are equal, since the policies may be the same but apply to
different nodes.
Fixes #170
Signed-off-by: buque <wuxu.wu@huawei.com>
---
shm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/shm.c b/shm.c
index 5d0d1ab..66dbea4 100644
--- a/shm.c
+++ b/shm.c
@@ -205,11 +205,12 @@ void dump_shm(void)
if (get_mempolicy(&pol, nodes->maskp, nodes->size, c+shmptr,
MPOL_F_ADDR) < 0)
err("get_mempolicy on shm");
- if (pol == prevpol)
+ if (pol == prevpol && numa_bitmask_equal(prevnodes, nodes))
continue;
if (prevpol != -1)
dumppol(start, c, prevpol, prevnodes);
- prevnodes = nodes;
+
+ copy_bitmask_to_bitmask(nodes, prevnodes);
prevpol = pol;
start = c;
}
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: numactl
Version: 2.0.16
Release: 4
Release: 5
Summary: Library for tuning for Non Uniform Memory Access machines
License: GPLv2
URL: https://github.com/numactl/numactl
@ -11,6 +11,8 @@ 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
Patch0005: 0005-numactl.c-Remove-unused-variable.patch
Patch0006: 0006-numactl.c-Fix-merging-of-neighboring-pages-policies-.patch
%description
Simple NUMA policy support. It consists of a numactl program to run other
@ -79,6 +81,9 @@ LD_LIBRARY_PATH=$(pwd)/.libs make check
%{_mandir}/man3/*.3*
%changelog
* Mon Jun 19 2023 wuxu <wuxu.wu@huawei.com> - 2.0.16-5
- numactl.c: Fix merging of neighboring pages' policies in dump_shm and remove unused variable
* Mon Jun 19 2023 wuxu <wuxu.wu@huawei.com> - 2.0.16-4
- fix wrong nodemask_sz when CONFIG_NODES_SHIFT is less than 5