Hello community, here is the log from the commit of package irqbalance for openSUSE:Factory checked in at 2015-03-19 20:55:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/irqbalance (Old) and /work/SRC/openSUSE:Factory/.irqbalance.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "irqbalance" Changes: -------- --- /work/SRC/openSUSE:Factory/irqbalance/irqbalance.changes 2015-01-24 22:20:02.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.irqbalance.new/irqbalance.changes 2015-03-19 20:55:45.000000000 +0100 @@ -1,0 +2,11 @@ +Mon Mar 16 20:21:29 UTC 2015 - mplus...@suse.com + +- Clenup spec file with spec-cleaner +- Remove bug-893478_warn-once.patch +- Update to 1.0.9 + * PCI quirk support + * System Logging compatibility + * isolcpus inheritance + * Misc. Bugfixes + +------------------------------------------------------------------- Old: ---- bug-893478_warn-once.patch v1.0.8.tar.gz New: ---- v1.0.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ irqbalance.spec ++++++ --- /var/tmp/diff_new_pack.H2CqVQ/_old 2015-03-19 20:55:46.000000000 +0100 +++ /var/tmp/diff_new_pack.H2CqVQ/_new 2015-03-19 20:55:46.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package irqbalance # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: irqbalance -Version: 1.0.8 +Version: 1.0.9 Release: 0 Summary: Balance IRQs on SMP Machines License: GPL-2.0+ @@ -25,15 +25,14 @@ Url: https://github.com/Irqbalance/irqbalance Source: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz Source3: sysconfig.irqbalance -Patch0: bug-893478_warn-once.patch +BuildRequires: libcap-ng-devel BuildRequires: libnuma-devel BuildRequires: libtool +BuildRequires: systemd-rpm-macros BuildRequires: pkgconfig(glib-2.0) Requires(pre): coreutils Requires(pre): fillup -ExclusiveArch: ia64 x86_64 ppc64 ppc64le ppc %sparc -BuildRequires: libcap-ng-devel -BuildRequires: systemd +ExclusiveArch: ia64 x86_64 ppc64 ppc64le ppc %{sparc} %{?systemd_requires} %description @@ -42,12 +41,11 @@ %prep %setup -q -%patch0 -p1 %build NOCONFIGURE=1 ./autogen.sh %configure -make LDFLAGS="-Wl,-z,relro,-z,now" CFLAGS="%{optflags} -fPIE -pie" +make %{?_smp_mflags} LDFLAGS="-Wl,-z,relro,-z,now" CFLAGS="%{optflags} -fPIE -pie" cp %{SOURCE3} . gzip irqbalance.1 @@ -58,11 +56,11 @@ install -m 0644 irqbalance.1.gz %{buildroot}%{_mandir}/man1 mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates/ install -m 0644 sysconfig.irqbalance %{buildroot}%{_localstatedir}/adm/fillup-templates/ -sed -ie "s|EnvironmentFile=.*|EnvironmentFile=/etc/sysconfig/irqbalance|g" misc/irqbalance.service +sed -ie "s|EnvironmentFile=.*|EnvironmentFile=%{_sysconfdir}/sysconfig/irqbalance|g" misc/irqbalance.service # Remove syslog.target in systemd service file; not provided by systemd anymore sed -ie "s|After=syslog.target||g" misc/irqbalance.service install -D -m 0644 misc/irqbalance.service %{buildroot}%{_unitdir}/irqbalance.service -ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcirqbalance +ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcirqbalance %pre %service_add_pre irqbalance.service ++++++ v1.0.8.tar.gz -> v1.0.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/activate.c new/irqbalance-1.0.9/activate.c --- old/irqbalance-1.0.8/activate.c 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/activate.c 2015-03-16 14:31:53.000000000 +0100 @@ -84,11 +84,14 @@ if ((info->hint_policy == HINT_POLICY_SUBSET) && (!cpus_empty(info->affinity_hint))) { cpus_and(applied_mask, applied_mask, info->affinity_hint); - if (!cpus_intersects(applied_mask, unbanned_cpus)) - log(TO_ALL, LOG_WARNING, - "irq %d affinity_hint subset empty\n", - info->irq); - else + if (!cpus_intersects(applied_mask, unbanned_cpus)) { + if (!info->warned) { + info->warned = 1; + log(TO_ALL, LOG_WARNING, + "irq %d affinity_hint subset empty\n", + info->irq); + } + } else valid_mask = 1; } else { valid_mask = 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/bitmap.c new/irqbalance-1.0.9/bitmap.c --- old/irqbalance-1.0.8/bitmap.c 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/bitmap.c 2015-03-16 14:31:53.000000000 +0100 @@ -377,3 +377,87 @@ return 0; } + +/** + * __bitmap_parselist - convert list format ASCII string to bitmap + * @buf: read nul-terminated user string from this buffer + * @buflen: buffer size in bytes. If string is smaller than this + * then it must be terminated with a \0. + * @is_user: location of buffer, 0 indicates kernel space + * @maskp: write resulting mask here + * @nmaskbits: number of bits in mask to be written + * + * Input format is a comma-separated list of decimal numbers and + * ranges. Consecutively set bits are shown as two hyphen-separated + * decimal numbers, the smallest and largest bit numbers set in + * the range. + * + * Returns 0 on success, -errno on invalid input strings. + * Error values: + * %-EINVAL: second number in range smaller than first + * %-EINVAL: invalid character in string + * %-ERANGE: bit number specified too large for mask + */ +int __bitmap_parselist(const char *buf, unsigned int buflen, + int is_user __attribute((unused)), unsigned long *maskp, + int nmaskbits) +{ + int a, b, c, old_c, totaldigits; + int exp_digit, in_range; + + totaldigits = c = 0; + bitmap_zero(maskp, nmaskbits); + do { + exp_digit = 1; + in_range = 0; + a = b = 0; + + /* Get the next cpu# or a range of cpu#'s */ + while (buflen) { + old_c = c; + c = *buf++; + buflen--; + if (isspace(c)) + continue; + + /* + * If the last character was a space and the current + * character isn't '\0', we've got embedded whitespace. + * This is a no-no, so throw an error. + */ + if (totaldigits && c && isspace(old_c)) + return -EINVAL; + + /* A '\0' or a ',' signal the end of a cpu# or range */ + if (c == '\0' || c == ',') + break; + + if (c == '-') { + if (exp_digit || in_range) + return -EINVAL; + b = 0; + in_range = 1; + exp_digit = 1; + continue; + } + + if (!isdigit(c)) + return -EINVAL; + + b = b * 10 + (c - '0'); + if (!in_range) + a = b; + exp_digit = 0; + totaldigits++; + } + if (!(a <= b)) + return -EINVAL; + if (b >= nmaskbits) + return -ERANGE; + while (a <= b) { + set_bit(a, maskp); + a++; + } + } while (buflen && c == ','); + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/bitmap.h new/irqbalance-1.0.9/bitmap.h --- old/irqbalance-1.0.8/bitmap.h 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/bitmap.h 2015-03-16 14:31:53.000000000 +0100 @@ -185,8 +185,8 @@ unsigned long *dst, int nbits); extern int bitmap_scnlistprintf(char *buf, unsigned int len, const unsigned long *src, int nbits); -extern int bitmap_parselist(const char *buf, unsigned long *maskp, - int nmaskbits); +extern int __bitmap_parselist(const char *buf, unsigned int buflen, int is_user, + unsigned long *dst, int nbits); extern void bitmap_remap(unsigned long *dst, const unsigned long *src, const unsigned long *old, const unsigned long *new, int bits); extern int bitmap_bitremap(int oldbit, @@ -351,6 +351,12 @@ return __bitmap_parse(buf, buflen, 0, maskp, nmaskbits); } +static inline int bitmap_parselist(const char *buf, unsigned int buflen, + unsigned long *maskp, int nmaskbits) +{ + return __bitmap_parselist(buf, buflen, 0, maskp, nmaskbits); +} + #endif /* __ASSEMBLY__ */ #endif /* __LINUX_BITMAP_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/classify.c new/irqbalance-1.0.9/classify.c --- old/irqbalance-1.0.8/classify.c 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/classify.c 2015-03-16 14:31:53.000000000 +0100 @@ -5,6 +5,7 @@ #include <sys/types.h> #include <dirent.h> #include <assert.h> +#include <errno.h> #include "irqbalance.h" #include "types.h" @@ -25,33 +26,6 @@ static int map_class_to_level[8] = { BALANCE_PACKAGE, BALANCE_CACHE, BALANCE_CORE, BALANCE_CORE, BALANCE_CORE, BALANCE_CORE, BALANCE_CORE, BALANCE_CORE }; - -#define MAX_CLASS 0x12 -/* - * Class codes lifted from pci spec, appendix D. - * and mapped to irqbalance types here - */ -static short class_codes[MAX_CLASS] = { - IRQ_OTHER, - IRQ_SCSI, - IRQ_ETH, - IRQ_VIDEO, - IRQ_OTHER, - IRQ_OTHER, - IRQ_LEGACY, - IRQ_OTHER, - IRQ_OTHER, - IRQ_LEGACY, - IRQ_OTHER, - IRQ_OTHER, - IRQ_LEGACY, - IRQ_ETH, - IRQ_SCSI, - IRQ_OTHER, - IRQ_OTHER, - IRQ_OTHER, -}; - struct user_irq_policy { int ban; int level; @@ -66,6 +40,221 @@ #define SYSDEV_DIR "/sys/bus/pci/devices" +#define PCI_MAX_CLASS 0x14 +#define PCI_MAX_SERIAL_SUBCLASS 0x81 + +#define PCI_INVAL_DATA 0xFFFFFFFF + +struct pci_info { + unsigned short vendor; + unsigned short device; + unsigned short sub_vendor; + unsigned short sub_device; + unsigned int class; +}; + +/* PCI vendor ID, device ID */ +#define PCI_VENDOR_PLX 0x10b5 +#define PCI_DEVICE_PLX_PEX8619 0x8619 +#define PCI_VENDOR_CAVIUM 0x177d +#define PCI_DEVICE_CAVIUM_CN61XX 0x0093 + +/* PCI subsystem vendor ID, subsystem device ID */ +#define PCI_SUB_VENDOR_EMC 0x1120 +#define PCI_SUB_DEVICE_EMC_055B 0x055b +#define PCI_SUB_DEVICE_EMC_0568 0x0568 +#define PCI_SUB_DEVICE_EMC_dd00 0xdd00 + +/* + * Apply software workarounds for some special devices + * + * The world is not perfect and supplies us with broken PCI devices. + * Usually there are two sort of cases: + * + * 1. The device is special + * Before shipping the devices, PCI spec doesn't have the definitions. + * + * 2. Buggy PCI devices + * Some PCI devices don't follow the PCI class code definitions. + */ +static void apply_pci_quirks(const struct pci_info *pci, int *irq_class) +{ + if ((pci->vendor == PCI_VENDOR_PLX) && + (pci->device == PCI_DEVICE_PLX_PEX8619) && + (pci->sub_vendor == PCI_SUB_VENDOR_EMC)) { + switch (pci->sub_device) { + case PCI_SUB_DEVICE_EMC_055B: + case PCI_SUB_DEVICE_EMC_dd00: + *irq_class = IRQ_SCSI; + break; + } + } + + if ((pci->vendor == PCI_VENDOR_CAVIUM) && + (pci->device == PCI_DEVICE_CAVIUM_CN61XX) && + (pci->sub_vendor == PCI_SUB_VENDOR_EMC)) { + switch (pci->sub_device) { + case PCI_SUB_DEVICE_EMC_0568: + *irq_class = IRQ_SCSI; + break; + } + } + + return; +} + +/* Determin IRQ class based on PCI class code */ +static int map_pci_irq_class(unsigned int pci_class) +{ + unsigned int major = pci_class >> 16; + unsigned int sub = (pci_class & 0xFF00) >> 8; + int irq_class = IRQ_NODEF; + /* + * Class codes lifted from below PCI-SIG spec: + * + * PCI Code and ID Assignment Specification v1.5 + * + * and mapped to irqbalance types here. + * + * IRQ_NODEF will go through classification by PCI sub-class code. + */ + static short major_class_codes[PCI_MAX_CLASS] = { + IRQ_OTHER, + IRQ_SCSI, + IRQ_ETH, + IRQ_VIDEO, + IRQ_OTHER, + IRQ_OTHER, + IRQ_LEGACY, + IRQ_OTHER, + IRQ_OTHER, + IRQ_LEGACY, + IRQ_OTHER, + IRQ_OTHER, + IRQ_NODEF, + IRQ_ETH, + IRQ_SCSI, + IRQ_OTHER, + IRQ_OTHER, + IRQ_OTHER, + IRQ_LEGACY, + IRQ_LEGACY, + }; + + /* + * All sub-class code for serial bus controllers. + * The major class code is 0xc. + */ + static short serial_sub_codes[PCI_MAX_SERIAL_SUBCLASS] = { + IRQ_LEGACY, + IRQ_LEGACY, + IRQ_LEGACY, + IRQ_LEGACY, + IRQ_SCSI, + IRQ_LEGACY, + IRQ_SCSI, + IRQ_LEGACY, + IRQ_LEGACY, + IRQ_LEGACY, + [0xa ... 0x7f] = IRQ_NODEF, + IRQ_LEGACY, + }; + + /* + * Check major class code first + */ + + if (major >= PCI_MAX_CLASS) + return IRQ_NODEF; + + switch (major) { + case 0xc: /* Serial bus class */ + if (sub >= PCI_MAX_SERIAL_SUBCLASS) + return IRQ_NODEF; + irq_class = serial_sub_codes[sub]; + break; + default: /* All other PCI classes */ + irq_class = major_class_codes[major]; + break; + } + + return irq_class; +} + +/* Read specific data from sysfs */ +static unsigned int read_pci_data(const char *devpath, const char* file) +{ + char path[PATH_MAX]; + FILE *fd; + unsigned int data = PCI_INVAL_DATA; + + sprintf(path, "%s/%s", devpath, file); + + fd = fopen(path, "r"); + + if (!fd) { + log(TO_CONSOLE, LOG_WARNING, "PCI: can't open file:%s\n", path); + return data; + } + + (void) fscanf(fd, "%x", &data); + fclose(fd); + + return data; +} + +/* Get pci information for IRQ classification */ +static int get_pci_info(const char *devpath, struct pci_info *pci) +{ + unsigned int data = PCI_INVAL_DATA; + + if ((data = read_pci_data(devpath, "vendor")) == PCI_INVAL_DATA) + return -ENODEV; + pci->vendor = (unsigned short)data; + + if ((data = read_pci_data(devpath, "device")) == PCI_INVAL_DATA) + return -ENODEV; + pci->device = (unsigned short)data; + + if ((data = read_pci_data(devpath, "subsystem_vendor")) == PCI_INVAL_DATA) + return -ENODEV; + pci->sub_vendor = (unsigned short)data; + + if ((data = read_pci_data(devpath, "subsystem_device")) == PCI_INVAL_DATA) + return -ENODEV; + pci->sub_device = (unsigned short)data; + + if ((data = read_pci_data(devpath, "class")) == PCI_INVAL_DATA) + return -ENODEV; + pci->class = data; + + return 0; +} + +/* Return IRQ class for given devpath */ +static int get_irq_class(const char *devpath) +{ + int irq_class = IRQ_NODEF; + struct pci_info pci; + + /* Get PCI info from sysfs */ + if (get_pci_info(devpath, &pci) < 0) + return IRQ_NODEF; + + /* Map PCI class code to irq class */ + irq_class = map_pci_irq_class(pci.class); + if (irq_class < 0) { + log(TO_CONSOLE, LOG_WARNING, "Invalid PCI class code %d\n", + pci.class); + return IRQ_NODEF; + } + + /* Reassign irq class for some buggy devices */ + apply_pci_quirks(&pci, &irq_class); + + return irq_class; +} + static gint compare_ints(gconstpointer a, gconstpointer b) { const struct irq_info *ai = a; @@ -123,7 +312,7 @@ */ static struct irq_info *add_one_irq_to_db(const char *devpath, int irq, struct user_irq_policy *pol) { - int class = 0; + int irq_class = IRQ_OTHER; int rc; struct irq_info *new, find; int numa_node; @@ -159,34 +348,16 @@ interrupts_db = g_list_append(interrupts_db, new); - sprintf(path, "%s/class", devpath); - - fd = fopen(path, "r"); - - if (!fd) { - perror("Can't open class file: "); - goto get_numa_node; - } - - rc = fscanf(fd, "%x", &class); - fclose(fd); - - if (!rc) - goto get_numa_node; - - /* - * Restrict search to major class code - */ - class >>= 16; - - if (class >= MAX_CLASS) + /* Map PCI class code to irq class */ + irq_class = get_irq_class(devpath); + if (irq_class < 0) goto get_numa_node; - new->class = class_codes[class]; + new->class = irq_class; if (pol->level >= 0) new->level = pol->level; else - new->level = map_class_to_level[class_codes[class]]; + new->level = map_class_to_level[irq_class]; get_numa_node: numa_node = -1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/configure.ac new/irqbalance-1.0.9/configure.ac --- old/irqbalance-1.0.8/configure.ac 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/configure.ac 2015-03-16 14:31:53.000000000 +0100 @@ -1,4 +1,4 @@ -AC_INIT(irqbalance,1.0.8) +AC_INIT(irqbalance,1.0.9) AC_PREREQ(2.12)dnl AM_CONFIG_HEADER(config.h) @@ -30,6 +30,17 @@ AC_C_INLINE AM_PROG_CC_C_O +AC_ARG_WITH([systemd], + [ AS_HELP_STRING([--with-systemd],[Add systemd-lib support])] +) +AS_IF( + [test "x$with_systemd" = xyes], [ + PKG_CHECK_MODULES([SYSTEMD], [libsystemd-journal], [journal_lib=yes]) + AC_DEFINE(HAVE_LIBSYSTEMD, 1, [systemd support]) + AC_CHECK_LIB([systemd], [sd_journal_print_with_location]) + AC_CHECK_LIB([systemd], [sd_journal_print]) +]) + AC_ARG_WITH([glib2], [AS_HELP_STRING([--without-glib2], [Don't use system glib2 library. Use local implementation instead.])], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/cpumask.h new/irqbalance-1.0.9/cpumask.h --- old/irqbalance-1.0.8/cpumask.h 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/cpumask.h 2015-03-16 14:31:53.000000000 +0100 @@ -281,10 +281,10 @@ return bitmap_scnlistprintf(buf, len, srcp->bits, nbits); } -#define cpulist_parse(buf, dst) __cpulist_parse((buf), &(dst), NR_CPUS) -static inline int __cpulist_parse(const char *buf, cpumask_t *dstp, int nbits) +#define cpulist_parse(buf, len, dst) __cpulist_parse((buf), (len), &(dst), NR_CPUS) +static inline int __cpulist_parse(const char *buf, int len, cpumask_t *dstp, int nbits) { - return bitmap_parselist(buf, dstp->bits, nbits); + return bitmap_parselist(buf, len, dstp->bits, nbits); } #define cpu_remap(oldbit, old, new) \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/cputree.c new/irqbalance-1.0.9/cputree.c --- old/irqbalance-1.0.8/cputree.c 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/cputree.c 2015-03-16 14:31:53.000000000 +0100 @@ -58,6 +58,48 @@ */ cpumask_t unbanned_cpus; +/* + * By default do not place IRQs on CPUs the kernel keeps isolated, + * as specified through the isolcpus= boot commandline. Users can + * override this with the IRQBALANCE_BANNED_CPUS environment variable. + */ +static void setup_banned_cpus(void) +{ + FILE *file; + char *c, *line = NULL; + size_t size = 0; + const char *isolcpus = "isolcpus="; + char buffer[4096]; + + /* A manually specified cpumask overrides auto-detection. */ + if (getenv("IRQBALANCE_BANNED_CPUS")) { + cpumask_parse_user(getenv("IRQBALANCE_BANNED_CPUS"), strlen(getenv("IRQBALANCE_BANNED_CPUS")), banned_cpus); + goto out; + } + + file = fopen("/proc/cmdline", "r"); + if (!file) + goto out; + + if (getline(&line, &size, file) <= 0) + goto out; + + if ((c = strstr(line, isolcpus))) { + char *end; + int len; + + c += strlen(isolcpus); + for (end = c; *end != ' ' && *end != '\0' && *end != '\n'; end++); + len = end - c; + + cpulist_parse(c, len, banned_cpus); + } + + out: + cpumask_scnprintf(buffer, 4096, banned_cpus); + log(TO_CONSOLE, LOG_INFO, "Isolated CPUs: %s\n", buffer); +} + static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache, int packageid, cpumask_t package_mask) { @@ -234,7 +276,6 @@ cpu_set(cpu->number, cache_mask); max_cache_index = 0; cache_index = 1; - cache_stat = 0; do { struct stat sb; snprintf(new_path, PATH_MAX, "%s/cache/index%d/shared_cpu_map", path, cache_index); @@ -295,15 +336,21 @@ { int spaces = (long int)data; int i; - for (i=0; i<spaces; i++) log(TO_CONSOLE, LOG_INFO, " "); - log(TO_CONSOLE, LOG_INFO, "Interrupt %i node_num is %d (%s/%u) \n", + char * indent = malloc (sizeof(char) * (spaces + 1)); + + for ( i = 0; i < spaces; i++ ) + indent[i] = log_indent[0]; + + indent[i] = '\0'; + log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%u) \n", indent, info->irq, irq_numa_node(info)->number, classes[info->class], (unsigned int)info->load); } static void dump_topo_obj(struct topo_obj *d, void *data __attribute__((unused))) { struct topo_obj *c = (struct topo_obj *)d; - log(TO_CONSOLE, LOG_INFO, " CPU number %i numa_node is %d (load %lu)\n", + log(TO_CONSOLE, LOG_INFO, "%s%s%s%sCPU number %i numa_node is %d (load %lu)\n", + log_indent, log_indent, log_indent, log_indent, c->number, cpu_numa_node(c)->number , (unsigned long)c->load); if (c->interrupts) for_each_irq(c->interrupts, dump_irq, (void *)18); @@ -313,7 +360,8 @@ { char *buffer = data; cpumask_scnprintf(buffer, 4095, d->mask); - log(TO_CONSOLE, LOG_INFO, " Cache domain %i: numa_node is %d cpu mask is %s (load %lu) \n", + log(TO_CONSOLE, LOG_INFO, "%s%sCache domain %i: numa_node is %d cpu mask is %s (load %lu) \n", + log_indent, log_indent, d->number, cache_domain_numa_node(d)->number, buffer, (unsigned long)d->load); if (d->children) for_each_object(d->children, dump_topo_obj, NULL); @@ -366,6 +414,8 @@ DIR *dir; struct dirent *entry; + setup_banned_cpus(); + cpus_complement(unbanned_cpus, banned_cpus); dir = opendir("/sys/devices/system/cpu"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/irqbalance.1 new/irqbalance-1.0.9/irqbalance.1 --- old/irqbalance-1.0.8/irqbalance.1 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/irqbalance.1 2015-03-16 14:31:53.000000000 +0100 @@ -46,6 +46,10 @@ Causes irqbalance to run in the foreground (without --debug). .TP +.B -j, --journal +Enables log output optimized for systemd-journal. + +.TP .B -h, --hintpolicy=[exact | subset | ignore] Set the policy for how IRQ kernel affinity hinting is treated. Can be one of: .P @@ -125,7 +129,7 @@ .B -s, --pid=<file> Have irqbalance write its process id to the specified file. By default no pidfile is written. The written pidfile is automatically unlinked when -irqbalance exits. +irqbalance exits. It is ignored when used with --debug or --foreground. .SH "ENVIRONMENT VARIABLES" .TP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/irqbalance.c new/irqbalance-1.0.9/irqbalance.c --- old/irqbalance-1.0.8/irqbalance.c 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/irqbalance.c 2015-03-16 14:31:53.000000000 +0100 @@ -46,8 +46,10 @@ int debug_mode; int foreground_mode; int numa_avail; +int journal_logging = 0; int need_rescan; unsigned int log_mask = TO_ALL; +char * log_indent; enum hp_e global_hint_policy = HINT_POLICY_IGNORE; unsigned long power_thresh = ULONG_MAX; unsigned long deepest_cache = 2; @@ -83,12 +85,13 @@ {"deepestcache", 1, NULL, 'c'}, {"policyscript", 1, NULL, 'l'}, {"pid", 1, NULL, 's'}, + {"journal", 0, NULL, 'j'}, {0, 0, 0, 0} }; static void usage(void) { - log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--hintpolicy= | -h [exact|subset|ignore]]\n"); + log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy= | -h [exact|subset|ignore]]\n"); log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>] [--policyscript=<script>] [--pid= | -s <file>] [--deepestcache= | -c <n>]\n"); } @@ -99,7 +102,7 @@ unsigned long val; while ((opt = getopt_long(argc, argv, - "odfh:i:p:s:c:b:l:", + "odfjh:i:p:s:c:b:l:", lopts, &longind)) != -1) { switch(opt) { @@ -173,6 +176,10 @@ case 's': pidfile = optarg; break; + case 'j': + journal_logging=1; + foreground_mode=1; + break; } } } @@ -238,10 +245,18 @@ int main(int argc, char** argv) { struct sigaction action, hupaction; + sigset_t sigset, old_sigset; + sigemptyset(&sigset); + sigaddset(&sigset,SIGINT); + sigaddset(&sigset,SIGHUP); + sigaddset(&sigset,SIGTERM); + sigaddset(&sigset,SIGUSR1); + sigaddset(&sigset,SIGUSR2); + sigprocmask(SIG_BLOCK, &sigset, &old_sigset); #ifdef HAVE_GETOPT_LONG parse_command_line(argc, argv); -#else +#else /* ! HAVE_GETOPT_LONG */ if (argc>1 && strstr(argv[1],"--debug")) { debug_mode=1; foreground_mode=1; @@ -250,17 +265,17 @@ foreground_mode=1; if (argc>1 && strstr(argv[1],"--oneshot")) one_shot_mode=1; -#endif + if (argc>1 && strstr(argv[1],"--journal")) { + journal_logging=1; + foreground_mode=1; + } +#endif /* HAVE_GETOPT_LONG */ /* * Open the syslog connection */ openlog(argv[0], 0, LOG_DAEMON); - if (getenv("IRQBALANCE_BANNED_CPUS")) { - cpumask_parse_user(getenv("IRQBALANCE_BANNED_CPUS"), strlen(getenv("IRQBALANCE_BANNED_CPUS")), banned_cpus); - } - if (getenv("IRQBALANCE_ONESHOT")) one_shot_mode=1; @@ -271,6 +286,11 @@ * If we are't in debug mode, don't dump anything to the console * note that everything goes to the console before we check this */ + if (journal_logging) + log_indent = strdup("...."); + else + log_indent = strdup(" "); + if (!debug_mode) log_mask &= ~TO_CONSOLE; @@ -279,6 +299,9 @@ } else log(TO_CONSOLE, LOG_INFO, "This machine seems not NUMA capable.\n"); + if (geteuid() != 0) + log(TO_ALL, LOG_WARNING, "Irqbalance hasn't been executed under root privileges, thus it won't in fact balance interrupts.\n"); + if (banscript) { char *note = "Please note that --banscript is deprecated, please use --policyscript instead"; log(TO_ALL, LOG_WARNING, "%s\n", note); @@ -290,11 +313,6 @@ HZ = 100; } - action.sa_handler = handler; - sigemptyset(&action.sa_mask); - action.sa_flags = 0; - sigaction(SIGINT, &action, NULL); - build_object_tree(); if (debug_mode) dump_object_tree(); @@ -324,6 +342,20 @@ } } + action.sa_handler = handler; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); + sigaction(SIGUSR1, &action, NULL); + sigaction(SIGUSR2, &action, NULL); + + hupaction.sa_handler = force_rescan; + sigemptyset(&hupaction.sa_mask); + hupaction.sa_flags = 0; + sigaction(SIGHUP, &hupaction, NULL); + + sigprocmask(SIG_SETMASK, &old_sigset, NULL); #ifdef HAVE_LIBCAP_NG // Drop capabilities @@ -337,11 +369,6 @@ parse_proc_interrupts(); parse_proc_stat(); - hupaction.sa_handler = force_rescan; - sigemptyset(&hupaction.sa_mask); - hupaction.sa_flags = 0; - sigaction(SIGHUP, &hupaction, NULL); - while (keep_going) { sleep_approx(SLEEP_INTERVAL); log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/irqbalance.h new/irqbalance-1.0.9/irqbalance.h --- old/irqbalance-1.0.8/irqbalance.h 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/irqbalance.h 2015-03-16 14:31:53.000000000 +0100 @@ -12,12 +12,17 @@ #include <limits.h> #include "types.h" +#include "config.h" #ifdef HAVE_NUMA_H #include <numa.h> #else #define numa_available() -1 #endif +#ifdef HAVE_LIBSYSTEMD +#include <systemd/sd-journal.h> +#endif + extern int package_count; extern int cache_domain_count; extern int core_count; @@ -60,6 +65,7 @@ }; extern int debug_mode; +extern int journal_logging; extern int one_shot_mode; extern int need_rescan; extern enum hp_e global_hint_policy; @@ -134,13 +140,34 @@ #define TO_CONSOLE (1 << 1) #define TO_ALL (TO_SYSLOG | TO_CONSOLE) +extern char * log_indent; extern unsigned int log_mask; -#define log(mask, lvl, fmt, args...) do {\ - if (log_mask & mask & TO_SYSLOG)\ - syslog(lvl, fmt, ##args);\ - if (log_mask & mask & TO_CONSOLE)\ - printf(fmt, ##args);\ +#ifdef HAVE_LIBSYSTEMD +#define log(mask, lvl, fmt, args...) do { \ + if (journal_logging) { \ + sd_journal_print(lvl, fmt, ##args); \ + if (log_mask & mask & TO_CONSOLE) \ + printf(fmt, ##args); \ + } else { \ + if (log_mask & mask & TO_SYSLOG) \ + syslog(lvl, fmt, ##args); \ + if (log_mask & mask & TO_CONSOLE) \ + printf(fmt, ##args); \ + } \ }while(0) +#else /* ! HAVE_LIBSYSTEMD */ +#define log(mask, lvl, fmt, args...) do { \ + if (journal_logging) { \ + printf("<%d>", lvl); \ + printf(fmt, ##args); \ + } else { \ + if (log_mask & mask & TO_SYSLOG) \ + syslog(lvl, fmt, ##args); \ + if (log_mask & mask & TO_CONSOLE) \ + printf(fmt, ##args); \ + } \ +}while(0) +#endif /* HAVE_LIBSYSTEMD */ -#endif +#endif /* __INCLUDE_GUARD_IRQBALANCE_H_ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/irqbalance-1.0.8/types.h new/irqbalance-1.0.9/types.h --- old/irqbalance-1.0.8/types.h 2014-12-17 16:11:44.000000000 +0100 +++ new/irqbalance-1.0.9/types.h 2015-03-16 14:31:53.000000000 +0100 @@ -13,6 +13,7 @@ /* * IRQ Classes */ +#define IRQ_NODEF -1 #define IRQ_OTHER 0 #define IRQ_LEGACY 1 #define IRQ_SCSI 2 @@ -70,6 +71,7 @@ uint64_t load; int moved; struct topo_obj *assigned_obj; + unsigned int warned; }; #endif -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org