diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..528b731 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/numactl-2.0.12.tar.gz diff --git a/.numactl.metadata b/.numactl.metadata new file mode 100644 index 0000000..f77fa54 --- /dev/null +++ b/.numactl.metadata @@ -0,0 +1 @@ +8576ef894d2c4d25adddd792593bcd92e711d86f SOURCES/numactl-2.0.12.tar.gz diff --git a/SOURCES/numactl-2.0.12-Update-manpage-description-of-numa_node_to_cpu_updat.patch b/SOURCES/numactl-2.0.12-Update-manpage-description-of-numa_node_to_cpu_updat.patch new file mode 100644 index 0000000..14f07fc --- /dev/null +++ b/SOURCES/numactl-2.0.12-Update-manpage-description-of-numa_node_to_cpu_updat.patch @@ -0,0 +1,28 @@ +From 034ad86281330ccd1cfe22d40698dd15c2453853 Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Mon, 16 Sep 2019 13:50:24 -0700 +Subject: [PATCH 2/2] Update manpage description of numa_node_to_cpu_update() + +--- + numa.3 | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/numa.3 b/numa.3 +index e54cb0b..3e18098 100644 +--- a/numa.3 ++++ b/numa.3 +@@ -799,8 +799,10 @@ will be set to + and \-1 returned. On success 0 is returned. + + .BR numa_node_to_cpu_update () +-Mark the node's cpus bitmask stale, then get the latest bitmask by calling ++Mark cpus bitmask of all nodes stale, then get the latest bitmask by calling + .BR numa_node_to_cpus () ++This allows to update the libnuma state after a CPU hotplug event. The application ++is in charge of detecting CPU hotplug events. + + .BR numa_node_of_cpu () + returns the node that a cpu belongs to. If the user supplies an invalid cpu +-- +2.7.5 + diff --git a/SOURCES/numactl-2.0.12-libnuma-introduce-an-API-to-outdate-cpu-to-node-mapp.patch b/SOURCES/numactl-2.0.12-libnuma-introduce-an-API-to-outdate-cpu-to-node-mapp.patch new file mode 100644 index 0000000..0ef372c --- /dev/null +++ b/SOURCES/numactl-2.0.12-libnuma-introduce-an-API-to-outdate-cpu-to-node-mapp.patch @@ -0,0 +1,183 @@ +From 3cc2e004cd5891a87d8bde2b9ddd814f68d1835a Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Mon, 15 Jul 2019 16:24:39 +0800 +Subject: [PATCH 1/2] libnuma: introduce an API to outdate cpu to node mapping + +numa_node_to_cpus() caches the cpu to node mapping, and not updates it +during the cpu online/offline event. + +Ideally, in order to update the mapping automatically, it requires +something like udev to spy on kernel event socket, and update cache if +event happen. This solution is a little complicated inside a libnuma.so. In +stead of doing so, exposing an API numa_node_to_cpu_outdated() for user, +and saddling the event-detecting task to the user. + +So the user of libnuma can work using either of the following models: + -1. blindless outdate cache if careless about performance + numa_node_to_cpu_outdated(); + numa_node_to_cpu(); + -2. event driven spy on kernel event, if happened, call + numa_node_to_cpu_outdated(); + +Signed-off-by: Pingfan Liu +--- + libnuma.c | 32 ++++++++++++++++++++++++++++---- + numa.3 | 7 +++++++ + numa.h | 2 ++ + versions.ldscript | 1 + + 4 files changed, 38 insertions(+), 4 deletions(-) + +diff --git a/libnuma.c b/libnuma.c +index cac8851..756a171 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -58,7 +58,9 @@ struct bitmask *numa_possible_cpus_ptr = NULL; + struct bitmask *numa_nodes_ptr = NULL; + static struct bitmask *numa_memnode_ptr = NULL; + static unsigned long *node_cpu_mask_v1[NUMA_NUM_NODES]; ++static char node_cpu_mask_v1_stale = 1; + static struct bitmask **node_cpu_mask_v2; ++static char node_cpu_mask_v2_stale = 1; + + WEAK void numa_error(char *where); + +@@ -1272,6 +1274,7 @@ numa_node_to_cpus_v1(int node, unsigned long *buffer, int bufferlen) + int err = 0; + char fn[64]; + FILE *f; ++ char update; + char *line = NULL; + size_t len = 0; + struct bitmask bitmask; +@@ -1287,7 +1290,8 @@ numa_node_to_cpus_v1(int node, unsigned long *buffer, int bufferlen) + } + if (bufferlen > buflen_needed) + memset(buffer, 0, bufferlen); +- if (node_cpu_mask_v1[node]) { ++ update = __atomic_fetch_and(&node_cpu_mask_v1_stale, 0, __ATOMIC_RELAXED); ++ if (node_cpu_mask_v1[node] && !update) { + memcpy(buffer, node_cpu_mask_v1[node], buflen_needed); + return 0; + } +@@ -1328,7 +1332,15 @@ numa_node_to_cpus_v1(int node, unsigned long *buffer, int bufferlen) + + /* slightly racy, see above */ + if (node_cpu_mask_v1[node]) { +- if (mask != buffer) ++ if (update) { ++ /* ++ * There may be readers on node_cpu_mask_v1[], hence it can not ++ * be freed. ++ */ ++ memcpy(node_cpu_mask_v1[node], mask, buflen_needed); ++ free(mask); ++ mask = NULL; ++ } else if (mask != buffer) + free(mask); + } else { + node_cpu_mask_v1[node] = mask; +@@ -1352,6 +1364,7 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) + int nnodes = numa_max_node(); + char fn[64], *line = NULL; + FILE *f; ++ char update; + size_t len = 0; + struct bitmask *mask; + +@@ -1364,7 +1377,8 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) + } + numa_bitmask_clearall(buffer); + +- if (node_cpu_mask_v2[node]) { ++ update = __atomic_fetch_and(&node_cpu_mask_v2_stale, 0, __ATOMIC_RELAXED); ++ if (node_cpu_mask_v2[node] && !update) { + /* have already constructed a mask for this node */ + if (buffer->size < node_cpu_mask_v2[node]->size) { + errno = EINVAL; +@@ -1407,8 +1421,12 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer) + /* slightly racy, see above */ + /* save the mask we created */ + if (node_cpu_mask_v2[node]) { ++ if (update) { ++ copy_bitmask_to_bitmask(mask, node_cpu_mask_v2[node]); ++ numa_bitmask_free(mask); ++ mask = NULL; + /* how could this be? */ +- if (mask != buffer) ++ } else if (mask != buffer) + numa_bitmask_free(mask); + } else { + /* we don't want to cache faulty result */ +@@ -1424,6 +1442,12 @@ __asm__(".symver numa_node_to_cpus_v2,numa_node_to_cpus@@libnuma_1.2"); + make_internal_alias(numa_node_to_cpus_v1); + make_internal_alias(numa_node_to_cpus_v2); + ++void numa_node_to_cpu_update(void) ++{ ++ __atomic_store_n(&node_cpu_mask_v1_stale, 1, __ATOMIC_RELAXED); ++ __atomic_store_n(&node_cpu_mask_v2_stale, 1, __ATOMIC_RELAXED); ++} ++ + /* report the node of the specified cpu */ + int numa_node_of_cpu(int cpu) + { +diff --git a/numa.3 b/numa.3 +index ba00572..e54cb0b 100644 +--- a/numa.3 ++++ b/numa.3 +@@ -124,6 +124,8 @@ numa \- NUMA policy library + .br + .BI "int numa_node_to_cpus(int " node ", struct bitmask *" mask "); + .br ++.BI "void numa_node_to_cpu_update();" ++.br + .BI "int numa_node_of_cpu(int " cpu "); + .sp + .BI "struct bitmask *numa_allocate_cpumask();" +@@ -232,6 +234,7 @@ Most functions in this library are only concerned about numa nodes and + their memory. + The exceptions to this are: + .IR numa_node_to_cpus (), ++.IR numa_node_to_cpu_update (), + .IR numa_node_of_cpu (), + .IR numa_bind (), + .IR numa_run_on_node (), +@@ -795,6 +798,10 @@ will be set to + .I ERANGE + and \-1 returned. On success 0 is returned. + ++.BR numa_node_to_cpu_update () ++Mark the node's cpus bitmask stale, then get the latest bitmask by calling ++.BR numa_node_to_cpus () ++ + .BR numa_node_of_cpu () + returns the node that a cpu belongs to. If the user supplies an invalid cpu + .I errno +diff --git a/numa.h b/numa.h +index 3a8c543..7316d1e 100644 +--- a/numa.h ++++ b/numa.h +@@ -282,6 +282,8 @@ static inline void numa_free_cpumask(struct bitmask *b) + /* Convert node to CPU mask. -1/errno on failure, otherwise 0. */ + int numa_node_to_cpus(int, struct bitmask *); + ++void numa_node_to_cpu_update(void); ++ + /* report the node of the specified cpu. -1/errno on invalid cpu. */ + int numa_node_of_cpu(int cpu); + +diff --git a/versions.ldscript b/versions.ldscript +index 4b04936..23074a0 100644 +--- a/versions.ldscript ++++ b/versions.ldscript +@@ -60,6 +60,7 @@ libnuma_1.1 { + numa_tonodemask_memory; + numa_warn; + numa_exit_on_warn; ++ numa_node_to_cpu_update; + local: + *; + }; +-- +2.7.5 + diff --git a/SOURCES/numactl-2.0.12-numastat-when-reading-no-exist-pid-return-EXIT_FAILU.patch b/SOURCES/numactl-2.0.12-numastat-when-reading-no-exist-pid-return-EXIT_FAILU.patch new file mode 100644 index 0000000..ac5d632 --- /dev/null +++ b/SOURCES/numactl-2.0.12-numastat-when-reading-no-exist-pid-return-EXIT_FAILU.patch @@ -0,0 +1,36 @@ +From 0707807bad2106598d5a73e0adec7ae3c3de284f Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Tue, 21 May 2019 14:13:28 +0800 +Subject: [PATCH] numastat: when reading no-exist pid, return EXIT_FAILURE + +This ease the result query by $? + +Signed-off-by: Pingfan Liu +--- + numastat.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/numastat.c b/numastat.c +index 263bddf..f1a3cc1 100644 +--- a/numastat.c ++++ b/numastat.c +@@ -956,6 +956,8 @@ void show_process_info() { + if (!fs) { + sprintf(buf, "Can't read /proc/%d/numa_maps", pid); + perror(buf); ++ if (num_pids == 1) ++ exit(EXIT_FAILURE); + continue; + } + // Add up sub-category memory used from each node. Must go line by line +@@ -1023,6 +1025,7 @@ void show_process_info() { + if (ferror(fs)) { + sprintf(buf, "Can't read /proc/%d/numa_maps", pid); + perror(buf); ++ exit(EXIT_FAILURE); + } + fclose(fs); + // If showing individual tables, or we just added the last total line, +-- +2.7.5 + diff --git a/SPECS/numactl.spec b/SPECS/numactl.spec new file mode 100644 index 0000000..fa2e8e4 --- /dev/null +++ b/SPECS/numactl.spec @@ -0,0 +1,296 @@ +Name: numactl +Summary: Library for tuning for Non Uniform Memory Access machines +Version: 2.0.12 +Release: 4%{?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 +BuildRequires: libtool automake autoconf + +ExcludeArch: s390 s390x %{arm} + +Patch1: numactl-2.0.12-numastat-when-reading-no-exist-pid-return-EXIT_FAILU.patch +Patch2: numactl-2.0.12-libnuma-introduce-an-API-to-outdate-cpu-to-node-mapp.patch +Patch3: numactl-2.0.12-Update-manpage-description-of-numa_node_to_cpu_updat.patch + +%description +Simple NUMA policy support. It consists of a numactl program to run +other programs with a specific NUMA policy. + +%package libs +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 +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 + +%prep +%setup -q -n %{name}-%{version} +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%build +%configure --prefix=/usr --libdir=%{_libdir} +make clean +make CFLAGS="$RPM_OPT_FLAGS -I." + +%install +rm -rf $RPM_BUILD_ROOT + +make DESTDIR=$RPM_BUILD_ROOT install + +%post -p /sbin/ldconfig +%post libs -p /sbin/ldconfig + +%postun -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig + +%files +%doc README.md +%{_bindir}/numactl +%{_bindir}/numademo +%{_bindir}/numastat +%{_bindir}/memhog +%{_bindir}/migspeed +%{_bindir}/migratepages +%{_mandir}/man8/*.8* +%exclude %{_mandir}/man2/*.2* + +%files libs +%{_libdir}/libnuma.so.1.0.0 +%{_libdir}/libnuma.so.1 + +%files devel +%{_libdir}/libnuma.so +%{_libdir}/pkgconfig/numa.pc +%exclude %{_libdir}/libnuma.a +%exclude %{_libdir}/libnuma.la +%{_includedir}/numa.h +%{_includedir}/numaif.h +%{_includedir}/numacompat1.h +%{_mandir}/man3/*.3* + +%changelog +* Wed Sep 18 2019 Pingfan Liu - 2.0.12-4 +- libnuma: introduce an API to outdate cpu to node mapping + +* Sat Jun 1 2019 Pingfan Liu - 2.0.12-3 +- numastat: bail out if reading no-exist pid + +* Fri May 31 2019 Pingfan Liu - 2.0.12-2 +- numastat: when reading no-exist pid, return EXIT_FAILURE +- Rebase to numactl-2.0.12 + +* Tue Aug 8 2017 Petr Oros - 2.0.9-7 +- Segment fault when numa nodes not sequential or contiguous +- Resolves: #1219445 + +* Mon Dec 14 2015 Petr Holasek - 2.0.9-6 +- confusing warning supressed (bz1270734) + +* Wed Jul 01 2015 Petr Holasek - 2.0.9-5 +- numa_node_to_cpu skips over non-existing nodes (bz1180415) + +* Mon Nov 10 2014 Petr Holasek - 2.0.9-4 +- Fixed missing question mark in dist macro + +* Thu Jul 31 2014 Petr Holasek - 2.0.9-3 +- Fixed hw detect segfault (bz1061874) +- Fixed printing of preferred node for MPOL_BIND (bz1119887) + +* Fri Dec 27 2013 Daniel Mach - 2.0.9-2 +- Mass rebuild 2013-12-27 + +* Fri Oct 25 2013 Petr Holasek - 2.0.9-1 +- rebased to version 2.0.9 (bz1017053) + +* Mon Aug 19 2013 Petr Holasek - 2.0.8-6 +- localalloc manpage option is more verbose (bz881779) + +* Tue Jul 30 2013 Petr Holasek - 2.0.8-5 +- numastat minor bugfixes +- manpage and usage fixes (bz948377) + +* Thu Feb 14 2013 Fedora Release Engineering - 2.0.8-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Tue Jan 22 2013 Petr Holasek - 2.0.8-3 +- deleted empty numastat file + +* Thu Nov 1 2012 Tom Callaway - 2.0.8-2 +- fix license issues + +* Fri Oct 26 2012 Petr Holasek - 2.0.8-1 +- Rebased to version 2.0.8 + +* Fri Jul 20 2012 Fedora Release Engineering - 2.0.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat May 19 2012 Petr Holasek - 2.0.7-6 +- numademo segfault fix (bz823125, bz823127) + +* Sun Apr 15 2012 Petr Holasek - 2.0.7-5 +- Library splitted out of numactl package to numactl-libs + +* Fri Jan 13 2012 Fedora Release Engineering - 2.0.7-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Sun Jan 01 2012 Anton Arapov - 2.0.7-3 +- Include missing manpages + +* Sat Jun 18 2011 Peter Robinson - 2.0.7-2 +- Exclude ARM platforms + +* Fri Apr 15 2011 Anton Arapov - 2.0.7-1 +- Update to latest upstream stable version (bz 696703) + +* Tue Mar 22 2011 Anton Arapov - 2.0.6-2 +- Better manpages (bz 673613) + +* Tue Feb 08 2011 Fedora Release Engineering - 2.0.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Jan 04 2011 Neil Horman - 2.0.6-1 +- Update to latest upstream stable version (bz 666379) + +* Mon Oct 18 2010 Neil Horman - 2.0.5-1 +- Update to latest stable upstream source + +* Mon Feb 15 2010 Neil Horman - 2.0.3-8 +- Remove static libs from numactl (bz 556088) + +* Mon Aug 10 2009 Neil Horman - 2.0.3-7 +- Add destructor to libnuma.so to free allocated memory (bz 516227) + +* Mon Aug 10 2009 Neil Horman - 2.0.3-6 +- Fix obo in nodes_allowed_list strncpy (bz 516223) + +* Sat Jul 25 2009 Fedora Release Engineering - 2.0.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri Jun 26 2009 Neil Horman +- Update to full 2.0.3 version (bz 506795) + +* Wed Jun 17 2009 Neil Horman +- Fix silly libnuma warnings again (bz 499633) + +* Fri May 08 2009 Neil Horman +- Update to 2.0.3-rc3 (bz 499633) + +* Wed Mar 25 2009 Mark McLoughlin - 2.0.2-4 +- Remove warning from libnuma (bz 484552) + +* Wed Feb 25 2009 Fedora Release Engineering - 2.0.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Sep 29 2008 Neil Horman - 2.0.2-2 +- Fix build break due to register selection in asm + +* Mon Sep 29 2008 Neil Horman - 2.0.2-1 +- Update rawhide to version 2.0.2 of numactl + +* Fri Apr 25 2008 Neil Horman - 1.0.2-6 +- Fix buffer size passing and arg sanity check for physcpubind (bz 442521) + +* Fri Mar 14 2008 Neil Horman - 1.0.2-5 +- Fixing spec file to actually apply alpha patch :) + +* Fri Mar 14 2008 Neil Horman - 1.0.2-4 +- Add alpha syscalls (bz 396361) + +* Tue Feb 19 2008 Fedora Release Engineering - 1.0.2-3 +- Autorebuild for GCC 4.3 + +* Thu Dec 20 2007 Neil Horman - 1.0.2-1 +- Update numactl to fix get_mempolicy signature (bz 418551) + +* Fri Dec 14 2007 Neil Horman - 1.0.2-1 +- Update numactl to latest version (bz 425281) + +* Tue Aug 07 2007 Neil Horman - 0.9.8-4 +- Fixing some remaining merge review issues (bz 226207) + +* Fri Aug 03 2007 Neil Horman - 0.9.8-3 +- fixing up merge review (bz 226207) + +* Fri Jan 12 2007 Neil Horman - 0.9.8-2 +- Properly fixed bz 221982 +- Updated revision string to include %{dist} + +* Thu Jan 11 2007 Neil Horman - 0.9.8-1.38 +- Fixed -devel to depend on base package so libnuma.so resolves + +* Thu Sep 21 2006 Neil Horman - 0.9.8-1.36 +- adding nodebind patch for bz 207404 + +* Fri Aug 25 2006 Neil Horman - 0.9.8-1.35 +- moving over libnuma.so to -devel package as well + +* Fri Aug 25 2006 Neil Horman - 0.9.8-1.34 +- split out headers/devel man pages to a devel subpackage + +* Tue Aug 15 2006 Neil Horman - 0.9.8-1.32 +- add patch for broken cpu/nodebind output (bz 201906) + +* Wed Jul 12 2006 Jesse Keating - 0.9.8-1.31 +- rebuild + +* Tue Jun 13 2006 Neil Horman +- Rebased numactl to version 0.9.8 for FC6/RHEL5 + +* Wed Apr 26 2006 Neil Horman +- Added patches for 64 bit overflows and cpu mask problem + +* Fri Mar 10 2006 Bill Nottingham +- rebuild for ppc TLS issue (#184446) + +* Fri Feb 10 2006 Jesse Keating - 0.6.4-1.25.2 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Thu Jul 7 2005 Dave Jones +- numactl doesn't own the manpage dirs. (#161547) + +* Tue Mar 1 2005 Dave Jones +- Rebuild for gcc4 + +* Tue Feb 8 2005 Dave Jones +- rebuild with -D_FORTIFY_SOURCE=2 + +* Wed Nov 10 2004 David Woodhouse +- Fix build on x86_64 + +* Thu Oct 21 2004 David Woodhouse +- Add PPC support + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Sat Jun 05 2004 Warren Togami +- spec cleanup + +* Sat Jun 05 2004 Arjan van de Ven +- initial packaging +