Date: Saturday, July 2, 2011 @ 11:48:03
  Author: dan
Revision: 130103

upgpkg: irqbalance 0.56-3
add upstream changes and two patches from bug tracker

Added:
  irqbalance/trunk/Fix-detection-of-CPUs-in-sysfs.patch
  irqbalance/trunk/Special-interrupt-counts-line-NMI-may-start-with-a-s.patch
  irqbalance/trunk/current-trunk.patch
Modified:
  irqbalance/trunk/PKGBUILD

------------------------------------------------------------+
 Fix-detection-of-CPUs-in-sysfs.patch                       |   35 +
 PKGBUILD                                                   |   30 +
 Special-interrupt-counts-line-NMI-may-start-with-a-s.patch |   67 +++
 current-trunk.patch                                        |  217 +++++++++++
 4 files changed, 339 insertions(+), 10 deletions(-)

Added: Fix-detection-of-CPUs-in-sysfs.patch
===================================================================
--- Fix-detection-of-CPUs-in-sysfs.patch                                (rev 0)
+++ Fix-detection-of-CPUs-in-sysfs.patch        2011-07-02 15:48:03 UTC (rev 
130103)
@@ -0,0 +1,35 @@
+From: Shawn Bohrer <[email protected]>
+
+Only count directories that match /sys/devices/system/cpu/cpu[0-9]+ as
+CPUs.  Previously any directory that started with cpu was counted which
+caused cpufreq and cpuidle to be counted as CPUs.
+
+Signed-off-by: Shawn Bohrer <[email protected]>
+---
+ cputree.c |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/cputree.c b/cputree.c
+index 3b0c982..b879785 100644
+--- a/cputree.c
++++ b/cputree.c
+@@ -25,6 +25,7 @@
+  */
+ 
+ #include "config.h"
++#include <ctype.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+@@ -321,7 +322,7 @@ void parse_cpu_tree(void)
+               return;
+       do {
+               entry = readdir(dir);
+-                if (entry && strlen(entry->d_name)>3 && 
strstr(entry->d_name,"cpu")) {
++                if (entry && !strncmp(entry->d_name,"cpu", 3) && 
isdigit(entry->d_name[3])) {
+                       char new_path[PATH_MAX];
+                       sprintf(new_path, "/sys/devices/system/cpu/%s", 
entry->d_name);
+                       do_one_cpu(new_path);
+-- 
+1.6.5.2
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2011-07-02 12:50:40 UTC (rev 130102)
+++ PKGBUILD    2011-07-02 15:48:03 UTC (rev 130103)
@@ -3,7 +3,7 @@
 
 pkgname=irqbalance
 pkgver=0.56
-pkgrel=1
+pkgrel=3
 pkgdesc="IRQ balancing daemon for SMP systems"
 arch=('i686' 'x86_64')
 url="http://www.irqbalance.org/";
@@ -13,22 +13,32 @@
 backup=(etc/conf.d/irqbalance)
 source=(http://irqbalance.googlecode.com/files/irqbalance-$pkgver.tbz2
         irqbalance.conf.d
-        irqbalance.rc.d)
+        irqbalance.rc.d
+        current-trunk.patch
+        Fix-detection-of-CPUs-in-sysfs.patch
+        Special-interrupt-counts-line-NMI-may-start-with-a-s.patch)
 md5sums=('cd0c4d3b2bb84778a04fc594ad83949a'
          '336c1ee99818f9ecda1687e34c69fd6b'
-         'fb82fc5d267d39110baf720d81282a7c')
+         'fb82fc5d267d39110baf720d81282a7c'
+         '64df09f54cf80d9ce5ff2751a882032d'
+         '00dcb394dac884c116657ade4fe623ee'
+         'e774aff57054ce3c8b5adc7c3e5a74c2')
 
 build() {
-  cd $srcdir/$pkgname-$pkgver
+  cd "$srcdir/$pkgname-$pkgver"
+  patch -Np0 < ../current-trunk.patch
+  patch -Np1 < ../Fix-detection-of-CPUs-in-sysfs.patch
+  patch -Np1 < ../Special-interrupt-counts-line-NMI-may-start-with-a-s.patch
   ./autogen.sh
-  ./configure
+  ./configure --prefix=/usr
   make
 }
 
 package() {
-  cd $srcdir/$pkgname-$pkgver
-  install -D -m755 irqbalance $pkgdir/usr/sbin/irqbalance
-  install -D -m644 irqbalance.1 $pkgdir/usr/share/man/man1/irqbalance.1
-  install -D -m644 ../irqbalance.conf.d $pkgdir/etc/conf.d/irqbalance
-  install -D -m755 ../irqbalance.rc.d $pkgdir/etc/rc.d/irqbalance
+  cd "$srcdir/$pkgname-$pkgver"
+  make install DESTDIR="$pkgdir"
+  #install -D -m755 irqbalance $pkgdir/usr/sbin/irqbalance
+  #install -D -m644 irqbalance.1 $pkgdir/usr/share/man/man1/irqbalance.1
+  install -D -m644 ../irqbalance.conf.d "$pkgdir"/etc/conf.d/irqbalance
+  install -D -m755 ../irqbalance.rc.d "$pkgdir"/etc/rc.d/irqbalance
 }

Added: Special-interrupt-counts-line-NMI-may-start-with-a-s.patch
===================================================================
--- Special-interrupt-counts-line-NMI-may-start-with-a-s.patch                  
        (rev 0)
+++ Special-interrupt-counts-line-NMI-may-start-with-a-s.patch  2011-07-02 
15:48:03 UTC (rev 130103)
@@ -0,0 +1,67 @@
+From: Shawn Bohrer <[email protected]>
+
+Special interrupt counts line NMI may start with a space
+
+The kernel determines the maximum number of possible IRQs and pads the
+first field of /proc/interrupts appropriately.  With four or more digits
+of precession the special interrupt counts all start with a space
+instead of a letter.  This caused the special interrupt counts to be
+counted on my system and that caused the cpunr count to be off when it
+reached the ERR and MIS lines forcing a CPU rescan.
+
+Signed-off-by: Shawn Bohrer <[email protected]>
+---
+ procinterrupts.c |   24 +++++++++++-------------
+ 1 files changed, 11 insertions(+), 13 deletions(-)
+
+diff --git a/procinterrupts.c b/procinterrupts.c
+index e336efe..322f4de 100644
+--- a/procinterrupts.c
++++ b/procinterrupts.c
+@@ -55,20 +55,18 @@ void parse_proc_interrupts(void)
+               if (getline(&line, &size, file)==0)
+                       break;
+ 
+-
++              number = strtoul(line, &c, 10);
+               /* lines with letters in front are special, like NMI count. 
Ignore */
+-              if (!(line[0]==' ' || (line[0]>='0' && line[0]<='9')))
+-                      break;
+-              c = strchr(line, ':');
+-              if (!c)
++              if (line == c)
++                      continue;
++
++              if (c[0] == ':')
++                      ++c;
++              else
+                       continue;
+-              *c = 0;
+-              c++;
+-              number = strtoul(line, NULL, 10);
++
+               count = 0;
+               cpunr = 0;
+-
+-              c2=NULL;
+               while (1) {
+                       uint64_t C;
+                       C = strtoull(c, &c2, 10);
+@@ -78,11 +76,11 @@ void parse_proc_interrupts(void)
+                       c=c2;
+                       cpunr++;
+               }
+-              if (cpunr != core_count) 
++              if (cpunr != core_count)
+                       need_cpu_rescan = 1;
+-              
++
+               set_interrupt_count(number, count);
+-      }               
++      }
+       fclose(file);
+       free(line);
+ }
+-- 
+1.6.5.2
+

Added: current-trunk.patch
===================================================================
--- current-trunk.patch                         (rev 0)
+++ current-trunk.patch 2011-07-02 15:48:03 UTC (rev 130103)
@@ -0,0 +1,217 @@
+Index: powermode.c
+===================================================================
+--- powermode.c        (.../tags/irqbalance-0.56)      (revision 33)
++++ powermode.c        (.../trunk)     (revision 33)
+@@ -40,7 +40,8 @@
+       char *line = NULL;
+       size_t size = 0;
+       char *c;
+-      uint64_t dummy, irq, softirq;
++      uint64_t dummy __attribute__((unused));
++      uint64_t irq, softirq;
+       file = fopen("/proc/stat", "r");
+       if (!file)
+               return;
+Index: cputree.c
+===================================================================
+--- cputree.c  (.../tags/irqbalance-0.56)      (revision 33)
++++ cputree.c  (.../trunk)     (revision 33)
+@@ -47,6 +47,7 @@
+ /* Users want to be able to keep interrupts away from some cpus; store these 
in a cpumask_t */
+ cpumask_t banned_cpus;
+ 
++cpumask_t cpu_possible_map;
+ 
+ /* 
+    it's convenient to have the complement of banned_cpus available so that 
+@@ -158,6 +159,8 @@
+       memset(cpu, 0, sizeof(struct cpu_core));
+ 
+       cpu->number = strtoul(&path[27], NULL, 10);
++
++      cpu_set(cpu->number, cpu_possible_map);
+       
+       cpu_set(cpu->number, cpu->mask);
+ 
+@@ -219,15 +222,15 @@
+       core_count++;
+ }
+ 
+-static void dump_irqs(int spaces, GList *interrupts)
++static void dump_irqs(int spaces, GList *dump_interrupts)
+ {
+       struct interrupt *irq;
+-      while (interrupts) {
++      while (dump_interrupts) {
+               int i;
+-              for (i=0; i<spaces;i++) printf(" ");
+-              irq = interrupts->data;
++              for (i=0; i<spaces; i++) printf(" ");
++              irq = dump_interrupts->data;
+               printf("Interrupt %i (%s/%u) \n", irq->number, 
classes[irq->class], (unsigned int)irq->workload);
+-              interrupts = g_list_next(interrupts);
++              dump_interrupts = g_list_next(dump_interrupts);
+       }
+ }
+ 
+Index: placement.c
+===================================================================
+--- placement.c        (.../tags/irqbalance-0.56)      (revision 33)
++++ placement.c        (.../trunk)     (revision 33)
+@@ -272,7 +272,7 @@
+               }
+               if ((!cpus_empty(irq->node_mask)) &&
+                   (!cpus_equal(irq->mask, irq->node_mask)) &&
+-                  (!cpus_full(irq->node_mask))) {
++                  (!__cpus_full(&irq->node_mask, num_possible_cpus()))) {
+                       irq->old_mask = irq->mask;
+                       irq->mask = irq->node_mask;
+               }
+Index: cpumask.h
+===================================================================
+--- cpumask.h  (.../tags/irqbalance-0.56)      (revision 33)
++++ cpumask.h  (.../trunk)     (revision 33)
+@@ -1,7 +1,7 @@
+ #ifndef __LINUX_CPUMASK_H
+ #define __LINUX_CPUMASK_H
+ 
+-#define NR_CPUS 256
++#define NR_CPUS 4096
+ /*
+  * Cpumasks provide a bitmap suitable for representing the
+  * set of CPU's in a system, one bit position per CPU number.
+Index: bitmap.c
+===================================================================
+--- bitmap.c   (.../tags/irqbalance-0.56)      (revision 33)
++++ bitmap.c   (.../trunk)     (revision 33)
+@@ -74,6 +74,19 @@
+       return 1;
+ }
+ 
++int __bitmap_weight(const unsigned long *bitmap, int bits)
++{
++      int k, w = 0, lim = bits/BITS_PER_LONG;
++
++      for (k = 0; k < lim; k++)
++              w += hweight_long(bitmap[k]);
++
++      if (bits % BITS_PER_LONG)
++              w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
++
++      return w;
++}
++
+ int __bitmap_equal(const unsigned long *bitmap1,
+               const unsigned long *bitmap2, int bits)
+ {
+Index: irqlist.c
+===================================================================
+--- irqlist.c  (.../tags/irqbalance-0.56)      (revision 33)
++++ irqlist.c  (.../trunk)     (revision 33)
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <dirent.h>
++#include <errno.h>
+ 
+ #include "types.h"
+ #include "irqbalance.h"
+@@ -39,6 +40,7 @@
+ void get_affinity_hint(struct interrupt *irq, int number)
+ {
+       char buf[PATH_MAX];
++      cpumask_t tempmask;
+       char *line = NULL;
+       size_t size = 0;
+       FILE *file;
+@@ -51,7 +53,9 @@
+               fclose(file);
+               return;
+       }
+-      cpumask_parse_user(line, strlen(line), irq->node_mask);
++      cpumask_parse_user(line, strlen(line), tempmask);
++      if (!__cpus_full(&tempmask, num_possible_cpus()))
++              irq->node_mask = tempmask;
+       fclose(file);
+       free(line);
+ }
+@@ -64,7 +68,7 @@
+       DIR *dir;
+       struct dirent *entry;
+       char *c, *c2;
+-      int nr , count = 0;
++      int nr , count = 0, can_set = 1;
+       char buf[PATH_MAX];
+       sprintf(buf, "/proc/irq/%i", number);
+       dir = opendir(buf);
+@@ -77,7 +81,7 @@
+                       size_t size = 0;
+                       FILE *file;
+                       sprintf(buf, "/proc/irq/%i/smp_affinity", number);
+-                      file = fopen(buf, "r");
++                      file = fopen(buf, "r+");
+                       if (!file)
+                               continue;
+                       if (getline(&line, &size, file)==0) {
+@@ -86,7 +90,13 @@
+                               continue;
+                       }
+                       cpumask_parse_user(line, strlen(line), irq->mask);
+-                      fclose(file);
++                      /*
++                       * Check that we can write the affinity, if
++                       * not take it out of the list.
++                       */
++                      fputs(line, file);
++                      if (fclose(file) && errno == EIO)
++                              can_set = 0;
+                       free(line);
+               } else if (strcmp(entry->d_name,"allowed_affinity")==0) {
+                       char *line = NULL;
+@@ -119,7 +129,7 @@
+                       count++;
+ 
+       /* if there is no choice in the allowed mask, don't bother to balance */
+-      if (count<2)
++      if ((count<2) || (can_set == 0))
+                irq->balance_level = BALANCE_NONE;
+               
+ 
+Index: Makefile.am
+===================================================================
+--- Makefile.am        (.../tags/irqbalance-0.56)      (revision 33)
++++ Makefile.am        (.../trunk)     (revision 33)
+@@ -21,7 +21,7 @@
+ # 
+ 
+ AUTOMAKE_OPTIONS = no-dependencies
+-EXTRA_DIST = README INSTALL COPYING autogen.sh m4/cap-ng.m4
++EXTRA_DIST = README INSTALL COPYING autogen.sh cap-ng.m4
+  
+ INCLUDES = -I${top_srcdir} 
+ LIBS = $(CAPNG_LDADD) $(GLIB_LIBS)
+@@ -31,6 +31,7 @@
+ sbin_PROGRAMS = irqbalance
+ irqbalance_SOURCES = activate.c bitmap.c classify.c cputree.c irqbalance.c \
+       irqlist.c network.c numa.c placement.c powermode.c procinterrupts.c
++dist_man_MANS = irqbalance.1
+ 
+ CONFIG_CLEAN_FILES = debug*.list config/*
+ clean-generic:
+Index: network.c
+===================================================================
+--- network.c  (.../tags/irqbalance-0.56)      (revision 33)
++++ network.c  (.../trunk)     (revision 33)
+@@ -160,10 +160,8 @@
+       }
+ 
+       while (!feof(file)) {
+-              uint64_t rxcount;
+-              uint64_t txcount;
+-              uint64_t delta;
+-              int dummy;
++              uint64_t dummy __attribute__((unused));
++              uint64_t rxcount, txcount, delta;
+               char *c, *c2;
+               if (getline(&line, &size, file)==0)
+                       break;

Reply via email to