diff --git a/0001-Fix-node_list-with-memory-less-nodes.patch b/0001-Fix-node_list-with-memory-less-nodes.patch deleted file mode 100644 index 700642e73de115abb00f217ea7e5b123d034cf6b..0000000000000000000000000000000000000000 --- a/0001-Fix-node_list-with-memory-less-nodes.patch +++ /dev/null @@ -1,32 +0,0 @@ -From cd7c78e77dc43fff5dbe2763f1ac83a8b4a6b1c7 Mon Sep 17 00:00:00 2001 -From: Harish -Date: Thu, 21 Jun 2018 07:53:10 +0530 -Subject: [PATCH 1/7] Fix: node_list with memory-less nodes - -Patch adds check to avoid memory-less nodes while traversing till -max node, and this also prevents nodes_to_use sysmalloc failure as -nodes_to_use is malloc'ed with numa_num_configured_nodes which -returns the number of nodes configured with memory. - -Signed-off-by: Harish -Signed-off-by: Pingfan Liu ---- - numademo.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/numademo.c b/numademo.c -index b01e995..90d8e84 100644 ---- a/numademo.c -+++ b/numademo.c -@@ -307,7 +307,7 @@ void get_node_list() - node_to_use = (int *)malloc(numnodes * sizeof(int)); - max_node = numa_max_node(); - for (a = 0; a <= max_node; a++) { -- if(numa_node_size(a, &free_node_sizes) != -1) -+ if (numa_node_size(a, &free_node_sizes) > 0) - node_to_use[got_nodes++] = a; - } - } --- -2.7.4 - diff --git a/0013-libnuma-make-numa_police_memory-free-of-race.patch b/0001-libnuma-make-numa_police_memory-free-of-race.patch similarity index 100% rename from 0013-libnuma-make-numa_police_memory-free-of-race.patch rename to 0001-libnuma-make-numa_police_memory-free-of-race.patch diff --git a/0002-numademo-fix-wrong-node-input.patch b/0002-numademo-fix-wrong-node-input.patch deleted file mode 100644 index 8d41d7b0a0d331003faab35389902af4d3764ad4..0000000000000000000000000000000000000000 --- a/0002-numademo-fix-wrong-node-input.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 2b190afdbbff875e519e4ae45390bdde11e8e190 Mon Sep 17 00:00:00 2001 -From: Harish -Date: Wed, 20 Jun 2018 18:46:55 +0530 -Subject: [PATCH 2/7] numademo: fix wrong node input - -In few sparse node systems, test fails with invalid argument at -set_mempolicy through numa_preferred_node. Patch fixes it by -providing a valid wrong node. - -Signed-off-by: Harish -Signed-off-by: Pingfan Liu ---- - numademo.c | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -diff --git a/numademo.c b/numademo.c -index 90d8e84..4d3c058 100644 ---- a/numademo.c -+++ b/numademo.c -@@ -298,7 +298,7 @@ int popcnt(unsigned long val) - - int max_node, numnodes; - --void get_node_list() -+int get_node_list() - { - int a, got_nodes = 0; - long free_node_sizes; -@@ -310,6 +310,9 @@ void get_node_list() - if (numa_node_size(a, &free_node_sizes) > 0) - node_to_use[got_nodes++] = a; - } -+ if(got_nodes != numnodes) -+ return -1; -+ return 0; - } - - void test(enum test type) -@@ -436,7 +439,7 @@ void test(enum test type) - numa_set_localalloc(); - memtest("local allocation", numa_alloc(msize)); - -- numa_set_preferred((node_to_use[i]+1) % numnodes ); -+ numa_set_preferred(node_to_use[(i + 1) % numnodes]); - memtest("setting wrong preferred node", numa_alloc(msize)); - numa_set_preferred(node_to_use[i]); - memtest("setting correct preferred node", numa_alloc(msize)); -@@ -512,7 +515,11 @@ int main(int ac, char **av) - if (!force) - exit(1); - } -- get_node_list(); -+ if(get_node_list()){ -+ fprintf(stderr, "Configured Nodes does not match available memory nodes\n"); -+ exit(1); -+ } -+ - printf("%d nodes available\n", numnodes); - fract_nodes = (((numnodes-1)/8)*2) + FRACT_NODES; - --- -2.7.4 - diff --git a/0002-shm.c-fix-memleak-in-dump_shm.patch b/0002-shm.c-fix-memleak-in-dump_shm.patch new file mode 100644 index 0000000000000000000000000000000000000000..76540d2d76ba7907f92f9b01c66d99b48bebd391 --- /dev/null +++ b/0002-shm.c-fix-memleak-in-dump_shm.patch @@ -0,0 +1,44 @@ +From 7b5f3e98680f0720f9e6d06b6acdcbf92af4aedd Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 10 Jun 2021 10:54:08 +0800 +Subject: [PATCH 2/6] shm.c: fix memleak in dump_shm() + +Signed-off-by: Pingfan Liu +--- + shm.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/shm.c b/shm.c +index 79043c9..c0b6ee3 100644 +--- a/shm.c ++++ b/shm.c +@@ -182,7 +182,7 @@ dumppol(unsigned long long start, unsigned long long end, int pol, struct bitmas + /* Dump policies in a shared memory segment. */ + void dump_shm(void) + { +- struct bitmask *nodes, *prevnodes; ++ struct bitmask *nodes, *prevnodes, *tag; + int prevpol = -1, pol; + unsigned long long c, start; + +@@ -193,7 +193,7 @@ void dump_shm(void) + } + + nodes = numa_allocate_nodemask(); +- prevnodes = numa_allocate_nodemask(); ++ tag = prevnodes = numa_allocate_nodemask(); + + for (c = 0; c < shmlen; c += shm_pagesize) { + if (get_mempolicy(&pol, nodes->maskp, nodes->size, c+shmptr, +@@ -208,6 +208,8 @@ void dump_shm(void) + start = c; + } + dumppol(start, c, prevpol, prevnodes); ++ numa_free_nodemask(nodes); ++ numa_free_nodemask(tag); + } + + static void dumpnode(unsigned long long start, unsigned long long end, int node) +-- +2.29.2 + diff --git a/0003-Fix-distance-test-to-include-all-existing-nodes.patch b/0003-Fix-distance-test-to-include-all-existing-nodes.patch deleted file mode 100644 index f8da28578452ca30192e1744f62e8bc478df4649..0000000000000000000000000000000000000000 --- a/0003-Fix-distance-test-to-include-all-existing-nodes.patch +++ /dev/null @@ -1,50 +0,0 @@ -From c465ca7ca41aa03e755ed71fa0281c620b0d8dc0 Mon Sep 17 00:00:00 2001 -From: Harish -Date: Thu, 21 Jun 2018 17:22:36 +0530 -Subject: [PATCH 3/7] Fix: distance test to include all existing nodes - -The previous implementation did not consider memory-less nodes as -numa_num_configured_nodes() returns only nodes with memory and -numa_node_size() check is unnecessary for distance check. Hence -removed the check for memory. - -Signed-off-by: Harish -Signed-off-by: Pingfan Liu ---- - test/distance.c | 11 +++++------ - 1 file changed, 5 insertions(+), 6 deletions(-) - -diff --git a/test/distance.c b/test/distance.c -index fca109f..3471db6 100644 ---- a/test/distance.c -+++ b/test/distance.c -@@ -5,21 +5,20 @@ - - int main(void) - { -- int numnodes, maxnode, a, b, got_nodes = 0; -+ int maxnode, a, b, got_nodes = 0; - int *node_to_use; -- long size, free_node_sizes; - if (numa_available() < 0) { - printf("no numa support in kernel\n"); - exit(1); - } -- numnodes = numa_num_configured_nodes(); - maxnode = numa_max_node(); -- node_to_use = (int *)malloc(numnodes * sizeof(int)); -+ node_to_use = (int *)malloc(maxnode * sizeof(int)); - for (a = 0; a <= maxnode; a++) { -- size = numa_node_size(a, &free_node_sizes); -- if(size != -1) -+ if (numa_bitmask_isbitset(numa_nodes_ptr, a)){ - node_to_use[got_nodes++] = a; -+ } - } -+ - for (a = 0; a < got_nodes; a++){ - printf("%03d: ", node_to_use[a]); - if (numa_distance(node_to_use[a], node_to_use[a]) != 10) { --- -2.7.4 - diff --git a/0003-shm.c-fix-memleak-in-verify_shm.patch b/0003-shm.c-fix-memleak-in-verify_shm.patch new file mode 100644 index 0000000000000000000000000000000000000000..53f6871f2a85e179843791de4f28742b5fec5113 --- /dev/null +++ b/0003-shm.c-fix-memleak-in-verify_shm.patch @@ -0,0 +1,60 @@ +From 8ae75219cc7a0dc69e77e22ba2547104078769d8 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 10 Jun 2021 11:06:07 +0800 +Subject: [PATCH 3/6] shm.c: fix memleak in verify_shm() + +Signed-off-by: Pingfan Liu +--- + shm.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/shm.c b/shm.c +index c0b6ee3..e5192e5 100644 +--- a/shm.c ++++ b/shm.c +@@ -273,8 +273,6 @@ void verify_shm(int policy, struct bitmask *nodes) + int pol2; + struct bitmask *nodes2; + +- nodes2 = numa_allocate_nodemask(); +- + if (policy == MPOL_INTERLEAVE) { + if (get_mempolicy(&ilnode, NULL, 0, shmptr, + MPOL_F_ADDR|MPOL_F_NODE) +@@ -282,6 +280,8 @@ void verify_shm(int policy, struct bitmask *nodes) + err("get_mempolicy"); + } + ++ nodes2 = numa_allocate_nodemask(); ++ + for (p = shmptr; p - (char *)shmptr < shmlen; p += shm_pagesize) { + if (get_mempolicy(&pol2, nodes2->maskp, nodes2->size, p, + MPOL_F_ADDR) < 0) +@@ -289,7 +289,7 @@ void verify_shm(int policy, struct bitmask *nodes) + if (pol2 != policy) { + vwarn(p, "wrong policy %s, expected %s\n", + policy_name(pol2), policy_name(policy)); +- return; ++ goto out; + } + if (memcmp(nodes2, nodes, numa_bitmask_nbytes(nodes))) { + vwarn(p, "mismatched node mask\n"); +@@ -307,7 +307,7 @@ void verify_shm(int policy, struct bitmask *nodes) + if (node != ilnode) { + vwarn(p, "expected interleave node %d, got %d\n", + ilnode,node); +- return; ++ goto out; + } + ilnode = interleave_next(ilnode, nodes2); + break; +@@ -325,4 +325,6 @@ void verify_shm(int policy, struct bitmask *nodes) + } + } + ++out: ++ numa_free_nodemask(nodes2); + } +-- +2.29.2 + diff --git a/0004-Fix-regress-test-numastat-function-and-few-test-fixe.patch b/0004-Fix-regress-test-numastat-function-and-few-test-fixe.patch deleted file mode 100644 index 84ab6f016633f36877f37087fb9b184b67ae889c..0000000000000000000000000000000000000000 --- a/0004-Fix-regress-test-numastat-function-and-few-test-fixe.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 09d294e8d83151fb76a7fc741bc6251c0b171e25 Mon Sep 17 00:00:00 2001 -From: Harish -Date: Wed, 27 Jun 2018 22:29:10 +0530 -Subject: [PATCH 4/7] Fix: regress test numastat function and few test fixes - -nstat function previously assumed node indexes to be contiguous -and get the numastat of the required statname. When run on a -machine with combinations of memory/memory-less nodes in a -non-contiguous way, the test fetches wrong stats and fails. This -patch finds the index of the given node and returns proper value. - -Signed-off-by: Harish -Signed-off-by: Pingfan Liu ---- - test/regress | 42 +++++++++++++++++++++--------------------- - 1 file changed, 21 insertions(+), 21 deletions(-) - -diff --git a/test/regress b/test/regress -index c0cf6d7..f06b22f 100755 ---- a/test/regress -+++ b/test/regress -@@ -47,9 +47,11 @@ failed() { - # nstat statname node - nstat() { - sleep $STAT_INTERVAL -+ nid=node$2 -+ id=`numastat | head -1 | awk -v node=$nid '{ for (i = 1; i <= NF; ++i) if($i==node) print i; exit }'` - declare -a fields - numastat | grep $1 | while read -a fields ; do -- echo ${fields[$[1 + $2]]} -+ echo ${fields[$id]} - done - } - -@@ -89,14 +91,13 @@ _test_process_state() { - test_process_state() - { - declare -i n0=${node[0]} n1=${node[1]} -- - _test_process_state --interleave=$n1 - -- a0=`nstat interleave_hit 0` -- a1=`nstat interleave_hit 1` -+ a0=`nstat interleave_hit $n0` -+ a1=`nstat interleave_hit $n1` - _test_process_state --interleave=$n0,$n1 -- b0=`nstat interleave_hit 0` -- b1=`nstat interleave_hit 1` -+ b0=`nstat interleave_hit $n0` -+ b1=`nstat interleave_hit $n1` - if [ $(expr $b1 - $a1) -lt $HALFPAGES ]; then - echo "interleaving test failed $n1 $b1 $a1" - failed -@@ -109,19 +110,18 @@ test_process_state() - _test_process_state --interleave=all - _test_process_state --membind=all - -- a=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1)) -+ a=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1)) - _test_process_state --membind=$n0,$n1 -- b=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1)) -+ b=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1)) - if [ $(expr $b - $a) -lt $PAGES ]; then - echo "membind test failed $n1 $b $a ($PAGES)" - failed - fi - -- for i in $(seq 0 $maxnode) ; do -- declare -i ni=${node[$i]} -+ for i in "${node[@]}" ; do - a=`nstat numa_hit $i` -- _test_process_state --membind=$ni -- _test_process_state --preferred=$ni -+ _test_process_state --membind=$i -+ _test_process_state --preferred=$i - b=`nstat numa_hit $i` - if [ $(expr $b - $a) -lt $DOUBLEPAGES ]; then - echo "membind/preferred on node $ni failed $b $a" -@@ -143,11 +143,11 @@ test_mbind() - { - declare -i n0=${node[0]} n1=${node[1]} - -- a0=`nstat interleave_hit 0` -- a1=`nstat interleave_hit 1` -+ a0=`nstat interleave_hit $n0` -+ a1=`nstat interleave_hit $n1` - _test_mbind interleave $n0,$n1 -- b0=`nstat interleave_hit 0` -- b1=`nstat interleave_hit 1` -+ b0=`nstat interleave_hit $n0` -+ b1=`nstat interleave_hit $n1` - if [ $(expr $b1 - $a1) -lt $HALFPAGES ]; then - echo "interleaving test 2 failed $n1 $b1 $a1 expected $HALFPAGES" - failed -@@ -159,19 +159,19 @@ test_mbind() - - _test_mbind interleave all - -- a=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1)) -+ a=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1)) - _test_mbind membind $n0,$n1 -- b=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1)) -+ b=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1)) - if [ $(expr $b - $a) -lt $PAGES ]; then - echo "membind test 2 failed $b $a ($PAGES)" - failed - fi - -- for i in $(seq 0 $maxnode) ; do -+ for i in "${node[@]}" ; do - declare -i ni=${node[$i]} - a=`nstat numa_hit $i` -- _test_mbind membind $ni -- _test_mbind preferred $ni -+ _test_mbind membind $i -+ _test_mbind preferred $i - b=`nstat numa_hit $i` - if [ $(expr $b - $a) -lt $DOUBLEPAGES ]; then - echo "membind/preferred test 2 on node $ni failed $b $a" --- -2.7.4 - diff --git a/0004-sysfs.c-don-t-leak-fd-if-fail-in-sysfs_read.patch b/0004-sysfs.c-don-t-leak-fd-if-fail-in-sysfs_read.patch new file mode 100644 index 0000000000000000000000000000000000000000..08b8840ec9c7160f3751327684c1aec81a843893 --- /dev/null +++ b/0004-sysfs.c-don-t-leak-fd-if-fail-in-sysfs_read.patch @@ -0,0 +1,29 @@ +From dfca78c8ee1d21d967b3a51d5488a8e8cd818ec4 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 10 Jun 2021 11:13:59 +0800 +Subject: [PATCH 4/6] sysfs.c: don't leak fd if fail in sysfs_read() + +Signed-off-by: Pingfan Liu +--- + sysfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysfs.c b/sysfs.c +index f1cdcdc..9ddf50d 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -17,10 +17,10 @@ hidden char *sysfs_read(char *name) + int n; + int fd; + +- fd = open(name, O_RDONLY); + buf = malloc(SYSFS_BLOCK); + if (!buf) + return NULL; ++ fd = open(name, O_RDONLY); + n = read(fd, buf, SYSFS_BLOCK - 1); + close(fd); + if (n <= 0) { +-- +2.29.2 + diff --git a/0005-Correct-calculation-of-nr_nodes-and-re-enable-move_p.patch b/0005-Correct-calculation-of-nr_nodes-and-re-enable-move_p.patch deleted file mode 100644 index 7f6a81933d855220d700c0dec19c1648d6fe8d9e..0000000000000000000000000000000000000000 --- a/0005-Correct-calculation-of-nr_nodes-and-re-enable-move_p.patch +++ /dev/null @@ -1,48 +0,0 @@ -From d1bc1653b3f86b8951b876946a94db681764fa2a Mon Sep 17 00:00:00 2001 -From: Filipe Brandenburger -Date: Fri, 15 Jun 2018 14:16:23 -0700 -Subject: [PATCH 5/7] Correct calculation of nr_nodes and re-enable move_pages - test - -This was pointed out by @bjsprakash in #8. - -After the bug is corrected, we can re-enable the test in `make check`, -since most machines these days will have at least two nodes by default. - -Travis-CI still fails with this test (one node only available), so keep -skipping it there. - -Signed-off-by: Pingfan Liu ---- - Makefile.am | 1 + - test/move_pages.c | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 03b0ab6..1c4266d 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -134,6 +134,7 @@ TESTS = \ - test/checkaffinity \ - test/checktopology \ - test/distance \ -+ test/move_pages \ - test/nodemap \ - test/numademo \ - test/regress \ -diff --git a/test/move_pages.c b/test/move_pages.c -index 87d9b3e..c5010e2 100644 ---- a/test/move_pages.c -+++ b/test/move_pages.c -@@ -28,7 +28,7 @@ int main(int argc, char **argv) - - pagesize = getpagesize(); - -- nr_nodes = numa_max_node(); -+ nr_nodes = numa_max_node() + 1; - - if (nr_nodes < 2) { - printf("A minimum of 2 nodes is required for this test.\n"); --- -2.7.4 - diff --git a/0005-sysfs.c-prevent-mem-leak-in-sysfs_node_read.patch b/0005-sysfs.c-prevent-mem-leak-in-sysfs_node_read.patch new file mode 100644 index 0000000000000000000000000000000000000000..3d04f42b96a7d48bbbd0b2cf0bf19ba7f319e365 --- /dev/null +++ b/0005-sysfs.c-prevent-mem-leak-in-sysfs_node_read.patch @@ -0,0 +1,60 @@ +From cc1d7d17c6d2df0f603932becf238fdf264a9e30 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 10 Jun 2021 11:17:40 +0800 +Subject: [PATCH 5/6] sysfs.c: prevent mem leak in sysfs_node_read() + +Signed-off-by: Pingfan Liu +--- + sysfs.c | 23 +++++++++++++++-------- + 1 file changed, 15 insertions(+), 8 deletions(-) + +diff --git a/sysfs.c b/sysfs.c +index 9ddf50d..a35c4b5 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -33,7 +33,7 @@ hidden char *sysfs_read(char *name) + + hidden int sysfs_node_read(struct bitmask *mask, char *fmt, ...) + { +- int n; ++ int n, ret = 0; + va_list ap; + char *p, *fn, *m, *end; + int num; +@@ -51,12 +51,18 @@ hidden int sysfs_node_read(struct bitmask *mask, char *fmt, ...) + m = p; + do { + num = strtol(m, &end, 0); +- if (m == end) +- return -1; +- if (num < 0) +- return -2; +- if (num >= numa_num_task_nodes()) +- return -1; ++ if (m == end) { ++ ret = -1; ++ goto out; ++ } ++ if (num < 0) { ++ ret = -2; ++ goto out; ++ } ++ if (num >= numa_num_task_nodes()) { ++ ret = -1; ++ goto out; ++ } + numa_bitmask_setbit(mask, num); + + /* Continuation not supported by kernel yet. */ +@@ -64,6 +70,7 @@ hidden int sysfs_node_read(struct bitmask *mask, char *fmt, ...) + while (isspace(*m) || *m == ',') + m++; + } while (isdigit(*m)); ++out: + free(p); +- return 0; ++ return ret; + } +-- +2.29.2 + diff --git a/0006-Fix-move_pages-test-for-non-contiguous-nodes.patch b/0006-Fix-move_pages-test-for-non-contiguous-nodes.patch deleted file mode 100644 index 22be346490e45fcfb9f12645aef800bba6e77b55..0000000000000000000000000000000000000000 --- a/0006-Fix-move_pages-test-for-non-contiguous-nodes.patch +++ /dev/null @@ -1,83 +0,0 @@ -From bad479d2fe1075cfc83ffbd4ad39bcc6e800e7ca Mon Sep 17 00:00:00 2001 -From: Harish -Date: Thu, 5 Jul 2018 12:08:33 +0530 -Subject: [PATCH 6/7] Fix: move_pages test for non-contiguous nodes - -Patch fixes move_pages test for non-contiguous memory nodes and -distributed pages among existing memory nodes instead of assuming -continuous node IDs. - -Signed-off-by: Harish -Signed-off-by: Pingfan Liu ---- - test/move_pages.c | 28 +++++++++++++++++++++++++--- - 1 file changed, 25 insertions(+), 3 deletions(-) - -diff --git a/test/move_pages.c b/test/move_pages.c -index c5010e2..4b207e8 100644 ---- a/test/move_pages.c -+++ b/test/move_pages.c -@@ -21,6 +21,24 @@ int *status; - int *nodes; - int errors; - int nr_nodes; -+int *node_to_use; -+ -+int get_node_list() -+{ -+ int a, got_nodes = 0, max_node, numnodes; -+ long free_node_sizes; -+ -+ numnodes = numa_num_configured_nodes(); -+ node_to_use = (int *)malloc(numnodes * sizeof(int)); -+ max_node = numa_max_node(); -+ for (a = 0; a <= max_node; a++) { -+ if (numa_node_size(a, &free_node_sizes) > 0) -+ node_to_use[got_nodes++] = a; -+ } -+ if(got_nodes != numnodes) -+ return -1; -+ return got_nodes; -+} - - int main(int argc, char **argv) - { -@@ -28,12 +46,16 @@ int main(int argc, char **argv) - - pagesize = getpagesize(); - -- nr_nodes = numa_max_node() + 1; -+ nr_nodes = get_node_list(); - - if (nr_nodes < 2) { - printf("A minimum of 2 nodes is required for this test.\n"); - exit(1); - } -+ if (nr_nodes == -1) { -+ printf("Mismatch between congfigured nodes and memory-rich nodes.\n"); -+ exit(1); -+ } - - setbuf(stdout, NULL); - printf("move_pages() test ......\n"); -@@ -58,7 +80,7 @@ int main(int argc, char **argv) - /* We leave page 2 unallocated */ - pages[ i * pagesize ] = (char) i; - addr[i] = pages + i * pagesize; -- nodes[i] = (i % nr_nodes); -+ nodes[i] = node_to_use[(i % nr_nodes)]; - status[i] = -123; - } - -@@ -82,7 +104,7 @@ int main(int argc, char **argv) - if (i != 2) { - if (pages[ i* pagesize ] != (char) i) - errors++; -- else if (nodes[i] != (i % nr_nodes)) -+ else if (nodes[i] != node_to_use[(i % nr_nodes)]) - errors++; - } - } --- -2.7.4 - diff --git a/0006-numactl.c-fix-use-after-free.patch b/0006-numactl.c-fix-use-after-free.patch new file mode 100644 index 0000000000000000000000000000000000000000..8832709ba2a700d3384237aa73907a1be9371be2 --- /dev/null +++ b/0006-numactl.c-fix-use-after-free.patch @@ -0,0 +1,30 @@ +From 498385e3aaf265d6e9786e0a391196cd82ab3260 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Fri, 18 Jun 2021 18:14:20 +0800 +Subject: [PATCH 6/6] numactl.c: fix use after free + +The following command can trigger the bug + numactl --length 65536 --shm xxx -p0 -V > /dev/null + +So reset mask to block any new access inside this loop. + +Signed-off-by: Pingfan Liu +--- + numactl.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/numactl.c b/numactl.c +index 5a9d2df..ae41d6c 100644 +--- a/numactl.c ++++ b/numactl.c +@@ -544,6 +544,7 @@ int main(int ac, char **av) + if (nnodes != 1) + usage(); + numa_bitmask_free(mask); ++ mask = NULL; + errno = 0; + did_node_cpu_parse = 1; + numa_set_bind_policy(0); +-- +2.29.2 + diff --git a/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch b/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch deleted file mode 100644 index e18c7786cd8e509a3e06af736e66dbf14e9ac603..0000000000000000000000000000000000000000 --- a/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch +++ /dev/null @@ -1,39 +0,0 @@ -From a8f5ed65b745f96f5e5af72bace8e7c63b96fd4e Mon Sep 17 00:00:00 2001 -From: Sanskriti Sharma -Date: Thu, 13 Sep 2018 10:01:58 -0400 -Subject: [PATCH 7/7] Fix: Add ShmemHugePages and ShmemPmdMapped to - system_meminfo[] - -ShmemHugePages and ShmemPmdMapped were recently added to -/sys/devices/system/node/node*/meminfo. Adding entries for them in the -system_meminfo data structure got rid of the error "Token Node not in hash -table." - -Signed-off-by: Sanskriti Sharma -Signed-off-by: Pingfan Liu ---- - numastat.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/numastat.c b/numastat.c -index 92d8496..25874db 100644 ---- a/numastat.c -+++ b/numastat.c -@@ -122,9 +122,11 @@ meminfo_t system_meminfo[] = { - { 27, "SReclaimable", "SReclaimable" }, - { 28, "SUnreclaim", "SUnreclaim" }, - { 29, "AnonHugePages", "AnonHugePages" }, -- { 30, "HugePages_Total", "HugePages_Total" }, -- { 31, "HugePages_Free", "HugePages_Free" }, -- { 32, "HugePages_Surp", "HugePages_Surp" } -+ { 30, "ShmemHugePages", "ShmemHugePages" }, -+ { 31, "ShmemPmdMapped", "ShmemPmdMapped" }, -+ { 32, "HugePages_Total", "HugePages_Total" }, -+ { 33, "HugePages_Free", "HugePages_Free" }, -+ { 34, "HugePages_Surp", "HugePages_Surp" } - }; - - #define SYSTEM_MEMINFO_ROWS (sizeof(system_meminfo) / sizeof(system_meminfo[0])) --- -2.7.4 - diff --git a/0008-memhog-add-man-page.patch b/0008-memhog-add-man-page.patch deleted file mode 100644 index c23877f6519e514e47fcfefdc921801574167b96..0000000000000000000000000000000000000000 --- a/0008-memhog-add-man-page.patch +++ /dev/null @@ -1,88 +0,0 @@ -From ffbc7a05e1777f4a2b3096483519fe5096ecc716 Mon Sep 17 00:00:00 2001 -From: Sanskriti Sharma -Date: Tue, 20 Nov 2018 10:22:06 -0500 -Subject: [PATCH] memhog: add man page - -Signed-off-by: Sanskriti Sharma ---- - memhog.8 | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 68 insertions(+) - create mode 100644 memhog.8 - -diff --git a/memhog.8 b/memhog.8 -new file mode 100644 -index 0000000..e28e784 ---- /dev/null -+++ b/memhog.8 -@@ -0,0 +1,68 @@ -+.TH MEMHOG 8 "2003,2004" "SuSE Labs" "Linux Administrator's Manual" -+.SH NAME -+memhog \- Allocates memory with policy for testing -+.SH SYNOPSIS -+.B memhog -+[ -+.B \-r -+] [ -+.B size kmg -+] [ -+.B policy nodeset -+] [ -+.B \-f -+] -+.SH DESCRIPTION -+.B memhog -+mmaps a memory region for a given size and sets the numa policy (if specified). -+It then updates the memory region for the given number of iterations using memset. -+.TS -+tab(|); -+l l. -+-r|Repeat memset NUM times -+-f|Open file for mmap backing -+-H|Disable transparent hugepages -+-size|Allocation size in bytes, may have case-insensitive order -+|suffix (G=gigabyte, M=megabyte, K=kilobyte) -+.TE -+ -+Supported numa-policies: -+.TP -+.B interleave -+Memory will be allocated using round robin on nodes. When -+memory cannot be allocated on the current interleave, target fall back -+to other nodes. Multiple nodes may be specified. -+.TP -+.B membind -+Only allocate memory from nodes. Allocation will fail -+when there is not enough memory available on these nodes. Multiple -+nodes may be specified. -+.TP -+.B preferred -+Preferably allocate memory on node, but if memory cannot be -+allocated there fall back to other nodes. This option takes only a -+single node number. -+.TP -+.B default -+Memory will be allocated on the local node (the node the -+thread is running on) -+ -+.SH EXAMPLES -+.TP -+# Allocate a 1G region, mmap backed by memhog.mmap file, membind to node 0, repeat test 6 times -+memhog -r6 1G --membind 0 -fmemhog.mmap -+.TP -+# Allocate a 1G region, iterleave across nodes 0,1,2,3, repeat test 4 times -+memhog -r4 1G --interleave 0-3 -+.TP -+# Allocate a 1G region, (implicit) default policy, repeat test 8 times -+memhog -r8 1G -+ -+.SH AUTHORS -+Andi Kleen (ak@suse.de) -+ -+.SH LICENSE -+GPL v2 -+ -+.SH SEE ALSO -+.I mmap(2), memset(3), numactl(8), numastat(8) --- -2.7.5 - diff --git a/0009-numastat.8-clarify-that-information-relates-to-resid.patch b/0009-numastat.8-clarify-that-information-relates-to-resid.patch deleted file mode 100644 index f8dcc6d2ffebb43642972891d89a8b62005d0ad0..0000000000000000000000000000000000000000 --- a/0009-numastat.8-clarify-that-information-relates-to-resid.patch +++ /dev/null @@ -1,33 +0,0 @@ -From c2b0a955a415c104be0fa1b3118f48f726fd23ea Mon Sep 17 00:00:00 2001 -From: Stefan Hajnoczi -Date: Tue, 9 Jul 2019 16:10:46 +0200 -Subject: [PATCH] numastat.8: clarify that information relates to resident - pages - -The man page gives no hint about whether memory usage information -relates to resident pages or virtual memory. The answer may not be -obvious to the user, so explicitly mention that only resident pages are -counted. - -Suggested-by: Daniele Palumbo -Signed-off-by: Stefan Hajnoczi ---- - numastat.8 | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/numastat.8 b/numastat.8 -index 4dcddf3..7fbcab2 100644 ---- a/numastat.8 -+++ b/numastat.8 -@@ -54,6 +54,8 @@ Any supplied options or arguments with the \fBnumastat\fP command will - significantly change both the content and the format of the display. Specified - options will cause display units to change to megabytes of memory, and will - change other specific behaviors of \fBnumastat\fP as described below. -+.LP -+Memory usage information reflects the resident pages on the system. - .SH "OPTIONS" - .LP - .TP --- -2.7.5 - diff --git a/0010-Fix-crashes-when-using-the-touch-option.patch b/0010-Fix-crashes-when-using-the-touch-option.patch deleted file mode 100644 index 5545619214a4f8e0e68f86b6af4f57a33d07511f..0000000000000000000000000000000000000000 --- a/0010-Fix-crashes-when-using-the-touch-option.patch +++ /dev/null @@ -1,46 +0,0 @@ -From a47463a72864a76b0557468daf83741632ea4d72 Mon Sep 17 00:00:00 2001 -From: Patrick Mansfield -Date: Mon, 30 Sep 2019 15:59:53 -0700 -Subject: [PATCH] Fix crashes when using the "--touch" option. - -Fix memory to be mapped read/write, so that the "touch" option can write to it. - -Signed-off-by: Patrick Mansfield ---- - shm.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/shm.c b/shm.c -index 260eeff..fb592ed 100644 ---- a/shm.c -+++ b/shm.c -@@ -119,7 +119,7 @@ void attach_sysvshm(char *name, char *opt) - shmlen = s.shm_segsz; - } - -- shmptr = shmat(shmfd, NULL, SHM_RDONLY); -+ shmptr = shmat(shmfd, NULL, 0); - if (shmptr == (void*)-1) - err("shmat"); - shmptr += shmoffset; -@@ -134,7 +134,7 @@ void attach_shared(char *name, char *opt) - { - struct stat64 st; - -- shmfd = open(name, O_RDONLY); -+ shmfd = open(name, O_RDWR); - if (shmfd < 0) { - errno = 0; - if (shmlen == 0) -@@ -160,7 +160,7 @@ void attach_shared(char *name, char *opt) - - /* RED-PEN For shmlen > address space may need to map in pieces. - Left for some poor 32bit soul. */ -- shmptr = mmap64(NULL, shmlen, PROT_READ, MAP_SHARED, shmfd, shmoffset); -+ shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset); - if (shmptr == (char*)-1) - err("shm mmap"); - --- -2.7.5 - diff --git a/0011-Added-memhog.8-to-Makefile.am.patch b/0011-Added-memhog.8-to-Makefile.am.patch deleted file mode 100644 index e18fda9649244f9f4da08e6cef3ea90cb4985080..0000000000000000000000000000000000000000 --- a/0011-Added-memhog.8-to-Makefile.am.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 6a41846f3191afe48144481bbfa2fd4edafdc8d5 Mon Sep 17 00:00:00 2001 -From: Sanskriti Sharma -Date: Wed, 21 Nov 2018 10:28:44 -0500 -Subject: [PATCH] Added memhog.8 to Makefile.am Signed-off-by: Sanskriti Sharma - - ---- - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 1c4266d..ab61d42 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -12,7 +12,7 @@ include_HEADERS = numa.h numacompat1.h numaif.h - - noinst_HEADERS = numaint.h util.h - --dist_man_MANS = move_pages.2 numa.3 numactl.8 numastat.8 migratepages.8 migspeed.8 -+dist_man_MANS = move_pages.2 numa.3 numactl.8 numastat.8 migratepages.8 migspeed.8 memhog.8 - - EXTRA_DIST = README.md INSTALL.md - --- -2.7.5 - diff --git a/0012-Update-manpage-description-of-localalloc-option.patch b/0012-Update-manpage-description-of-localalloc-option.patch deleted file mode 100644 index 53b47c6314682242ad6d135a4bfd0afecb798918..0000000000000000000000000000000000000000 --- a/0012-Update-manpage-description-of-localalloc-option.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 26fba7199c365b55e72e054bb2adba097ce04924 Mon Sep 17 00:00:00 2001 -From: Seeteena Thoufeek -Date: Wed, 8 Jan 2020 14:39:01 +0530 -Subject: [PATCH] Update manpage description of --localalloc option - -Signed-off-by: Seeteena Thoufeek ---- - numactl.8 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/numactl.8 b/numactl.8 -index 7a001c0..f3bb22b 100644 ---- a/numactl.8 -+++ b/numactl.8 -@@ -159,7 +159,7 @@ A !N-N notation indicates the inverse of N-N, in other words all cpus - except N-N. If used with + notation, specify !+N-N. - .TP - .B \-\-localalloc, \-l --Always allocate on the current node. -+Try to allocate on the current node of the process, but if memory cannot be allocated there fall back to other nodes. - .TP - .B \-\-preferred=node - Preferably allocate memory on --- -2.7.5 - diff --git a/numactl-2.0.12.tar.gz b/numactl-2.0.12.tar.gz deleted file mode 100644 index 55db787b172ec65aa7c00fe66aa09655b229b98a..0000000000000000000000000000000000000000 Binary files a/numactl-2.0.12.tar.gz and /dev/null differ diff --git a/numactl-2.0.14.tar.gz b/numactl-2.0.14.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..17fe3d394343fdc123830174b7442cb92c40f506 Binary files /dev/null and b/numactl-2.0.14.tar.gz differ diff --git a/numactl.spec b/numactl.spec index bbc90cb5d31d3e6528c023f5db9f25791a1d7088..5d2c9e5e302c9f8622369c7fb9cbde0058679931 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,14 +1,15 @@ +%define anolis_release .0.1 Name: numactl Summary: Library for tuning for Non Uniform Memory Access machines -Version: 2.0.12 -Release: 13%{?dist} +Version: 2.0.14 +Release: 8%{anolis_release}%{dist} # libnuma is LGPLv2 and GPLv2 # numactl binaries are GPLv2 only License: GPLv2 -Group: System Environment/Base URL: https://github.com/numactl/numactl -Source0: https://github.com/numactl/numactl/releases/download/%{version}/numactl-%{version}.tar.gz -Buildroot: %{_tmppath}/%{name}-buildroot +Source0: %{url}/releases/download/v%{version}/%{name}-%{version}.tar.gz + +BuildRequires: make BuildRequires: libtool automake autoconf ExcludeArch: s390 %{arm} @@ -37,20 +38,12 @@ ExcludeArch: s390 %{arm} # # Patches 601 onward are generic patches # -Patch601 :0001-Fix-node_list-with-memory-less-nodes.patch -Patch602 :0002-numademo-fix-wrong-node-input.patch -Patch603 :0003-Fix-distance-test-to-include-all-existing-nodes.patch -Patch604 :0004-Fix-regress-test-numastat-function-and-few-test-fixe.patch -Patch605 :0005-Correct-calculation-of-nr_nodes-and-re-enable-move_p.patch -Patch606 :0006-Fix-move_pages-test-for-non-contiguous-nodes.patch -Patch607 :0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch -Patch608 :0008-memhog-add-man-page.patch -Patch609: 0009-numastat.8-clarify-that-information-relates-to-resid.patch -Patch610: 0010-Fix-crashes-when-using-the-touch-option.patch -Patch611: 0011-Added-memhog.8-to-Makefile.am.patch -Patch612: 0012-Update-manpage-description-of-localalloc-option.patch -Patch613: 0013-libnuma-make-numa_police_memory-free-of-race.patch - +Patch601: 0001-libnuma-make-numa_police_memory-free-of-race.patch +Patch602: 0002-shm.c-fix-memleak-in-dump_shm.patch +Patch603: 0003-shm.c-fix-memleak-in-verify_shm.patch +Patch604: 0004-sysfs.c-don-t-leak-fd-if-fail-in-sysfs_read.patch +Patch605: 0005-sysfs.c-prevent-mem-leak-in-sysfs_node_read.patch +Patch606: 0006-numactl.c-fix-use-after-free.patch %description @@ -61,7 +54,6 @@ other programs with a specific NUMA policy. Summary: libnuma libraries # There is a tiny bit of GPLv2 code in libnuma.c License: LGPLv2 and GPLv2 -Group: System Environment/Libraries %description libs numactl-libs provides libnuma, a library to do allocations with @@ -69,51 +61,42 @@ NUMA policy in applications. %package devel Summary: Development package for building Applications that use numa -Group: System Environment/Libraries Requires: %{name}-libs = %{version}-%{release} License: LGPLv2 and GPLv2 %description devel Provides development headers for numa library calls +%package doc +Summary: Documents for %{name} +BuildArch: noarch +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} + +%description doc +Doc pages for %{name}. + %prep -%setup -q -n %{name}-%{version} +%autosetup #patch -%patch601 -p1 -%patch602 -p1 -%patch603 -p1 -%patch604 -p1 -%patch605 -p1 -%patch606 -p1 -%patch607 -p1 -%patch608 -p1 -%patch609 -p1 -%patch610 -p1 -%patch611 -p1 -%patch612 -p1 -%patch613 -p1 - +#%patch601 -p1 %build -aclocal && automake %configure --prefix=/usr --libdir=%{_libdir} -make clean -make CFLAGS="$RPM_OPT_FLAGS -I." +# Using recipe to fix rpaths, from here: +# https://fedoraproject.org/wiki/RPath_Packaging_Draft#Removing_Rpath +sed -i -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \ + -e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool +%make_build %install rm -rf $RPM_BUILD_ROOT +%make_install -make DESTDIR=$RPM_BUILD_ROOT install - -%post -p /sbin/ldconfig -%post libs -p /sbin/ldconfig - -%postun -p /sbin/ldconfig -%postun libs -p /sbin/ldconfig +%ldconfig_scriptlets +%ldconfig_scriptlets libs %files -%doc README.md %{_bindir}/numactl %{_bindir}/numademo %{_bindir}/numastat @@ -129,35 +112,75 @@ make DESTDIR=$RPM_BUILD_ROOT install %files devel %{_libdir}/libnuma.so -%{_libdir}/pkgconfig/numa.pc %exclude %{_libdir}/libnuma.a %exclude %{_libdir}/libnuma.la +%{_libdir}/pkgconfig/numa.pc %{_includedir}/numa.h %{_includedir}/numaif.h %{_includedir}/numacompat1.h %{_mandir}/man3/*.3* +%files doc +%doc README.md + %changelog -* Wed May 12 2021 Pingfan Liu - 2.0.12-13 +* Mon Nov 28 2022 Bo Ren - 2.0.14-8.0.1 +- Add doc sub package + +* Tue Jan 4 2022 Pingfan Liu - 2.0.14-8 +- For GA release + +* Mon Aug 09 2021 Mohan Boddu - 2.0.14-7 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Tue Jul 6 2021 Pingfan Liu - 2.0.14-6 +- fix covscan complain + +* Mon May 24 2021 Pingfan Liu - 2.0.14-5 - libnuma: make numa_police_memory() free of race -* Sat May 9 2020 Pingfan Liu - 2.0.12-11 -- Update manpage description of --localalloc option +* Fri Apr 16 2021 Mohan Boddu - 2.0.14-4 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Tue Jan 26 2021 Fedora Release Engineering - 2.0.14-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Nov 11 2020 Florian Weimer - 2.0.14-2 +- Trigger rebuild to avoid DT_INIT/DT_FINI with zero values + +* Thu Sep 17 2020 Filipe Brandenburger - 2.0.14-1 +- Upgrade to 2.0.14 +- Re-enabled LTO, now that upstream has been fixed to support it. + +* Tue Jul 28 2020 Fedora Release Engineering - 2.0.12-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jul 01 2020 Jeff Law - 2.0.12-5 +- Disable LTO + +* Wed Jan 29 2020 Fedora Release Engineering - 2.0.12-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 2.0.12-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild -* Fri Mar 13 2020 Pingfan Liu - 2.0.12-10 -- memhog : add man page +* Fri Feb 01 2019 Fedora Release Engineering - 2.0.12-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild -* Mon Apr 1 2019 Pingfan Liu - 2.0.12-3 -- add gating test cases +* Wed Jul 25 2018 Filipe Brandenburger - 2.0.12-1 +- Rebased to version 2.0.12 -* Mon Nov 26 2018 Pingfan Liu - 2.0.12-2 -- Fix: Add ShmemHugePages and ShmemPmdMapped to system_meminfo[] +* Wed Jul 25 2018 Filipe Brandenburger +- Fix check-rpaths warning about including /usr/lib64 in RPATH of the binaries. -* Mon Nov 5 2018 Pingfan Liu - 2.0.12-1 -- Rebase to 2.0.12 +* Fri Jul 13 2018 Fedora Release Engineering - 2.0.11-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild -* Fri Aug 10 2018 Lianbo Jiang - 2.0.11-8%{dist} -- Fix compilation error (bz1611734) +* Sat Mar 24 2018 Richard W.M. Jones - 2.0.11-9%{dist} +- Fix major/minor macros on glibc 2.27. +- Update config.{guess,sub} with versions which understand riscv64. +- Remove obsolete Buildroot tag. * Sat Feb 24 2018 Florian Weimer - 2.0.11-8%{dist} - Use LDFLAGS from redhat-rpm-config