Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package numactl for openSUSE:Factory checked in at 2023-04-26 17:24:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/numactl (Old) and /work/SRC/openSUSE:Factory/.numactl.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "numactl" Wed Apr 26 17:24:25 2023 rev:70 rq:1082765 version:2.0.16.21.g693fee1 Changes: -------- --- /work/SRC/openSUSE:Factory/numactl/numactl.changes 2022-09-10 20:17:09.708808989 +0200 +++ /work/SRC/openSUSE:Factory/.numactl.new.1533/numactl.changes 2023-04-26 17:25:04.145520916 +0200 @@ -1,0 +2,40 @@ +Tue Apr 25 07:46:43 UTC 2023 - tr...@suse.de + +- Update to version 2.0.16.21.g693fee1: + * fix typo + * Add fuzzer for OSS-Fuzz integration + * numactl.c: Fix merging of neighboring pages' policies in dump_shm + * memhog: Update memhog usage + * feat: Add minimum permissions to makefile.yml + * feat: Add minimum permissions to cut-release.yml + * feat: Add minimum permissions to codeql.yml + +------------------------------------------------------------------- +Sun Jan 08 21:33:11 UTC 2023 - tr...@suse.de + +- jsc#PED-3367 +- Remove unneeded defattr(root,root) statements from spec file from dmueller +- Replace deletion of *.la files with a more general version from dmueller +- Update to version 2.0.16.14.gc09fefd: + * numactl.c: Remove unused variable + * shm.c: Replace stat64/fstat64/ftruncate64mmap64 with normal functions + * configure: Check for largefile support + * numastat: Update system hugepages memory info from sysfs/node/hugepages directory + * numastat: statistical errors occur when huge pages is used + * fix wrong nodemask_sz when CONFIG_NODES_SHIFT is less than 5 + * libnuma: clear errno at the end of numa_init + * numastat: Add SwapCached to list of known fields in meminfo + * numastat: Add SecPageTables to list of known fields in meminfo + * numastat: Add ShadowCallStack to list of known fields in meminfo + * numastat: Add FileHugePages/FilePmdMapped to list of known fields in meminfo + * numactl: 'numactl --length=xxx --shm xxx -px' doesn't work + * numactl: Fix shm verfiy for preferred policy + * link with -latomic if needed (again ...) + * Release numactl 2.0.16 + * add cut-release github workflow (#142) + * when preferred_many is not supported, fall back to preferred will report error. + * fix the memory leak of numa_preferred api + * build: Refactor autotools setup to store version in separate file + * Revert "numademo: fix error on 32bit system" + +------------------------------------------------------------------- Old: ---- numactl-2.0.15.0.g01a39cb.obscpio New: ---- numactl-2.0.16.21.g693fee1.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ numactl.spec ++++++ --- /var/tmp/diff_new_pack.UnlNQq/_old 2023-04-26 17:25:04.673523996 +0200 +++ /var/tmp/diff_new_pack.UnlNQq/_new 2023-04-26 17:25:04.677524020 +0200 @@ -1,7 +1,7 @@ # # spec file for package numactl # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 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.15.0.g01a39cb +Version: 2.0.16.21.g693fee1 Release: 0 Summary: NUMA Policy Control License: GPL-2.0-only @@ -69,24 +69,21 @@ %install %make_install rm %{buildroot}%{_mandir}/man2/move_pages.2* -rm -f %{buildroot}/%{_libdir}/lib*.la +find %{buildroot} -type f -name "*.la" -delete -print %post -n libnuma1 -p /sbin/ldconfig %postun -n libnuma1 -p /sbin/ldconfig %files -%defattr(-,root,root) %license LICENSE.GPL2 LICENSE.LGPL2.1 %{_bindir}/* %{_mandir}/man8/* %files -n libnuma1 -%defattr(-,root,root) %{_libdir}/lib*so.* %files -n libnuma-devel -%defattr(-,root,root) %{_mandir}/man3/* %{_includedir}/* %{_libdir}/lib*so ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.UnlNQq/_old 2023-04-26 17:25:04.745524416 +0200 +++ /var/tmp/diff_new_pack.UnlNQq/_new 2023-04-26 17:25:04.749524440 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/numactl/numactl</param> - <param name="changesrevision">01a39cb4edc0dd0f4151b7ad11e0c56d2e612a02</param></service></servicedata> + <param name="changesrevision">693fee1ed3d9524d2696f6ba021431b3176b6f57</param></service></servicedata> (No newline at EOF) ++++++ numactl-2.0.15.0.g01a39cb.obscpio -> numactl-2.0.16.21.g693fee1.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/.github/workflows/codeql.yml new/numactl-2.0.16.21.g693fee1/.github/workflows/codeql.yml --- old/numactl-2.0.15.0.g01a39cb/.github/workflows/codeql.yml 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/.github/workflows/codeql.yml 2023-03-15 04:30:49.000000000 +0100 @@ -20,6 +20,9 @@ schedule: - cron: '25 18 * * 6' +permissions: + contents: read + jobs: analyze: name: Analyze diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/.github/workflows/cut-release.yml new/numactl-2.0.16.21.g693fee1/.github/workflows/cut-release.yml --- old/numactl-2.0.15.0.g01a39cb/.github/workflows/cut-release.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.16.21.g693fee1/.github/workflows/cut-release.yml 2023-03-15 04:30:49.000000000 +0100 @@ -0,0 +1,30 @@ +name: Create GitHub release from pushed tag +on: + push: + tags: + - v* +permissions: + contents: read +jobs: + cut_release: + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - name: Install deps + run: | + sudo apt-get install -y build-essential fakeroot + - name: Checkout code + uses: actions/checkout@v3 + - name: "Build & test" + run: | + ./autogen.sh + ./configure + fakeroot make distcheck + - name: Create Release + uses: marvinpinto/action-automatic-releases@v1.2.1 + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + draft: false + prerelease: false + files: numactl-*.tar.gz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/.github/workflows/makefile.yml new/numactl-2.0.16.21.g693fee1/.github/workflows/makefile.yml --- old/numactl-2.0.15.0.g01a39cb/.github/workflows/makefile.yml 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/.github/workflows/makefile.yml 2023-03-15 04:30:49.000000000 +0100 @@ -6,6 +6,9 @@ pull_request: branches: [ "master", "action-1" ] +permissions: + contents: read + jobs: build: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/VERSION new/numactl-2.0.16.21.g693fee1/VERSION --- old/numactl-2.0.15.0.g01a39cb/VERSION 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.16.21.g693fee1/VERSION 2023-03-15 04:30:49.000000000 +0100 @@ -0,0 +1 @@ +2.0.16 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/configure.ac new/numactl-2.0.16.21.g693fee1/configure.ac --- old/numactl-2.0.15.0.g01a39cb/configure.ac 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/configure.ac 2023-03-15 04:30:49.000000000 +0100 @@ -1,5 +1,5 @@ AC_PREREQ([2.64]) -AC_INIT([numactl], [2.0.14]) +AC_INIT([numactl], m4_normalize(m4_include([VERSION]))) AC_CONFIG_SRCDIR([numactl.c]) AC_CONFIG_MACRO_DIR([m4]) @@ -14,6 +14,9 @@ AC_PROG_CC +# Check for enabling LFS support +AC_SYS_LARGEFILE + # Override CFLAGS so that we can specify custom CFLAGS for numademo. AX_AM_OVERRIDE_VAR([CFLAGS]) @@ -27,6 +30,8 @@ AC_CONFIG_FILES([Makefile]) +AC_SEARCH_LIBS([__atomic_fetch_and_1], [atomic]) + # GCC tries to be "helpful" and only issue a warning for unrecognized # attributes. So we compile the test with Werror, so that if the # attribute is not recognized the compilation fails diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/fuzz/README.md new/numactl-2.0.16.21.g693fee1/fuzz/README.md --- old/numactl-2.0.15.0.g01a39cb/fuzz/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.16.21.g693fee1/fuzz/README.md 2023-03-15 04:30:49.000000000 +0100 @@ -0,0 +1,4 @@ +# Numactl fuzzing + +OSS-Fuzz fuzzing suite. Fuzzers here are meant to run by way of OSS-Fuzz and +will be build and executed continuously. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/fuzz/fuzz_parse_str.c new/numactl-2.0.16.21.g693fee1/fuzz/fuzz_parse_str.c --- old/numactl-2.0.15.0.g01a39cb/fuzz/fuzz_parse_str.c 1970-01-01 01:00:00.000000000 +0100 +++ new/numactl-2.0.16.21.g693fee1/fuzz/fuzz_parse_str.c 2023-03-15 04:30:49.000000000 +0100 @@ -0,0 +1,28 @@ +#include <stdint.h> +#include <stdlib.h> +#include "numa.h" + + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + struct bitmask *mask = NULL; + + char *fuzz_str1 = malloc(size+1); + memcpy(fuzz_str1, data, size); + fuzz_str1[size] = '\0'; + + mask = numa_parse_nodestring(fuzz_str1); + if (mask != NULL) { + numa_bitmask_free(mask); + } + + // NULLify the mask variable before we use it again. + mask = NULL; + mask = numa_parse_cpustring(fuzz_str1); + if (mask != NULL) { + numa_node_to_cpus_v2(0, mask); + numa_bitmask_free(mask); + } + + free(fuzz_str1); + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/libnuma.c new/numactl-2.0.16.21.g693fee1/libnuma.c --- old/numactl-2.0.15.0.g01a39cb/libnuma.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/libnuma.c 2023-03-15 04:30:49.000000000 +0100 @@ -106,6 +106,9 @@ for (i = 0; i < max; i++) nodemask_set_compat((nodemask_t *)&numa_all_nodes, i); memset(&numa_no_nodes, 0, sizeof(numa_no_nodes)); + + /* clear errno */ + errno = 0; } static void cleanup_node_cpu_mask_v2(void); @@ -367,13 +370,11 @@ } } -/* - * Convert the string length of an ascii hex mask to the number - * of bits represented by that mask. - */ -static int s2nbits(const char *s) +static inline int is_digit(char s) { - return strlen(s) * 32 / 9; + return (s >= '0' && s <= '9') + || (s >= 'a' && s <= 'f') + || (s >= 'A' && s <= 'F'); } /* Is string 'pre' a prefix of string 's'? */ @@ -395,6 +396,8 @@ { FILE *fp; char *buf = NULL; + char *tmp_buf = NULL; + int digit_len = 0; size_t bufsize = 0; if ((fp = fopen(mask_size_file, "r")) == NULL) @@ -402,8 +405,14 @@ while (getline(&buf, &bufsize, fp) > 0) { if (strprefix(buf, nodemask_prefix)) { - nodemask_sz = s2nbits(buf + strlen(nodemask_prefix)); - break; + tmp_buf = buf; + tmp_buf += strlen(nodemask_prefix); + while (*tmp_buf != '\n' && *tmp_buf != '\0') { + if (is_digit(*tmp_buf)) + digit_len++; + tmp_buf++; + } + nodemask_sz = digit_len * 4; } } free(buf); @@ -830,10 +839,10 @@ make_internal_alias(numa_node_size64); -long long numa_node_size(int node, long long *freep) +long numa_node_size(int node, long *freep) { long long f2; - long long sz = numa_node_size64_int(node, &f2); + long sz = numa_node_size64_int(node, &f2); if (freep) *freep = f2; return sz; @@ -1828,7 +1837,14 @@ int numa_preferred(void) { - return numa_find_first(__numa_preferred()); + int first_node = 0; + struct bitmask *bmp; + + bmp = __numa_preferred(); + first_node = numa_find_first(bmp); + numa_bitmask_free(bmp); + + return first_node; } static void __numa_set_preferred(struct bitmask *bmp) @@ -1854,9 +1870,14 @@ void numa_set_preferred_many(struct bitmask *bitmask) { + int first_node = 0; + if (!has_preferred_many) { - numa_error("Unable to handle MANY preferred nodes. Falling back to first node\n"); - __numa_set_preferred(bitmask); + numa_warn(W_nodeparse, + "Unable to handle MANY preferred nodes. Falling back to first node\n"); + first_node = numa_find_first(bitmask); + numa_set_preferred(first_node); + return; } setpol(MPOL_PREFERRED_MANY, bitmask); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/memhog.c new/numactl-2.0.16.21.g693fee1/memhog.c --- old/numactl-2.0.15.0.g01a39cb/memhog.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/memhog.c 2023-03-15 04:30:49.000000000 +0100 @@ -38,7 +38,7 @@ static void usage(void) { - printf("memhog [-fFILE] [-rNUM] size[kmg] [policy [nodeset]]\n"); + printf("memhog [-fFILE] [-rNUM] [-H] size[kmg] [policy [nodeset]]\n"); printf("-f mmap is backed by FILE\n"); printf("-rNUM repeat memset NUM times\n"); printf("-H disable transparent hugepages\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/numa.h new/numactl-2.0.16.21.g693fee1/numa.h --- old/numactl-2.0.15.0.g01a39cb/numa.h 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/numa.h 2023-03-15 04:30:49.000000000 +0100 @@ -143,7 +143,7 @@ /* Return node size and free memory */ long long numa_node_size64(int node, long long *freep); -long long numa_node_size(int node, long long *freep); +long numa_node_size(int node, long *freep); int numa_pagesize(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/numactl.c new/numactl-2.0.16.21.g693fee1/numactl.c --- old/numactl-2.0.15.0.g01a39cb/numactl.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/numactl.c 2023-03-15 04:30:49.000000000 +0100 @@ -422,7 +422,6 @@ int main(int ac, char **av) { int c; - long node=-1; char *end; char shortopts[array_len(opts)*2 + 1]; struct bitmask *mask = NULL; @@ -548,7 +547,13 @@ did_node_cpu_parse = 1; numa_set_bind_policy(0); if (shmfd >= 0) { - numa_tonode_memory(shmptr, shmlen, node); + numa_tonode_memory(shmptr, shmlen, find_first(mask)); + /* Correspond to numa_set_bind_policy function */ + if (numa_has_preferred_many()) { + setpolicy(MPOL_PREFERRED_MANY); + } else { + setpolicy(MPOL_PREFERRED); + } } else if (c == 'p') { if (numa_bitmask_weight(mask) != 1) usage(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/numademo.c new/numactl-2.0.16.21.g693fee1/numademo.c --- old/numactl-2.0.15.0.g01a39cb/numademo.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/numademo.c 2023-03-15 04:30:49.000000000 +0100 @@ -301,8 +301,8 @@ static int get_node_list(void) { int a, got_nodes = 0; - long long free_node_sizes; - int max_node; + int max_node; + long free_node_sizes; numnodes = numa_num_configured_nodes(); node_to_use = (int *)malloc(numnodes * sizeof(int)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/numastat.c new/numactl-2.0.16.21.g693fee1/numastat.c --- old/numactl-2.0.15.0.g01a39cb/numastat.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/numastat.c 2023-03-15 04:30:49.000000000 +0100 @@ -41,6 +41,9 @@ #include <string.h> #include <sys/types.h> #include <unistd.h> +#include <dirent.h> +#include <sys/stat.h> +#include <errno.h> #define STRINGIZE(s) #s #define STRINGIFY(s) STRINGIZE(s) @@ -50,6 +53,8 @@ #define BUF_SIZE 2048 #define SMALL_BUF_SIZE 128 +#define PATH_LEN 128 +#define DNAME_LEN 64 // Don't assume nodes are sequential or contiguous. // Need to discover and map node numbers. @@ -57,6 +62,10 @@ int *node_ix_map = NULL; char **node_header; +//Vma Kernel Pagesize string +#define VM_PGSZ_STR "kernelpagesize_kB=" +#define VM_PGSZ_STRLEN 18 + // Structure to organize memory info from /proc/<PID>/numa_maps for a specific // process, or from /sys/devices/system/node/node?/meminfo for system-wide // data. Tables are defined below for each process and for system-wide data. @@ -94,39 +103,44 @@ { 0, "MemTotal", "MemTotal" }, { 1, "MemFree", "MemFree" }, { 2, "MemUsed", "MemUsed" }, - { 3, "HighTotal", "HighTotal" }, - { 4, "HighFree", "HighFree" }, - { 5, "LowTotal", "LowTotal" }, - { 6, "LowFree", "LowFree" }, - { 7, "Active", "Active" }, - { 8, "Inactive", "Inactive" }, - { 9, "Active(anon)", "Active(anon)" }, - { 10, "Inactive(anon)", "Inactive(anon)" }, - { 11, "Active(file)", "Active(file)" }, - { 12, "Inactive(file)", "Inactive(file)" }, - { 13, "Unevictable", "Unevictable" }, - { 14, "Mlocked", "Mlocked" }, - { 15, "Dirty", "Dirty" }, - { 16, "Writeback", "Writeback" }, - { 17, "FilePages", "FilePages" }, - { 18, "Mapped", "Mapped" }, - { 19, "AnonPages", "AnonPages" }, - { 20, "Shmem", "Shmem" }, - { 21, "KernelStack", "KernelStack" }, - { 22, "PageTables", "PageTables" }, - { 23, "NFS_Unstable", "NFS_Unstable" }, - { 24, "Bounce", "Bounce" }, - { 25, "WritebackTmp", "WritebackTmp" }, - { 26, "Slab", "Slab" }, - { 27, "SReclaimable", "SReclaimable" }, - { 28, "SUnreclaim", "SUnreclaim" }, - { 29, "AnonHugePages", "AnonHugePages" }, - { 30, "ShmemHugePages", "ShmemHugePages" }, - { 31, "ShmemPmdMapped", "ShmemPmdMapped" }, - { 32, "HugePages_Total", "HugePages_Total" }, - { 33, "HugePages_Free", "HugePages_Free" }, - { 34, "HugePages_Surp", "HugePages_Surp" }, - { 35, "KReclaimable", "KReclaimable" } + { 3, "SwapCached", "SwapCached" }, + { 4, "HighTotal", "HighTotal" }, + { 5, "HighFree", "HighFree" }, + { 6, "LowTotal", "LowTotal" }, + { 7, "LowFree", "LowFree" }, + { 8, "Active", "Active" }, + { 9, "Inactive", "Inactive" }, + { 10, "Active(anon)", "Active(anon)" }, + { 11, "Inactive(anon)", "Inactive(anon)" }, + { 12, "Active(file)", "Active(file)" }, + { 13, "Inactive(file)", "Inactive(file)" }, + { 14, "Unevictable", "Unevictable" }, + { 15, "Mlocked", "Mlocked" }, + { 16, "Dirty", "Dirty" }, + { 17, "Writeback", "Writeback" }, + { 18, "FilePages", "FilePages" }, + { 19, "Mapped", "Mapped" }, + { 20, "AnonPages", "AnonPages" }, + { 21, "Shmem", "Shmem" }, + { 22, "KernelStack", "KernelStack" }, + { 23, "ShadowCallStack", "ShadowCallStack" }, + { 24, "PageTables", "PageTables" }, + { 25, "SecPageTables", "SecPageTables" }, + { 26, "NFS_Unstable", "NFS_Unstable" }, + { 27, "Bounce", "Bounce" }, + { 28, "WritebackTmp", "WritebackTmp" }, + { 29, "Slab", "Slab" }, + { 30, "SReclaimable", "SReclaimable" }, + { 31, "SUnreclaim", "SUnreclaim" }, + { 32, "AnonHugePages", "AnonHugePages" }, + { 33, "ShmemHugePages", "ShmemHugePages" }, + { 34, "ShmemPmdMapped", "ShmemPmdMapped" }, + { 35, "FileHugePages", "FileHugePages" }, + { 36, "FilePmdMapped", "FilePmdMapped" }, + { 37, "HugePages_Total", "HugePages_Total" }, + { 38, "HugePages_Free", "HugePages_Free" }, + { 39, "HugePages_Surp", "HugePages_Surp" }, + { 40, "KReclaimable", "KReclaimable" } }; #define SYSTEM_MEMINFO_ROWS (sizeof(system_meminfo) / sizeof(system_meminfo[0])) @@ -785,6 +799,88 @@ return NULL; } +/* update hugepages info from /sys/devices/system/node/node$/hugepages/hugepages-$ */ +static double update_hugepages_info(int node_ix, const char *token) +{ + char *fname; + DIR *d = NULL; + struct dirent *dp = NULL; + struct stat st; + char top_path[64]; + + if (!strncmp(token, "HugePages_Total", 15)) { + fname = "nr_hugepages"; + } else if(!strncmp(token, "HugePages_Free", 14)) { + fname = "free_hugepages"; + } else if (!strncmp(token, "HugePages_Surp", 14)) { + fname = "surplus_hugepages"; + } else { + return -EINVAL; + } + + snprintf(top_path, sizeof(top_path), "/sys/devices/system/node/node%d/hugepages", node_ix); + + if(stat(top_path, &st) < 0 || !S_ISDIR(st.st_mode)) { + printf("invalid path: %s\n", top_path); + return -ENOENT; + } + + if(!(d = opendir(top_path))) { + fprintf(stderr, "opendir[%s] error: %s\n", top_path, strerror(errno)); + return -ENOENT; + } + + const char *delimiters = "-"; + double total = 0; + char *huge_dname; + char *fpath; + char *buf; + + huge_dname = (char *)malloc(DNAME_LEN); + fpath = (char *)malloc(PATH_LEN); + buf = (char *)malloc(SMALL_BUF_SIZE); + + /* Traversing directories /sys/devices/system/node/node%d/hugepages */ + while((dp = readdir(d)) != NULL) { + if((!strncmp(dp->d_name, ".", 1)) || (!strncmp(dp->d_name, "..", 2))) + continue; + + if ((dp->d_type != DT_DIR) || strncmp(dp->d_name, "hugepages-", 10)) + continue; + + /* Get huge pages size from d_name d_name: example hugepages-1048576kB */ + memset(huge_dname, 0, DNAME_LEN); + memcpy(huge_dname, dp->d_name, strlen(dp->d_name)); + + /* Example: /sys/devices/system/node/node%d/hugepages/hugepages-1048576kB/nr_hugepages */ + snprintf(fpath, PATH_LEN, "%s/%s/%s", top_path, huge_dname, fname); + + char *pagesz_str = strtok(huge_dname, delimiters); + pagesz_str = strtok(NULL, pagesz_str); + memset(strstr(pagesz_str, "kB"), 0, 2); + unsigned long hugepage_size = strtol(pagesz_str, NULL, 10); + hugepage_size *= KILOBYTE; + + /* Get the number of pages */ + FILE *fs = fopen(fpath, "r"); + if (!fs) { + printf("cannot open %s: %s\n", fpath, strerror(errno)); + continue; + } + fgets(buf, SMALL_BUF_SIZE, fs); + unsigned long nr_pages = strtol(buf, NULL, 10); + fclose(fs); + + total += nr_pages * hugepage_size; + } + closedir(d); + free(huge_dname); + free(fpath); + free(buf); + + return total; +} + static void show_info_from_system_file(char *file, meminfo_p meminfo, int meminfo_rows, int tok_offset) { // Setup and init table @@ -864,7 +960,14 @@ if (tokens < 4) { multiplier = page_size_in_bytes; } else if (!strncmp("HugePages", tok[2], 9)) { - multiplier = huge_page_size_in_bytes; + /* update hugepages info more detail from sysfs/hugepages directory */ + double new = update_hugepages_info(node_ix_map[node_ix], tok[2]); + if (new > 0) { + value = new; + } else { + /* fall back old way */ + multiplier = huge_page_size_in_bytes; + } } else if (!strncmp("kB", tok[4], 2)) { multiplier = KILOBYTE; } @@ -997,6 +1100,12 @@ // amount. while (fgets(buf, BUF_SIZE, fs)) { int category = PROCESS_PRIVATE_INDEX; // init category to the catch-all... + double vm_pagesz = 0; + char *pagesz_str = strstr(buf, VM_PGSZ_STR); + if (pagesz_str) { + vm_pagesz = (double)strtol(&pagesz_str[VM_PGSZ_STRLEN], NULL, 10); + vm_pagesz *= KILOBYTE; + } const char *delimiters = " \t\r\n"; char *p = strtok(buf, delimiters); while (p) { @@ -1021,11 +1130,13 @@ exit(EXIT_FAILURE); } double value = (double)strtol(&p[1], &p, 10); - double multiplier = page_size_in_bytes; - if (category == PROCESS_HUGE_INDEX) { - multiplier = huge_page_size_in_bytes; + if (!vm_pagesz) { + vm_pagesz = page_size_in_bytes; + if (category == PROCESS_HUGE_INDEX) { + vm_pagesz = huge_page_size_in_bytes; + } } - value *= multiplier; + value *= vm_pagesz; value /= (double)MEGABYTE; // Add value to data cell, total_col, and total_row int tmp_row; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/numactl-2.0.15.0.g01a39cb/shm.c new/numactl-2.0.16.21.g693fee1/shm.c --- old/numactl-2.0.15.0.g01a39cb/shm.c 2022-09-07 23:43:06.000000000 +0200 +++ new/numactl-2.0.16.21.g693fee1/shm.c 2023-03-15 04:30:49.000000000 +0100 @@ -24,8 +24,8 @@ #include <sys/mman.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <sys/fcntl.h> #include <sys/stat.h> +#include <fcntl.h> #include <stdarg.h> #include <errno.h> #include <unistd.h> @@ -135,7 +135,7 @@ /* Attach a shared memory file. */ void attach_shared(char *name, char *opt) { - struct stat64 st; + struct stat st; shmfd = open(name, O_RDWR); if (shmfd < 0) { @@ -146,14 +146,14 @@ if (shmfd < 0) nerror("cannot create file %s", name); } - if (fstat64(shmfd, &st) < 0) + if (fstat(shmfd, &st) < 0) err("shm stat"); /* 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) { + if (ftruncate(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. */ @@ -168,7 +168,7 @@ /* RED-PEN For shmlen > address space may need to map in pieces. Left for some poor 32bit soul. */ - shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset); + shmptr = mmap(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset); if (shmptr == (char*)-1) err("shm mmap"); } @@ -205,11 +205,12 @@ 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; } ++++++ numactl.obsinfo ++++++ --- /var/tmp/diff_new_pack.UnlNQq/_old 2023-04-26 17:25:04.901525327 +0200 +++ /var/tmp/diff_new_pack.UnlNQq/_new 2023-04-26 17:25:04.905525350 +0200 @@ -1,5 +1,5 @@ name: numactl -version: 2.0.15.0.g01a39cb -mtime: 1662586986 -commit: 01a39cb4edc0dd0f4151b7ad11e0c56d2e612a02 +version: 2.0.16.21.g693fee1 +mtime: 1678851049 +commit: 693fee1ed3d9524d2696f6ba021431b3176b6f57