fixing some segfaults on non-numa systems

This commit is contained in:
Neil Horman 2011-10-25 09:28:20 -04:00
parent b1b570c5ce
commit 2baeffa6df
3 changed files with 115 additions and 3 deletions

View File

@ -0,0 +1,51 @@
commit 1c4ad25a74b5b613b1d1972668bf41fc128420db
Author: Neil Horman <nhorman@tuxdriver.com>
Date: Mon Oct 24 10:15:49 2011 -0400
Ensure that packages get valid numa node:
On non-numa enabled systems, packages will get a NULL pointer to the
numa node, instead of the implied unspecified node structure. This
resutls in a segfaul. This should fix it.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
diff --git a/cputree.c b/cputree.c
index 31fefab..26a45db 100644
--- a/cputree.c
+++ b/cputree.c
@@ -228,7 +228,7 @@ static void do_one_cpu(char *path)
free(line);
}
- nodeid=0;
+ nodeid=-1;
dir = opendir(path);
do {
entry = readdir(dir);
diff --git a/numa.c b/numa.c
index 9cbbfc0..510fedc 100644
--- a/numa.c
+++ b/numa.c
@@ -127,19 +127,15 @@ static gint compare_node(gconstpointer a, gconstpointer b)
void add_package_to_node(struct topo_obj *p, int nodeid)
{
struct topo_obj find, *node;
- find.number = nodeid;
- GList *entry;
- find.number = nodeid;
- entry = g_list_find_custom(numa_nodes, &find, compare_node);
+ node = get_numa_node(nodeid);
- if (!entry) {
+ if (!node) {
if (debug_mode)
printf("Could not find numa node for node id %d\n", nodeid);
return;
}
- node = entry->data;
if (!p->parent) {
node->children = g_list_append(node->children, p);

View File

@ -0,0 +1,54 @@
commit effc540808e630d1fad423d653c43737e99cc1b6
Author: Neil Horman <nhorman@tuxdriver.com>
Date: Thu Oct 20 10:56:48 2011 -0400
Fix oops on non-numa enabled systems
Some systems aren't numa enabled, but still have devices that indicate they
belong to numa node 0 (rather than -1 as they should). Thats a kernel problem
but we still shouldn't crash as a result (which we will when device get a NULL
numa_node pointer as a result of trying to find non-existant node 0). This
patch fixes the crash by always returning the unspecified node pointer when numa
is disabled
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
diff --git a/classify.c b/classify.c
index 6a20480..bb34f04 100644
--- a/classify.c
+++ b/classify.c
@@ -281,7 +281,7 @@ struct irq_info *add_misc_irq(int irq)
new->irq = irq;
new->type = IRQ_TYPE_LEGACY;
new->class = IRQ_OTHER;
- new->numa_node = get_numa_node(0);
+ new->numa_node = get_numa_node(-1);
interrupts_db = g_list_append(interrupts_db, new);
return new;
}
diff --git a/irqbalance.h b/irqbalance.h
index a1b1e8a..73a0864 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -49,6 +49,7 @@ extern GList *numa_nodes;
extern GList *packages;
extern GList *cache_domains;
extern GList *cpus;
+extern int numa_avail;
enum hp_e {
HINT_POLICY_IGNORE,
diff --git a/numa.c b/numa.c
index 0d93091..9cbbfc0 100644
--- a/numa.c
+++ b/numa.c
@@ -162,6 +162,9 @@ struct topo_obj *get_numa_node(int nodeid)
struct topo_obj find;
GList *entry;
+ if (!numa_avail)
+ return &unspecified_node;
+
if (nodeid == -1)
return &unspecified_node;

View File

@ -1,6 +1,6 @@
Name: irqbalance
Version: 1.0
Release: 2%{?dist}
Release: 3%{?dist}
Epoch: 2
Summary: IRQ balancing daemon
@ -10,9 +10,11 @@ Url: http://irqbalance.org/
Source0: http://irqbalance.googlecode.com/files/irqbalance-%{version}.tbz2
Source1: irqbalance.sysconfig
Patch0: irqbalance-bz746159-no-numa-nodes.patch
Patch1: irqbalance-bz748070-numa-sysfs.patch
Patch2: irqbalance-bz748070-numa-pkg-assign.patch
BuildRequires: autoconf automake libtool libcap-ng
BuildRequires: glib2-devel pkgconfig imake libcap-ng-devel numactl-devel
BuildRequires: autoconf automake libtool libcap-ng numactl-devel
BuildRequires: glib2-devel pkgconfig imake libcap-ng-devel
Requires: numactl
Requires(post): systemd-units
Requires(postun):systemd-units
@ -28,6 +30,8 @@ multiple CPUs for enhanced performance.
%prep
%setup -q -n irqbalance
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
sh ./autogen.sh
@ -77,6 +81,9 @@ fi
/sbin/chkconfig --del irqbalance >/dev/null 2>&1 || :
%changelog
* Fri Oct 21 2011 Neil Horman <nhorman@redhat.com> - 2:1.0-3
- Fix another crash on non-numa systems (bz 748070)
* Mon Oct 17 2011 Neil Horman <nhorman@redhat.com> - 2:1.0-2
- Fix crash for systems with no numa node support