Resolves: bz310821
This commit is contained in:
parent
966244dec5
commit
20c188ed63
146
irqbalance-0.55-cputree-parse.patch
Normal file
146
irqbalance-0.55-cputree-parse.patch
Normal file
@ -0,0 +1,146 @@
|
||||
diff -up irqbalance-0.55/irqbalance-0.55/cputree.c.orig irqbalance-0.55/irqbalance-0.55/cputree.c
|
||||
--- irqbalance-0.55/irqbalance-0.55/cputree.c.orig 2006-12-10 15:04:59.000000000 -0500
|
||||
+++ irqbalance-0.55/irqbalance-0.55/cputree.c 2007-09-28 12:43:35.000000000 -0400
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
+#include <ctype.h>
|
||||
+#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@@ -131,34 +133,30 @@ static void fill_cache_domain(void)
|
||||
}
|
||||
|
||||
|
||||
-static void do_one_cpu(char *path)
|
||||
+static void do_one_cpu(int dfd, char *d_name)
|
||||
{
|
||||
struct cpu_core *cpu;
|
||||
FILE *file;
|
||||
char new_path[PATH_MAX];
|
||||
|
||||
/* skip offline cpus */
|
||||
- snprintf(new_path, PATH_MAX, "%s/online", path);
|
||||
- file = fopen(new_path, "r");
|
||||
- if (file) {
|
||||
- char *line = NULL;
|
||||
- size_t size = 0;
|
||||
- if (getline(&line, &size, file)==0)
|
||||
+ snprintf(new_path, PATH_MAX, "%s/online", d_name);
|
||||
+ int fd = openat(dfd, new_path, O_RDONLY);
|
||||
+ if (fd != -1) {
|
||||
+ char buf[1];
|
||||
+ ssize_t n = read(fd, buf, sizeof(buf));
|
||||
+ close(fd);
|
||||
+ if (n != sizeof(buf))
|
||||
return;
|
||||
- fclose(file);
|
||||
- if (line && line[0]=='0') {
|
||||
- free(line);
|
||||
+ if (buf[0] == '0')
|
||||
return;
|
||||
- }
|
||||
- free(line);
|
||||
}
|
||||
|
||||
- cpu = malloc(sizeof(struct cpu_core));
|
||||
+ cpu = calloc(1, sizeof(struct cpu_core));
|
||||
if (!cpu)
|
||||
return;
|
||||
- memset(cpu, 0, sizeof(struct cpu_core));
|
||||
|
||||
- cpu->number = strtoul(&path[27], NULL, 10);
|
||||
+ cpu->number = strtoul(&d_name[3], NULL, 10);
|
||||
|
||||
cpu_set(cpu->number, cpu->mask);
|
||||
|
||||
@@ -170,43 +168,45 @@ static void do_one_cpu(char *path)
|
||||
return;
|
||||
}
|
||||
|
||||
+ char *line = NULL;
|
||||
+ size_t size = 0;
|
||||
|
||||
/* try to read the package mask; if it doesn't exist assume solitary */
|
||||
- snprintf(new_path, PATH_MAX, "%s/topology/core_siblings", path);
|
||||
- file = fopen(new_path, "r");
|
||||
+ snprintf(new_path, PATH_MAX, "%s/topology/core_siblings", d_name);
|
||||
+ fd = openat(dfd, new_path, O_RDONLY);
|
||||
+ file = fd == -1 ? NULL : fdopen(fd, "r");
|
||||
cpu_set(cpu->number, cpu->package_mask);
|
||||
if (file) {
|
||||
- char *line = NULL;
|
||||
- size_t size = 0;
|
||||
if (getline(&line, &size, file))
|
||||
cpumask_parse_user(line, strlen(line), cpu->package_mask);
|
||||
fclose(file);
|
||||
- free(line);
|
||||
- }
|
||||
+ } else if (fd != -1)
|
||||
+ close(fd);
|
||||
|
||||
/* try to read the cache mask; if it doesn't exist assume solitary */
|
||||
/* We want the deepest cache level available so try index1 first, then index2 */
|
||||
cpu_set(cpu->number, cpu->cache_mask);
|
||||
- snprintf(new_path, PATH_MAX, "%s/cache/index1/shared_cpu_map", path);
|
||||
- file = fopen(new_path, "r");
|
||||
+ snprintf(new_path, PATH_MAX, "%s/cache/index1/shared_cpu_map", d_name);
|
||||
+ fd = openat(dfd, new_path, O_RDONLY);
|
||||
+ file = fd == -1 ? NULL : fdopen(fd, "r");
|
||||
if (file) {
|
||||
- char *line = NULL;
|
||||
- size_t size = 0;
|
||||
if (getline(&line, &size, file))
|
||||
cpumask_parse_user(line, strlen(line), cpu->cache_mask);
|
||||
fclose(file);
|
||||
- free(line);
|
||||
- }
|
||||
- snprintf(new_path, PATH_MAX, "%s/cache/index2/shared_cpu_map", path);
|
||||
- file = fopen(new_path, "r");
|
||||
+ } else if (fd != -1)
|
||||
+ close(fd);
|
||||
+
|
||||
+ snprintf(new_path, PATH_MAX, "%s/cache/index2/shared_cpu_map", d_name);
|
||||
+ fd = openat(dfd, new_path, O_RDONLY);
|
||||
+ file = fd == -1 ? NULL : fdopen(fd, "r");
|
||||
if (file) {
|
||||
- char *line = NULL;
|
||||
- size_t size = 0;
|
||||
if (getline(&line, &size, file))
|
||||
cpumask_parse_user(line, strlen(line), cpu->cache_mask);
|
||||
fclose(file);
|
||||
- free(line);
|
||||
- }
|
||||
+ } else if (fd != -1)
|
||||
+ close(fd);
|
||||
+
|
||||
+ free(line);
|
||||
|
||||
/*
|
||||
blank out the banned cpus from the various masks so that interrupts
|
||||
@@ -311,18 +311,19 @@ void parse_cpu_tree(void)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
+ int dfd;
|
||||
|
||||
cpus_complement(unbanned_cpus, banned_cpus);
|
||||
|
||||
dir = opendir("/sys/devices/system/cpu");
|
||||
if (!dir)
|
||||
return;
|
||||
+ dfd = dirfd(dir);
|
||||
do {
|
||||
entry = readdir(dir);
|
||||
- if (entry && strlen(entry->d_name)>3 && strstr(entry->d_name,"cpu")) {
|
||||
- char new_path[PATH_MAX];
|
||||
- sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name);
|
||||
- do_one_cpu(new_path);
|
||||
+ if (entry && strlen(entry->d_name)>3 && memcmp(entry->d_name,"cpu",3) == 0
|
||||
+ && isdigit(entry->d_name[3])) {
|
||||
+ do_one_cpu(dfd, entry->d_name);
|
||||
}
|
||||
} while (entry);
|
||||
closedir(dir);
|
12
irqbalance-pie.patch
Normal file
12
irqbalance-pie.patch
Normal file
@ -0,0 +1,12 @@
|
||||
diff -up irqbalance-0.55/irqbalance-0.55/Makefile.orig irqbalance-0.55/irqbalance-0.55/Makefile
|
||||
--- irqbalance-0.55/irqbalance-0.55/Makefile.orig 2006-12-05 08:15:23.000000000 -0500
|
||||
+++ irqbalance-0.55/irqbalance-0.55/Makefile 2007-09-28 13:35:46.000000000 -0400
|
||||
@@ -5,7 +5,7 @@ all: irqbalance
|
||||
LIBS=bitmap.o irqbalance.o cputree.o procinterrupts.o irqlist.o placement.o activate.o network.o powermode.o numa.o classify.o
|
||||
|
||||
irqbalance: .depend $(LIBS)
|
||||
- gcc -g -O2 -D_FORTIFY_SOURCE=2 -Wall `pkg-config --libs glib-2.0` $(LIBS) -o irqbalance
|
||||
+ gcc -g -D_FORTIFY_SOURCE=2 -Wall -Os -Wl,-z,relro,-z,now -pie -fpie `pkg-config --libs glib-2.0` $(LIBS) -o irqbalance
|
||||
|
||||
clean:
|
||||
rm -f irqbalance *~ *.o .depend
|
@ -1,7 +1,7 @@
|
||||
Summary: IRQ balancing daemon.
|
||||
Name: irqbalance
|
||||
Version: 0.55
|
||||
Release: 4%{?dist}
|
||||
Release: 5%{?dist}
|
||||
Epoch: 2
|
||||
Group: System Environment/Base
|
||||
License: GPL/OSL
|
||||
@ -17,6 +17,9 @@ Obsoletes: kernel-utils
|
||||
BuildRequires: glib2-devel pkgconfig imake
|
||||
Requires: glib2
|
||||
|
||||
Patch0: irqbalance-pie.patch
|
||||
Patch1: irqbalance-0.55-cputree-parse.patch
|
||||
|
||||
%description
|
||||
irqbalance is a daemon that evenly distributes IRQ load across
|
||||
multiple CPUs for enhanced performance.
|
||||
@ -24,6 +27,9 @@ multiple CPUs for enhanced performance.
|
||||
%prep
|
||||
%setup -q -c -a 0
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
|
||||
%build
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
@ -70,6 +76,10 @@ exit 0
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Sep 28 2007 Neil Horman <nhorman@redhat.com> - 2:0.55-5
|
||||
- Install pie patch
|
||||
- Grab Ulis cpuparse cleanup (bz 310821)
|
||||
|
||||
* Wed Aug 29 2007 Fedora Release Engineering <rel-eng at fedoraproject dot org> - 2:0.55-4
|
||||
- Rebuild for selinux ppc32 issue.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user