summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-process/numad/Manifest1
-rw-r--r--sys-process/numad/files/numad-0.5-fix-sparse-node-ids.patch53
-rw-r--r--sys-process/numad/numad-0.5_p20180531.ebuild56
3 files changed, 110 insertions, 0 deletions
diff --git a/sys-process/numad/Manifest b/sys-process/numad/Manifest
index 9ca70d36ccab..937bd58cf6f8 100644
--- a/sys-process/numad/Manifest
+++ b/sys-process/numad/Manifest
@@ -1 +1,2 @@
DIST numad-0.5-334278f.tar.bz2 21007 BLAKE2B f226e90e0ad664b0cccd82c060b21cc8b7c4b086220f6eee1cd6e421b32f0efe2be11e66ce749142315f8207e19e635a718a41e5a8dd3ecfda02a96dfbd62798 SHA512 1b4a577f0713bae1386f2064fcb2dcbfb9453e23e7617f40cfff4e56d02a8c26a48c8d03f1ac7aa36e4ba168824572377f84bc669d1dabdc1820c2cdc4c57911
+DIST numad-0.5_p20180531.tar.gz 29797 BLAKE2B 455feba97685b0f0c6dd8ce10227d397b14d51d6fc128805648dd94b627ae61c4889ea4cc17667b9a1953c5122d39972172e05d3e782a313ecedbe7f85bfce41 SHA512 36b0387369b7d23b28ad8b4bd8b27089c304efb8357ad9f6693ff3098c56a3a88e39b30f70d35688e6090f4917250fd40d1aaac084a91310450412a05b8d6746
diff --git a/sys-process/numad/files/numad-0.5-fix-sparse-node-ids.patch b/sys-process/numad/files/numad-0.5-fix-sparse-node-ids.patch
new file mode 100644
index 000000000000..d7d438457826
--- /dev/null
+++ b/sys-process/numad/files/numad-0.5-fix-sparse-node-ids.patch
@@ -0,0 +1,53 @@
+From ab79ec5b6389507b4970d68862abb95d0b2b94c9 Mon Sep 17 00:00:00 2001
+From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
+Date: Jun 17 2019 10:37:48 +0000
+Subject: fix sparse node ids
+
+
+CPU-ids can be sparse due to disabling a subset of CPUs.
+On ppc64le this even will make the node_ids sparse, this is actually pretty
+common on ppc64 when SMT is disabled.
+
+Numad has the assumption of cpu/node-ids always being linear and due to that
+accesses the 'node' array out of bounds. That triggers crashes like the
+following:
+
+ Thread 1 "numad" received signal SIGSEGV, Segmentation fault.
+ #0 0x00000fb6cd2779f4 in bind_process_and_migrate_memory (p=0xfb6fc1e0f70)
+ at numad.c:998
+ #1 0x00000fb6cd27d148 in manage_loads () at numad.c:2225
+ #2 0x00000fb6cd2734dc in main (argc=<optimized out>, argv=<optimized out>)
+ at numad.c:2654
+
+Instead of directly indexing with node_id we need to detect which array
+element has the matching node_id and use that.
+
+Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
+
+---
+
+diff --git a/numad.c b/numad.c
+index a6a7a5d..524bf61 100644
+--- a/numad.c
++++ b/numad.c
+@@ -995,7 +995,18 @@ int bind_process_and_migrate_memory(process_data_p p) {
+ int node_id = 0;
+ while (nodes) {
+ if (ID_IS_IN_LIST(node_id, p->node_list_p)) {
+- OR_LISTS(cpu_bind_list_p, cpu_bind_list_p, node[node_id].cpu_list_p);
++ int id = -1;
++ for (int node_ix = 0; (node_ix < num_nodes); node_ix++) {
++ if (node[node_ix].node_id == node_id) {
++ id = node_ix;
++ break;
++ }
++ }
++ if (id == -1) {
++ numad_log(LOG_CRIT, "Node %d is requested, but unknown\n", node_id);
++ exit(EXIT_FAILURE);
++ }
++ OR_LISTS(cpu_bind_list_p, cpu_bind_list_p, node[id].cpu_list_p);
+ nodes -= 1;
+ }
+ node_id += 1;
+
diff --git a/sys-process/numad/numad-0.5_p20180531.ebuild b/sys-process/numad/numad-0.5_p20180531.ebuild
new file mode 100644
index 000000000000..a778299f0ae4
--- /dev/null
+++ b/sys-process/numad/numad-0.5_p20180531.ebuild
@@ -0,0 +1,56 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic linux-info systemd toolchain-funcs
+
+if [[ ${PV} == 9999 ]]; then
+ EGIT_REPO_URI="https://pagure.io/numad.git"
+ inherit git-r3
+else
+ # sync with fedora (as numad upstream) and add couple of commis.
+ # at time of writing f37 uses 20150602
+ # git archive --format=tar.gz --prefix="${P}/" -o ${P}.tar.gz ${EGIT_COMMIT}
+ EGIT_COMMIT="d696d6c413c5b47b4bbae79e29ea132e52095af3"
+ SRC_URI="https://dev.gentoo.org/~gyakovlev/distfiles/${P}.tar.gz"
+ KEYWORDS="~amd64 -arm ~arm64 ~ppc64 ~s390 ~x86"
+fi
+
+DESCRIPTION="The NUMA daemon that manages application locality"
+HOMEPAGE="http://fedoraproject.org/wiki/Features/numad"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+
+CONFIG_CHECK="~NUMA ~CPUSETS"
+
+PATCHES=(
+ # https://pagure.io/numad/pull-request/3
+ "${FILESDIR}/${PN}-0.5-fix-sparse-node-ids.patch"
+)
+
+src_configure() {
+ tc-export AR CC RANLIB
+
+ # FIXME: https://bugs.gentoo.org/890985
+ # temp workaround
+ filter-flags -D_FORTIFY_SOURCE=3
+ append-cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
+}
+
+src_compile() {
+ emake OPT_CFLAGS="${CFLAGS}"
+}
+
+src_install() {
+ emake prefix="${ED}"/usr install
+
+ newinitd "${FILESDIR}"/numad.initd numad
+ newconfd "${FILESDIR}"/numad.confd numad
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/numad.logrotated numad
+
+ systemd_dounit numad.service
+}