commit 01d34a36657cc9a189195e1829a46d6b4ba950c5 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 11:10:22 2019 -0400 Package init diff --git a/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch b/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch new file mode 100644 index 0000000..073364c --- /dev/null +++ b/0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch @@ -0,0 +1,38 @@ +From a8f5ed65b745f96f5e5af72bace8e7c63b96fd4e Mon Sep 17 00:00:00 2001 +From: Sanskriti Sharma +Date: Thu, 13 Sep 2018 10:01:58 -0400 +Subject: [PATCH 07/25] 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 +--- + 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])) +-- +1.8.3.1 + diff --git a/0008-add-missing-policy.patch b/0008-add-missing-policy.patch new file mode 100644 index 0000000..bba1f5c --- /dev/null +++ b/0008-add-missing-policy.patch @@ -0,0 +1,29 @@ +From b4072cd7add189dae02f3787cbc6a9e65f0326e7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jo=C3=A3o=20Neto?= +Date: Thu, 4 Oct 2018 09:55:00 +0100 +Subject: [PATCH 08/25] add missing policy + +`MPOL_LOCAL` has been a policy since Linux 3.8, but is missing from `numaif.h` +--- + numaif.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/numaif.h b/numaif.h +index 2c9f214..de58097 100644 +--- a/numaif.h ++++ b/numaif.h +@@ -23,9 +23,10 @@ extern long move_pages(int pid, unsigned long count, + + /* Policies */ + #define MPOL_DEFAULT 0 +-#define MPOL_PREFERRED 1 ++#define MPOL_PREFERRED 1 + #define MPOL_BIND 2 + #define MPOL_INTERLEAVE 3 ++#define MPOL_LOCAL 4 + + #define MPOL_MAX MPOL_INTERLEAVE + +-- +1.8.3.1 + diff --git a/0013-numactl-add-va_end-to-usage-function.patch b/0013-numactl-add-va_end-to-usage-function.patch new file mode 100644 index 0000000..88b552a --- /dev/null +++ b/0013-numactl-add-va_end-to-usage-function.patch @@ -0,0 +1,29 @@ +From a7ee1fcdae89c17721a12240d4d6b775820b60ed Mon Sep 17 00:00:00 2001 +From: Sanskriti Sharma +Date: Tue, 9 Oct 2018 15:08:12 -0400 +Subject: [PATCH 13/25] numactl: add va_end to usage function + +Fixes the following cppcheck: + + [numactl.c:104]: (error) va_list 'ap' was opened but not closed by va_end(). + +Signed-off-by: Sanskriti Sharma +--- + numactl.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/numactl.c b/numactl.c +index a2b2d9d..76a1cca 100644 +--- a/numactl.c ++++ b/numactl.c +@@ -101,6 +101,7 @@ void usage_msg(char *msg, ...) + vfprintf(stderr, msg, ap); + putchar('\n'); + usage(); ++ va_end(ap); + } + + void show_physcpubind(void) +-- +1.8.3.1 + diff --git a/0014-libnuma-cleanup-node-cpu-mask-in-destructor.patch b/0014-libnuma-cleanup-node-cpu-mask-in-destructor.patch new file mode 100644 index 0000000..c141644 --- /dev/null +++ b/0014-libnuma-cleanup-node-cpu-mask-in-destructor.patch @@ -0,0 +1,84 @@ +From 24514624d5d3121884344b2847b0e50204b2ffb8 Mon Sep 17 00:00:00 2001 +From: Sanskriti Sharma +Date: Tue, 9 Oct 2018 15:15:25 -0400 +Subject: [PATCH 14/25] libnuma: cleanup node cpu mask in destructor + +Free node_cpu_mask_v2[] bitmap-pointer-array and all of the bitmaps +that it points to. + +Fixes the following valgrind warnings: + + 16 bytes in 1 blocks are still reachable in loss record 1 of 3 + at 0x4C28BE3: malloc (vg_replace_malloc.c:299) + by 0x4E37E05: numa_bitmask_alloc (libnuma.c:210) + by 0x4E3998E: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1381) + by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718) + by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo) + by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo) + + 512 bytes in 1 blocks are still reachable in loss record 2 of 3 + at 0x4C2A975: calloc (vg_replace_malloc.c:711) + by 0x4E37E24: numa_bitmask_alloc (libnuma.c:214) + by 0x4E3998E: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1381) + by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718) + by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo) + by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo) + + 8,192 bytes in 1 blocks are still reachable in loss record 3 of 3 + at 0x4C2A975: calloc (vg_replace_malloc.c:711) + by 0x4E39974: init_node_cpu_mask_v2 (libnuma.c:1266) + by 0x4E39974: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1361) + by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718) + by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo) + by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo) + +Signed-off-by:Sanskriti Sharma +--- + libnuma.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/libnuma.c b/libnuma.c +index eb99567..658ee00 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -103,6 +103,8 @@ numa_init(void) + memset(&numa_no_nodes, 0, sizeof(numa_no_nodes)); + } + ++static void cleanup_node_cpu_mask_v2(); ++ + #define FREE_AND_ZERO(x) if (x) { \ + numa_bitmask_free(x); \ + x = NULL; \ +@@ -118,6 +120,7 @@ numa_fini(void) + FREE_AND_ZERO(numa_no_nodes_ptr); + FREE_AND_ZERO(numa_memnode_ptr); + FREE_AND_ZERO(numa_nodes_ptr); ++ cleanup_node_cpu_mask_v2(); + } + + /* +@@ -1248,6 +1251,20 @@ static init_node_cpu_mask_v2(void) + node_cpu_mask_v2 = calloc (nnodes, sizeof(struct bitmask *)); + } + ++static void cleanup_node_cpu_mask_v2(void) ++{ ++ if (node_cpu_mask_v2) { ++ int i; ++ int nnodes; ++ nnodes = numa_max_possible_node_v2_int() + 1; ++ for (i = 0; i < nnodes; i++) { ++ FREE_AND_ZERO(node_cpu_mask_v2[i]); ++ } ++ free(node_cpu_mask_v2); ++ node_cpu_mask_v2 = NULL; ++ } ++} ++ + /* This would be better with some locking, but I don't want to make libnuma + dependent on pthreads right now. The races are relatively harmless. */ + int +-- +1.8.3.1 + diff --git a/0021-Removed-unnecessary-exit-from-memhog.c.patch b/0021-Removed-unnecessary-exit-from-memhog.c.patch new file mode 100644 index 0000000..bb0978e --- /dev/null +++ b/0021-Removed-unnecessary-exit-from-memhog.c.patch @@ -0,0 +1,25 @@ +From 9555fd2c5c700e774620017fa611c864fc3c8f2a Mon Sep 17 00:00:00 2001 +From: Sanskriti Sharma +Date: Wed, 28 Nov 2018 10:12:26 -0500 +Subject: [PATCH 21/25] Removed unnecessary exit from memhog.c Solves issue #50 + Signed-off-by: Sanskriti sharma + +--- + memhog.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/memhog.c b/memhog.c +index e832266..829b393 100644 +--- a/memhog.c ++++ b/memhog.c +@@ -101,7 +101,6 @@ int main(int ac, char **av) + length = memsize(av[1]); + if (av[2] && numa_available() < 0) { + printf("Kernel doesn't support NUMA policy\n"); +- exit(1); + } else + loose = 1; + policy = parse_policy(av[2], av[3]); +-- +1.8.3.1 + diff --git a/0022-Correct-sysconf-constants.patch b/0022-Correct-sysconf-constants.patch new file mode 100644 index 0000000..c8bb03e --- /dev/null +++ b/0022-Correct-sysconf-constants.patch @@ -0,0 +1,38 @@ +From 4fda899f78887c782ba1dc6613d0b7b635aee535 Mon Sep 17 00:00:00 2001 +From: Gareth Lloyd +Date: Fri, 4 Jan 2019 13:58:58 +0000 +Subject: [PATCH 22/25] Correct sysconf constants + +Only level 1 distinguishes between data and intstruction cache +--- + clearcache.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/clearcache.c b/clearcache.c +index 82469c1..146051c 100644 +--- a/clearcache.c ++++ b/clearcache.c +@@ -14,14 +14,14 @@ unsigned cache_size(void) + #ifdef _SC_LEVEL1_DCACHE_SIZE + cs += sysconf(_SC_LEVEL1_DCACHE_SIZE); + #endif +-#ifdef _SC_LEVEL2_DCACHE_SIZE +- cs += sysconf(_SC_LEVEL2_DCACHE_SIZE); ++#ifdef _SC_LEVEL2_CACHE_SIZE ++ cs += sysconf(_SC_LEVEL2_CACHE_SIZE); + #endif +-#ifdef _SC_LEVEL3_DCACHE_SIZE +- cs += sysconf(_SC_LEVEL3_DCACHE_SIZE); ++#ifdef _SC_LEVEL3_CACHE_SIZE ++ cs += sysconf(_SC_LEVEL3_CACHE_SIZE); + #endif +-#ifdef _SC_LEVEL4_DCACHE_SIZE +- cs += sysconf(_SC_LEVEL4_DCACHE_SIZE); ++#ifdef _SC_LEVEL4_CACHE_SIZE ++ cs += sysconf(_SC_LEVEL4_CACHE_SIZE); + #endif + if (cs == 0) { + static int warned; +-- +1.8.3.1 + diff --git a/0024-numastat-Better-diagnostic-when-find-unknown-string-.patch b/0024-numastat-Better-diagnostic-when-find-unknown-string-.patch new file mode 100644 index 0000000..5ea9af1 --- /dev/null +++ b/0024-numastat-Better-diagnostic-when-find-unknown-string-.patch @@ -0,0 +1,35 @@ +From ec4fa9fe01d0735f9440ef69e1a5a1cca63bf78e Mon Sep 17 00:00:00 2001 +From: Tony Luck +Date: Fri, 25 Jan 2019 15:15:34 -0800 +Subject: [PATCH 24/25] numastat: Better diagnostic when find unknown string in + meminfo + +From time to time the kernel adds new statistics to the meminfo +file. These currently result in messages like this: + + Token Node not in hash table. + +it would be more helpful to print the actual token that was found, +rather than the word "Node". E.g. + + Token KReclaimable not in hash table. +--- + numastat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/numastat.c b/numastat.c +index 25874db..1ae11fb 100644 +--- a/numastat.c ++++ b/numastat.c +@@ -824,7 +824,7 @@ void show_info_from_system_file(char *file, meminfo_p meminfo, int meminfo_rows, + // example line from meminfo file: "Node 3 Inactive: 210680 kB" + int index = hash_lookup(tok[0 + tok_offset]); + if (index < 0) { +- printf("Token %s not in hash table.\n", tok[0]); ++ printf("Token %s not in hash table.\n", tok[0 + tok_offset]); + } else { + double value = (double)atol(tok[1 + tok_offset]); + if (!compatibility_mode) { +-- +1.8.3.1 + diff --git a/0025-numastat-Add-KReclaimable-to-list-of-known-fields-in.patch b/0025-numastat-Add-KReclaimable-to-list-of-known-fields-in.patch new file mode 100644 index 0000000..f52d86e --- /dev/null +++ b/0025-numastat-Add-KReclaimable-to-list-of-known-fields-in.patch @@ -0,0 +1,33 @@ +From ebec09d9f6c6d8ab268472347bbe7f94659d7275 Mon Sep 17 00:00:00 2001 +From: Tony Luck +Date: Fri, 25 Jan 2019 15:22:34 -0800 +Subject: [PATCH 25/25] numastat: Add KReclaimable to list of known fields in + meminfo + +Linux kernel added this new field in October 2018 version v4.20 +with commit: + + 61f94e18de94 ("mm, proc: add KReclaimable to /proc/meminfo") + +Add it to numastat too. +--- + numastat.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/numastat.c b/numastat.c +index 1ae11fb..263bddf 100644 +--- a/numastat.c ++++ b/numastat.c +@@ -126,7 +126,8 @@ meminfo_t system_meminfo[] = { + { 31, "ShmemPmdMapped", "ShmemPmdMapped" }, + { 32, "HugePages_Total", "HugePages_Total" }, + { 33, "HugePages_Free", "HugePages_Free" }, +- { 34, "HugePages_Surp", "HugePages_Surp" } ++ { 34, "HugePages_Surp", "HugePages_Surp" }, ++ { 35, "KReclaimable", "KReclaimable" } + }; + + #define SYSTEM_MEMINFO_ROWS (sizeof(system_meminfo) / sizeof(system_meminfo[0])) +-- +1.8.3.1 + diff --git a/numactl-2.0.12.tar.gz b/numactl-2.0.12.tar.gz new file mode 100644 index 0000000..55db787 Binary files /dev/null and b/numactl-2.0.12.tar.gz differ diff --git a/numactl.spec b/numactl.spec new file mode 100644 index 0000000..da2310a --- /dev/null +++ b/numactl.spec @@ -0,0 +1,90 @@ +Name: numactl +Version: 2.0.12 +Release: 2 +Summary: Library for tuning for Non Uniform Memory Access machines +License: GPLv2 +URL: https://github.com/numactl/numactl +Source0: https://github.com/numactl/numactl/releases/download/v2.0.12/numactl-2.0.12.tar.gz +BuildRequires: libtool automake autoconf git + +Patch6000: 0007-Fix-Add-ShmemHugePages-and-ShmemPmdMapped-to-system_.patch +Patch6001: 0008-add-missing-policy.patch +Patch6002: 0013-numactl-add-va_end-to-usage-function.patch +Patch6003: 0014-libnuma-cleanup-node-cpu-mask-in-destructor.patch +Patch6004: 0021-Removed-unnecessary-exit-from-memhog.c.patch +Patch6005: 0022-Correct-sysconf-constants.patch +Patch6006: 0024-numastat-Better-diagnostic-when-find-unknown-string-.patch +Patch6007: 0025-numastat-Add-KReclaimable-to-list-of-known-fields-in.patch + +%description +Simple NUMA policy support. It consists of a numactl program to run other +programs with a specific NUMA policy and a libnuma shared library to set +NUMA policy in applications. + +%package libs +Summary: libnuma libraries +License: LGPLv2 and GPLv2 + +%description libs +Libs for numa policy support + +%package devel +Summary: Development package for building Applications that use numa +Requires: %{name}-libs = %{version}-%{release} +License: LGPLv2 and GPLv2 + +%description devel +Development package for numa library calls + +%prep +%autosetup -n %{name}-%{version} -p1 -Sgit + +%build +%configure +%disable_rpath +%make_build CFLAGS="$RPM_OPT_FLAGS -I." + +%install +rm -rf $RPM_BUILD_ROOT +%make_install + +%post libs +/sbin/ldconfig + +%postun libs +/sbin/ldconfig + +%files +%{_bindir}/memhog +%{_bindir}/migspeed +%{_bindir}/migratepages +%{_bindir}/numactl +%{_bindir}/numademo +%{_bindir}/numastat +%{_mandir}/man8/*.8* +%doc README.md +%exclude %{_mandir}/man2/*.2* + +%files libs +%{_libdir}/libnuma.so.1 +%{_libdir}/libnuma.so.1.0.0 +%exclude %{_libdir}/libnuma.a +%exclude %{_libdir}/libnuma.la + +%files devel +%{_libdir}/libnuma.so +%{_libdir}/pkgconfig/numa.pc +%{_includedir}/numa.h +%{_includedir}/numaif.h +%{_includedir}/numacompat1.h +%{_mandir}/man3/*.3* + +%changelog +* Thu Mar 21 2019 lihongjiang - 2.0.12-2 +- Type:enhancement +- ID:NA +- SUG:restart +- DESC:backport patches + +* Mon Sep 10 2018 openEuler Buildteam - 2.0.12-1 +- Package init