]> xenbits.xensource.com Git - xenclient/kernel.git/commitdiff
imported patch CA-14360-loadavg-not-uninterruptible pci-ignore
authort_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:05:56 +0000 (12:05 +0000)
committert_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:05:56 +0000 (12:05 +0000)
fs/proc/proc_misc.c
include/linux/sched.h
kernel/timer.c

index edebc4918c1ef2a4e1261c4390ba73dedafa30e8..500264573b25dd4da2c4a84528e0ff9e74150b36 100644 (file)
@@ -95,6 +95,23 @@ static int loadavg_read_proc(char *page, char **start, off_t off,
        return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+static int loadavg_not_uninterruptible_read_proc(char *page, char **start, off_t off,
+                                int count, int *eof, void *data)
+{
+       int a, b, c;
+       int len;
+
+       a = avenrun_not_uninterruptible[0] + (FIXED_1/200);
+       b = avenrun_not_uninterruptible[1] + (FIXED_1/200);
+       c = avenrun_not_uninterruptible[2] + (FIXED_1/200);
+       len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d (not uninterruptible)\n",
+               LOAD_INT(a), LOAD_FRAC(a),
+               LOAD_INT(b), LOAD_FRAC(b),
+               LOAD_INT(c), LOAD_FRAC(c),
+               nr_running(), nr_threads, last_pid);
+       return proc_calc_metrics(page, start, off, count, eof, len);
+}
+
 static int uptime_read_proc(char *page, char **start, off_t off,
                                 int count, int *eof, void *data)
 {
@@ -660,6 +677,7 @@ void __init proc_misc_init(void)
                int (*read_proc)(char*,char**,off_t,int,int*,void*);
        } *p, simple_ones[] = {
                {"loadavg",     loadavg_read_proc},
+               {"loadavg_not_uninterruptible",     loadavg_not_uninterruptible_read_proc},
                {"uptime",      uptime_read_proc},
                {"meminfo",     meminfo_read_proc},
                {"version",     version_read_proc},
index c7502a678f3b2ed1f956e7179fa0101181687738..ee07ae3ac2f7d52fb6ee8cc8c8469e722b9466eb 100644 (file)
@@ -105,6 +105,7 @@ extern int print_fatal_signals;
  *    11 bit fractions.
  */
 extern unsigned long avenrun[];                /* Load averages */
+extern unsigned long avenrun_not_uninterruptible[];            /* Load averages minus uninterruptible */
 
 #define FSHIFT         11              /* nr of bits of precision */
 #define FIXED_1                (1<<FSHIFT)     /* 1.0 as fixed-point */
index 567eea3debe450ba92b558185c087cd668488060..626abc47edd15a65d1349d579a4ff7ccd338411d 100644 (file)
@@ -1328,6 +1328,14 @@ static unsigned long count_active_tasks(void)
        return nr_active() * FIXED_1;
 }
 
+/*
+ * Nr of running (not uninterruptible) tasks - counted in fixed-point numbers
+ */
+static unsigned long count_running_tasks(void)
+{
+       return nr_running() * FIXED_1;
+}
+
 /*
  * Hmm.. Changed this, as the GNU make sources (load.c) seems to
  * imply that avenrun[] is the standard name for this kind of thing.
@@ -1340,6 +1348,10 @@ unsigned long avenrun[3];
 
 EXPORT_SYMBOL(avenrun);
 
+unsigned long avenrun_not_uninterruptible[3];
+
+EXPORT_SYMBOL(avenrun_not_uninterruptible);
+
 /*
  * calc_load - given tick count, update the avenrun load estimates.
  * This is called while holding a write_lock on xtime_lock.
@@ -1347,6 +1359,7 @@ EXPORT_SYMBOL(avenrun);
 static inline void calc_load(unsigned long ticks)
 {
        unsigned long active_tasks; /* fixed-point */
+       unsigned long running_tasks; /* fixed-point */
        static int count = LOAD_FREQ;
 
        count -= ticks;
@@ -1356,6 +1369,11 @@ static inline void calc_load(unsigned long ticks)
                CALC_LOAD(avenrun[0], EXP_1, active_tasks);
                CALC_LOAD(avenrun[1], EXP_5, active_tasks);
                CALC_LOAD(avenrun[2], EXP_15, active_tasks);
+               /* Normal loadavg minus uninterruptible */
+               running_tasks = count_running_tasks();
+               CALC_LOAD(avenrun_not_uninterruptible[0], EXP_1, running_tasks);
+               CALC_LOAD(avenrun_not_uninterruptible[1], EXP_5, running_tasks);
+               CALC_LOAD(avenrun_not_uninterruptible[2], EXP_15, running_tasks);
        }
 }