Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package numactl for openSUSE:Factory checked in at 2022-05-14 22:54:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/numactl (Old) and /work/SRC/openSUSE:Factory/.numactl.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "numactl" Sat May 14 22:54:38 2022 rev:68 rq:976992 version:2.0.14.39.g8b18345 Changes: -------- --- /work/SRC/openSUSE:Factory/numactl/numactl.changes 2021-09-03 21:25:34.578137235 +0200 +++ /work/SRC/openSUSE:Factory/.numactl.new.1538/numactl.changes 2022-05-14 22:54:41.455180533 +0200 @@ -1,0 +2,15 @@ +Tue May 10 09:48:02 UTC 2022 - moritz.kody...@suse.com + +- Update to version 2.0.14.39.g8b18345: + * numa(3): Fix typos and punctuation + * Avoid libnuma.so dependency on util.o + * test/prefered: add test cases for new 'preferred-many' policy + * test/prefered: fix compiling problem + * numa(3): Update the man page + * Update to support multiple nodes + * numademo: Add a new test for multiple-preferred-nodes policy + * numactl: Simplify preferred selection + * libnuma: Export interface to set/get preferred nodes + * util: Add new preferred-many type + +------------------------------------------------------------------- Old: ---- numactl-2.0.14.20.g4ee5e0c.obscpio New: ---- numactl-2.0.14.39.g8b18345.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ numactl.spec ++++++ --- /var/tmp/diff_new_pack.EE2SH9/_old 2022-05-14 22:54:42.027181247 +0200 +++ /var/tmp/diff_new_pack.EE2SH9/_new 2022-05-14 22:54:42.031181253 +0200 @@ -1,7 +1,7 @@ # # spec file for package numactl # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: numactl -Version: 2.0.14.20.g4ee5e0c +Version: 2.0.14.39.g8b18345 Release: 0 Summary: NUMA Policy Control License: GPL-2.0-only ++++++ numactl-2.0.14.20.g4ee5e0c.obscpio -> numactl-2.0.14.39.g8b18345.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/.gitignore new/numactl-2.0.14.39.g8b18345/.gitignore --- old/numactl-2.0.14.20.g4ee5e0c/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.14.39.g8b18345/.gitignore 2022-02-25 20:18:46.000000000 +0100 @@ -0,0 +1,64 @@ +# Object files: +*.o +*.lo + +# Auxiliary build files: +.deps +.libs +.dirstamp + +# libnuma libraries: +/libnuma.la +/libnuma.a +/libnuma.so +/libnuma.so.* + +# Built binaries: +/memhog +/migratepages +/migspeed +/numactl +/numademo +/numamon +/numastat +/stream + +# Built test cases: +/test/distance +/test/ftok +/test/mbind_mig_pages +/test/migrate_pages +/test/move_pages +/test/mynode +/test/node-parse +/test/nodemap +/test/pagesize +/test/prefered +/test/randmap +/test/realloc_test +/test/tbitmap +/test/tshared + +# Files generated by autoreconf: +/Makefile.in +/aclocal.m4 +/autom4te.cache +/build-aux +/config.h.in +/configure + +# Files generated by configure: +/Makefile +/config.h +/config.log +/config.status +/libtool +/stamp-* + +# Test logs: +/test-suite.log +/test/*.log +/test/*.trs + +# pkg-config file +numa.pc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/Makefile.am new/numactl-2.0.14.39.g8b18345/Makefile.am --- old/numactl-2.0.14.20.g4ee5e0c/Makefile.am 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/Makefile.am 2022-02-25 20:18:46.000000000 +0100 @@ -22,7 +22,7 @@ numastat_SOURCES = numastat.c numastat_CFLAGS = $(AM_CFLAGS) -std=gnu99 -numademo_SOURCES = numademo.c stream_lib.c stream_lib.h mt.c mt.h clearcache.c clearcache.h +numademo_SOURCES = numademo.c stream_lib.c stream_lib.h mt.c mt.h clearcache.c util.c clearcache.h numademo_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_STREAM_LIB -DHAVE_MT -DHAVE_CLEAR_CACHE numademo_CFLAGS = $(AM_CFLAGS) -O3 -ffast-math -funroll-loops if HAVE_TREE_VECTORIZE @@ -98,7 +98,7 @@ test_pagesize_SOURCES = test/pagesize.c test_pagesize_LDADD = libnuma.la -test_prefered_SOURCES = test/prefered.c +test_prefered_SOURCES = test/prefered.c util.c test_prefered_LDADD = libnuma.la test_randmap_SOURCES = test/randmap.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/libnuma.c new/numactl-2.0.14.39.g8b18345/libnuma.c --- old/numactl-2.0.14.20.g4ee5e0c/libnuma.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/libnuma.c 2022-02-25 20:18:46.000000000 +0100 @@ -27,6 +27,7 @@ #include <errno.h> #include <stdarg.h> #include <ctype.h> +#include <assert.h> #include <sys/mman.h> #include <limits.h> @@ -79,6 +80,8 @@ static int nodemask_sz = 0; static int cpumask_sz = 0; +static int has_preferred_many = 0; + int numa_exit_on_error = 0; int numa_exit_on_warn = 0; static void set_sizes(void); @@ -125,6 +128,15 @@ cleanup_node_cpu_mask_v2(); } +static int numa_find_first(struct bitmask *mask) +{ + int i; + for (i = 0; i < mask->size; i++) + if (numa_bitmask_isbitset(mask, i)) + return i; + return -1; +} + /* * The following bitmask declarations, bitmask_*() routines, and associated * _setbit() and _getbit() routines are: @@ -589,6 +601,30 @@ numa_error("sysconf(NPROCESSORS_CONF) failed"); } +static void +set_kernel_abi() +{ + int oldp; + struct bitmask *bmp, *tmp; + bmp = numa_allocate_nodemask(); + tmp = numa_allocate_nodemask(); + + if (get_mempolicy(&oldp, bmp->maskp, bmp->size + 1, 0, 0) < 0) + goto out; + + /* Assumes there's always a node 0, and it's online */ + numa_bitmask_setbit(tmp, 0); + if (set_mempolicy(MPOL_PREFERRED_MANY, tmp->maskp, tmp->size) == 0) { + has_preferred_many++; + /* reset the old memory policy */ + setpol(oldp, bmp); + } + +out: + numa_bitmask_free(tmp); + numa_bitmask_free(bmp); +} + /* * Initialize all the sizes. */ @@ -601,6 +637,7 @@ set_numa_max_cpu(); /* size of kernel cpumask_t */ set_configured_cpus(); /* cpus listed in /sys/devices/system/cpu */ set_task_constraints(); /* cpus and nodes for current task */ + set_kernel_abi(); /* man policy supported */ } int @@ -857,7 +894,7 @@ void numa_setlocal_memory(void *mem, size_t size) { - dombind(mem, size, MPOL_PREFERRED, NULL); + dombind(mem, size, MPOL_LOCAL, NULL); } void numa_police_memory(void *mem, size_t size) @@ -1034,7 +1071,7 @@ if (mem == (char *)-1) mem = NULL; else - dombind(mem, size, MPOL_PREFERRED, NULL); + dombind(mem, size, MPOL_LOCAL, NULL); return mem; } @@ -1042,6 +1079,8 @@ { if (strict) bind_policy = MPOL_BIND; + else if (has_preferred_many) + bind_policy = MPOL_PREFERRED_MANY; else bind_policy = MPOL_PREFERRED; } @@ -1765,47 +1804,71 @@ return ret; } -int numa_preferred(void) +static struct bitmask *__numa_preferred(void) { int policy; - int ret; struct bitmask *bmp; bmp = numa_allocate_nodemask(); - getpol(&policy, bmp); - if (policy == MPOL_PREFERRED || policy == MPOL_BIND) { - int i; - int max = numa_num_possible_nodes(); - for (i = 0; i < max ; i++) - if (numa_bitmask_isbitset(bmp, i)){ - ret = i; - goto end; - } - } /* could read the current CPU from /proc/self/status. Probably not worth it. */ - ret = 0; /* or random one? */ -end: - numa_bitmask_free(bmp); - return ret; + numa_bitmask_clearall(bmp); + getpol(&policy, bmp); + + if (policy != MPOL_PREFERRED && + policy != MPOL_PREFERRED_MANY && + policy != MPOL_BIND) + return bmp; + + if (numa_bitmask_weight(bmp) > 1) + numa_error(__FILE__); + + return bmp; } -void numa_set_preferred(int node) +int numa_preferred(void) { - struct bitmask *bmp; + return numa_find_first(__numa_preferred()); +} - bmp = numa_allocate_nodemask(); - if (node >= 0) { - numa_bitmask_setbit(bmp, node); - setpol(MPOL_PREFERRED, bmp); - } else - setpol(MPOL_DEFAULT, bmp); +static void __numa_set_preferred(struct bitmask *bmp) +{ + int nodes = numa_bitmask_weight(bmp); + if (nodes > 1) + numa_error(__FILE__); + setpol(nodes ? MPOL_PREFERRED : MPOL_LOCAL, bmp); +} + +void numa_set_preferred(int node) +{ + struct bitmask *bmp = numa_allocate_nodemask(); + numa_bitmask_setbit(bmp, node); + __numa_set_preferred(bmp); numa_bitmask_free(bmp); } +int numa_has_preferred_many(void) +{ + return has_preferred_many; +} + +void numa_set_preferred_many(struct bitmask *bitmask) +{ + if (!has_preferred_many) { + numa_error("Unable to handle MANY preferred nodes. Falling back to first node\n"); + __numa_set_preferred(bitmask); + } + setpol(MPOL_PREFERRED_MANY, bitmask); +} + +struct bitmask *numa_preferred_many() +{ + return __numa_preferred(); +} + void numa_set_localalloc(void) { - setpol(MPOL_DEFAULT, numa_no_nodes_ptr); + setpol(MPOL_LOCAL, numa_no_nodes_ptr); } SYMVER("numa_bind_v1", "numa_bind@libnuma_1.1") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/m4/.gitignore new/numactl-2.0.14.39.g8b18345/m4/.gitignore --- old/numactl-2.0.14.20.g4ee5e0c/m4/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.14.39.g8b18345/m4/.gitignore 2022-02-25 20:18:46.000000000 +0100 @@ -0,0 +1,6 @@ +# m4 files generated by libtoolize: +libtool.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 +lt~obsolete.m4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numa.3 new/numactl-2.0.14.39.g8b18345/numa.3 --- old/numactl-2.0.14.20.g4ee5e0c/numa.3 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numa.3 2022-02-25 20:18:46.000000000 +0100 @@ -64,8 +64,14 @@ .sp .B int numa_preferred(void); .br +.B int numa_has_preferred_many(void); +.br +.B struct bitmask *numa_preferred_many(void); +.br .BI "void numa_set_preferred(int " node ); .br +.BI "void numa_set_preferred_many(struct bitmask *" nodemask ); +.br .BI "int numa_get_interleave_node(void); .br .B struct bitmask *numa_get_interleave_mask(void); @@ -427,6 +433,16 @@ .\" order of the current node's zonelist to return the correct .\" node. Need to tighten this up with the syscall results. +.BR numa_has_preferred_many () +Returns > 0 if the system supports multiple preferred nodes. + +.BR numa_preferred_many () +Returns the current set of preferred nodes. This implies the empty set when the +policy isn't one used for preference +.I (PREFERRED, PREFERRED_MANY, BIND). +The caller is responsible for freeing the mask with +.BR numa_bitmask_free (). + .BR numa_set_preferred () sets the preferred node for the current task to .IR node . @@ -439,6 +455,16 @@ calling .BR numa_set_localalloc (). +.BR numa_set_preferred_many () +sets the preferred set of nodes for the current task to +.IR nodemask . +This is similar to +.BR numa_set_preferred () +with the exception that it utilizes a different kernel interface to specify +multiple preferred nodes. +The caller is responsible for freeing the mask with +.BR numa_bitmask_free (). + .BR numa_get_interleave_mask () returns the current interleave mask if the task's memory allocation policy is page interleaved. @@ -564,7 +590,7 @@ .I node is externally denied to this process, this call will fail. This function is relatively slow compared to the -.IR malloc (3), +.IR malloc (3) family of functions. The memory must be freed with @@ -607,8 +633,8 @@ The nodes on which a process is allowed to allocate memory may be constrained externally. If this is the case, this function may fail. -This function is relatively slow compare to -.IR malloc (3), +This function is relatively slow compared to the +.IR malloc (3) family of functions and should only be used for large areas consisting of multiple pages. The interleaving works at page level and will only show an effect when the @@ -624,7 +650,7 @@ The .I size argument will be rounded up to a multiple of the system page size. -This function is relatively slow compare to the +This function is relatively slow compared to the .IR malloc (3) family of functions. The memory must be freed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numa.h new/numactl-2.0.14.39.g8b18345/numa.h --- old/numactl-2.0.14.20.g4ee5e0c/numa.h 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numa.h 2022-02-25 20:18:46.000000000 +0100 @@ -186,6 +186,15 @@ /* Some node to preferably allocate memory from for task. */ void numa_set_preferred(int node); +/* Returns whether or not the platform supports MPOL_PREFERRED_MANY */ +int numa_has_preferred_many(void); + +/* Set of nodes to preferably allocate memory from for task. */ +void numa_set_preferred_many(struct bitmask *bitmask); + +/* Return preferred nodes */ +struct bitmask *numa_preferred_many(void); + /* Set local memory allocation policy for task */ void numa_set_localalloc(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numactl.8 new/numactl-2.0.14.39.g8b18345/numactl.8 --- old/numactl-2.0.14.20.g4ee5e0c/numactl.8 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numactl.8 2022-02-25 20:18:46.000000000 +0100 @@ -31,6 +31,8 @@ ] [ .B \-\-preferred node ] [ +.B \-\-preferred-many nodes +] [ .B \-\-membind nodes ] [ .B \-\-cpunodebind nodes @@ -176,6 +178,14 @@ .I \-\-membind, \-m only, otherwise ignored. .TP +.B \-\-preferred-many=node +Preferably allocate memory on +.I nodes, +but if memory cannot be allocated there fall back to other nodes. +This option takes a mask of preferred nodes where the closest node to local is +considered most preferred. +Relative notation may be used. +.TP .B \-\-show, \-s Show NUMA policy settings of the current process. .TP @@ -195,6 +205,7 @@ .I \-\-interleave, .I \-\-localalloc, .I \-\-preferred, +.I \-\-preferred-many, .I \-\-membind ). .TP @@ -297,6 +308,9 @@ numactl \-\-preferred=1 numactl \-\-show Set preferred node 1 and show the resulting state. +numactl \-\-preferred-many=0x3 numactl \-\-show +Set preferred nodes 1 and 2, and show the resulting state. + numactl --interleave=all --shm /tmp/shmkey Interleave all of the sysv shared memory region specified by /tmp/shmkey over all nodes. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numactl.c new/numactl-2.0.14.39.g8b18345/numactl.c --- old/numactl-2.0.14.20.g4ee5e0c/numactl.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numactl.c 2022-02-25 20:18:46.000000000 +0100 @@ -39,6 +39,7 @@ {"all", 0, 0, 'a'}, {"interleave", 1, 0, 'i' }, {"preferred", 1, 0, 'p' }, + {"preferred-many", 1, 0, 'P' }, {"cpubind", 1, 0, 'c' }, {"cpunodebind", 1, 0, 'N' }, {"physcpubind", 1, 0, 'C' }, @@ -67,8 +68,9 @@ { fprintf(stderr, "usage: numactl [--all | -a] [--balancing | -b] [--interleave= | -i <nodes>]\n" - " [--preferred= | -p <node>] [--physcpubind= | -C <cpus>]\n" - " [--cpunodebind= | -N <nodes>] [--membind= | -m <nodes>]\n" + " [--preferred= | -p <node>] [--preferred-many= | -P <nodes>]\n" + " [--physcpubind= | -C <cpus>] [--cpunodebind= | -N <nodes>]\n" + " [--membind= | -m <nodes>] [--localalloc | -l] command args ...\n" " [--localalloc | -l] command args ...\n" " numactl [--show | -s]\n" " numactl [--hardware | -H]\n" @@ -132,8 +134,7 @@ void show(void) { - unsigned long prefnode; - struct bitmask *membind, *interleave, *cpubind; + struct bitmask *membind, *interleave, *cpubind, *preferred; unsigned long cur; int policy; @@ -145,7 +146,7 @@ cpubind = numa_get_run_node_mask(); - prefnode = numa_preferred(); + preferred = numa_preferred_many(); interleave = numa_get_interleave_mask(); membind = numa_get_membind(); cur = numa_get_interleave_node(); @@ -159,8 +160,10 @@ printf("preferred node: "); switch (policy) { case MPOL_PREFERRED: - assert(prefnode != -1); - printf("%ld\n", prefnode); + if (numa_bitmask_weight(preferred)) + printf("%d\n", find_first(preferred)); + else + printf("%d\n", 0); break; case MPOL_DEFAULT: printf("current\n"); @@ -171,6 +174,9 @@ case MPOL_BIND: printf("%d\n", find_first(membind)); break; + case MPOL_PREFERRED_MANY: + printf("%ld (preferred-many)\n",cur); + break; } if (policy == MPOL_INTERLEAVE) { printmask("interleavemask", interleave); @@ -180,6 +186,7 @@ printmask("cpubind", cpubind); // for compatibility printmask("nodebind", cpubind); printmask("membind", membind); + printmask("preferred", preferred); } char *fmt_mem(unsigned long long mem, char *buf) @@ -420,7 +427,7 @@ int main(int ac, char **av) { - int c, i, nnodes=0; + int c; long node=-1; char *end; char shortopts[array_len(opts)*2 + 1]; @@ -497,7 +504,7 @@ did_node_cpu_parse = 1; numa_sched_setaffinity(0, cpubuf); checkerror("sched_setaffinity"); - free(cpubuf); + numa_bitmask_free(cpubuf); break; } case 'm': /* --membind */ @@ -524,9 +531,11 @@ numa_set_bind_policy(0); checkerror("setting membind"); break; + case 'P': /* --preferred-many */ + if (!numa_has_preferred_many()) + complain("preferred-many requested without kernel support"); case 'p': /* --preferred */ checknuma(); - setpolicy(MPOL_PREFERRED); if (parse_all) mask = numactl_parse_nodestring(optarg, ALL); else @@ -535,26 +544,26 @@ printf ("<%s> is invalid\n", optarg); usage(); } - for (i=0; i<mask->size; i++) { - if (numa_bitmask_isbitset(mask, i)) { - node = i; - nnodes++; - } - } - if (nnodes != 1) - usage(); errno = 0; did_node_cpu_parse = 1; numa_set_bind_policy(0); - if (shmfd >= 0) + if (shmfd >= 0) { numa_tonode_memory(shmptr, shmlen, node); - else - numa_set_preferred(node); + } else if (c == 'p') { + if (numa_bitmask_weight(mask) != 1) + usage(); + + setpolicy(MPOL_PREFERRED); + numa_set_preferred(find_first(mask)); + } else { + setpolicy(MPOL_PREFERRED_MANY); + numa_set_preferred_many(mask); + } checkerror("setting preferred node"); break; case 'l': /* --local */ checknuma(); - setpolicy(MPOL_DEFAULT); + setpolicy(MPOL_LOCAL); errno = 0; if (shmfd >= 0) numa_setlocal_memory(shmptr, shmlen); @@ -645,6 +654,8 @@ } } + numa_bitmask_free(mask); + av += optind; ac -= optind; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numademo.c new/numactl-2.0.14.39.g8b18345/numademo.c --- old/numactl-2.0.14.20.g4ee5e0c/numademo.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numademo.c 2022-02-25 20:18:46.000000000 +0100 @@ -24,6 +24,7 @@ #include <ctype.h> #include <sys/time.h> #include "numa.h" +#include "util.h" #ifdef HAVE_STREAM_LIB #include "stream_lib.h" #endif @@ -369,6 +370,18 @@ strcat(buf, buf2); } memtest(buf, numa_alloc_interleaved_subset(msize, nodes)); + + if (!numa_has_preferred_many()) + continue; + + sprintf(buf, "memory preferred on"); + for (k = 0; k < numnodes; k++) + if ((1UL<<node_to_use[k]) & mask) { + sprintf(buf2, " %d", node_to_use[k]); + strcat(buf, buf2); + } + numa_set_preferred_many(nodes); + memtest(buf, numa_alloc(msize)); } for (i = 0; i < numnodes; i++) { @@ -441,11 +454,27 @@ numa_set_localalloc(); memtest("local allocation", numa_alloc(msize)); +#define set_pref_many(__i) do { \ + numa_bitmask_clearall(nodes); \ + numa_bitmask_setbit(nodes, __i); \ + numa_set_preferred_many(nodes); \ +} while (0) 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)); - numa_set_preferred(-1); + + if (numa_has_preferred_many()) { + set_pref_many(node_to_use[(i + 1) % numnodes]); + memtest("setting wrong preferred-many nodes", + numa_alloc(msize)); + set_pref_many(node_to_use[i]); + memtest("setting correct preferred-many nodes", + numa_alloc(msize)); + } +#undef set_pref_many + + numa_set_localalloc(); if (!delim[0]) printf("\n\n\n"); } @@ -466,19 +495,6 @@ exit(1); } -/* duplicated to make numademo standalone */ -long memsize(char *s) -{ - char *end; - long length = strtoul(s,&end,0); - switch (toupper(*end)) { - case 'G': length *= 1024; /*FALL THROUGH*/ - case 'M': length *= 1024; /*FALL THROUGH*/ - case 'K': length *= 1024; break; - } - return length; -} - int main(int ac, char **av) { int simple_tests = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/numaif.h new/numactl-2.0.14.39.g8b18345/numaif.h --- old/numactl-2.0.14.20.g4ee5e0c/numaif.h 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/numaif.h 2022-02-25 20:18:46.000000000 +0100 @@ -27,7 +27,8 @@ #define MPOL_BIND 2 #define MPOL_INTERLEAVE 3 #define MPOL_LOCAL 4 -#define MPOL_MAX 5 +#define MPOL_PREFERRED_MANY 5 +#define MPOL_MAX 6 /* Flags for set_mempolicy, specified in mode */ #define MPOL_F_NUMA_BALANCING (1 << 13) /* Optimize with NUMA balancing if possible */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/shm.c new/numactl-2.0.14.39.g8b18345/shm.c --- old/numactl-2.0.14.20.g4ee5e0c/shm.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/shm.c 2022-02-25 20:18:46.000000000 +0100 @@ -107,8 +107,8 @@ "need a --length to create a sysv shared memory segment"); fprintf(stderr, "numactl: Creating shared memory segment %s id %ld mode %04o length %.fMB\n", - name, shmid, shmmode, ((double)shmlen) / (1024*1024) ); - shmfd = shmget(key, shmlen, IPC_CREAT|shmmode|shmflags); + name, shmid, shmmode, ((double)(shmlen + shmoffset)) / (1024*1024) ); + shmfd = shmget(key, shmlen + shmoffset, IPC_CREAT|shmmode|shmflags); if (shmfd < 0) nerror("cannot create shared memory segment"); } @@ -145,8 +145,12 @@ } if (fstat64(shmfd, &st) < 0) err("shm stat"); - if (shmlen > st.st_size) { - if (ftruncate64(shmfd, shmlen) < 0) { + /* the file size must be larger than mmap shmlen + shmoffset, otherwise SIGBUS + * will be caused when we access memory, because mmaped memory is no longer in + * the range of the file laster. + */ + if ((shmlen + shmoffset) > st.st_size) { + if (ftruncate64(shmfd, shmlen + shmoffset) < 0) { /* XXX: we could do it by hand, but it would it would be impossible to apply policy then. need to fix that in the kernel. */ @@ -291,7 +295,7 @@ policy_name(pol2), policy_name(policy)); goto out; } - if (memcmp(nodes2, nodes, numa_bitmask_nbytes(nodes))) { + if (memcmp(nodes2->maskp, nodes->maskp, numa_bitmask_nbytes(nodes))) { vwarn(p, "mismatched node mask\n"); printmask("expected", nodes); printmask("real", nodes2); @@ -311,6 +315,7 @@ } ilnode = interleave_next(ilnode, nodes2); break; + case MPOL_PREFERRED_MANY: case MPOL_PREFERRED: case MPOL_BIND: if (!numa_bitmask_isbitset(nodes2, node)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/syscall.c new/numactl-2.0.14.39.g8b18345/syscall.c --- old/numactl-2.0.14.20.g4ee5e0c/syscall.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/syscall.c 2022-02-25 20:18:46.000000000 +0100 @@ -72,6 +72,16 @@ #define __NR_move_pages xxx */ +#elif defined(__loongarch__) + +//reference to /usr/include/asm-generic/unistd.h + +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 + #elif defined(__mips__) #if _MIPS_SIM == _ABIO32 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/test/prefered.c new/numactl-2.0.14.39.g8b18345/test/prefered.c --- old/numactl-2.0.14.20.g4ee5e0c/test/prefered.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/test/prefered.c 2022-02-25 20:18:46.000000000 +0100 @@ -10,6 +10,12 @@ #define err(x) perror(x),exit(1) +extern void printmask(char *name, struct bitmask *mask); + +void usage(void) +{ +} + int main(void) { int max = numa_max_node(); @@ -23,6 +29,8 @@ nodes = numa_bitmask_alloc(maxmask); mask = numa_bitmask_alloc(maxmask); + /* Step 1. test 'preferred' policy */ + printf("\nTesting MPOL_PREFERRED policy:\n\n"); for (i = max; i >= 0; --i) { char *mem = mmap(NULL, pagesize*(max+1), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); @@ -59,5 +67,51 @@ if (node != i) err = 1; } + + + /* Step 2. test 'preferred-many' policy */ + if (max < 1) + return err; + + printf("\nTesting MPOL_PREFERRED_MANY policy:\n\n"); + for (i = max; i >= 1; --i) { + char *mem = mmap(NULL, pagesize*(max+1), PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); + char *adr = mem; + + if (mem == (char *)-1) + err("mmap"); + + numa_bitmask_clearall(nodes); + numa_bitmask_clearall(mask); + /* Set 2 nodes */ + numa_bitmask_setbit(nodes, i); + numa_bitmask_setbit(nodes, i - 1); + + if (mbind(adr, pagesize, MPOL_PREFERRED_MANY, nodes->maskp, + nodes->size, 0) < 0) + err("mbind"); + + ++*adr; + if (get_mempolicy(&pol, mask->maskp, mask->size, adr, MPOL_F_ADDR) < 0) + err("get_mempolicy"); + + assert(pol == MPOL_PREFERRED_MANY); + printmask("Got nodes", mask); + printmask("Expected nodes", nodes); + if (!numa_bitmask_equal(mask, nodes)) + err = 1; + + node = 0x123; + if (get_mempolicy(&node, NULL, 0, adr, MPOL_F_ADDR|MPOL_F_NODE) < 0) + err("get_mempolicy2"); + + printf("Got node: %d ", node); + printmask("Expected nodes", nodes); + + if (!numa_bitmask_isbitset(nodes, node)) + err = 1; + } + return err; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/util.c new/numactl-2.0.14.39.g8b18345/util.c --- old/numactl-2.0.14.20.g4ee5e0c/util.c 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/util.c 2022-02-25 20:18:46.000000000 +0100 @@ -86,6 +86,8 @@ int policy; int noarg; } policies[] = { + { "preferred-many", MPOL_PREFERRED_MANY, }, + { "local", MPOL_LOCAL, 1 }, { "interleave", MPOL_INTERLEAVE, }, { "membind", MPOL_BIND, }, { "preferred", MPOL_PREFERRED, }, @@ -93,7 +95,7 @@ { NULL }, }; -static char *policy_names[] = { "default", "preferred", "bind", "interleave" }; +static char *policy_names[] = { "default", "preferred", "bind", "interleave", "local", "preferred-many" }; char *policy_name(int policy) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.14.20.g4ee5e0c/versions.ldscript new/numactl-2.0.14.39.g8b18345/versions.ldscript --- old/numactl-2.0.14.20.g4ee5e0c/versions.ldscript 2021-08-26 07:01:55.000000000 +0200 +++ new/numactl-2.0.14.39.g8b18345/versions.ldscript 2022-02-25 20:18:46.000000000 +0100 @@ -154,3 +154,13 @@ local: *; } libnuma_1.4; + + +libnuma_1.6{ + global: + numa_has_preferred_many; + numa_set_preferred_many; + numa_preferred_many; + local: + *; +} libnuma_1.5; ++++++ numactl.obsinfo ++++++ --- /var/tmp/diff_new_pack.EE2SH9/_old 2022-05-14 22:54:42.195181458 +0200 +++ /var/tmp/diff_new_pack.EE2SH9/_new 2022-05-14 22:54:42.195181458 +0200 @@ -1,6 +1,5 @@ name: numactl -version: 2.0.14.20.g4ee5e0c -mtime: 1629954115 -commit: 4ee5e0cda9b6f00586a7dc366b6dd33c4302e478 - +version: 2.0.14.39.g8b18345 +mtime: 1645816726 +commit: 8b18345065c39d6b1e498bf635b4c8668e2d8f4e