[2.5.45] SARQ (Run Queue Statistics) [Update]
PATCH 1/1 [2.5.45] SARQ (Run Queue Statistics) [Update]
I am not sure if there is any interest in this, but here is an update of my previous patch for 2.5.45. This version is less intrusive -- it doesn't touch calc_load() or count_active_tasks(). (I figure that since nr_running()/nr_uninterruptible() are now O(NR_CPUS), calling them one extra time per second is no big deal.)
The patch adds two counters in /proc/stat, runque and runocc, similar to those in traditional UNIX systems (usually reported by sar -q), that track the system run queue occupancy.
Every second, 'runque' is incremented by the run queue size, and 'runocc' is incremented by one if the run queue is not empty.
Lev
--------------------------------------------------------------------------
diff -urN linux-2.5.45.orig/fs/proc/proc_misc.clinux-2.5.45/fs/proc/proc_misc.c
fs/proc/proc_misc.c +5 -2
@@ -419,12 +419,15 @@"btime %lu\n" "processes %lu\n" "procs_running %lu\n" -"procs_blocked %u\n" , +"procs_blocked %u\n" +"runque %u %u\n" ,nr_context_switches (), xtime.tv_sec - jif /HZ , total_forks,nr_running (), - atomic_read(&nr_iowait_tasks)); +atomic_read (&nr_iowait_tasks), + kstat.runque, + kstat.runocc);return proc_calc_metrics (page, start, off, count, eof, len); }
diff -urN linux-2.5.45.orig/include/linux/kernel_stat.h linux-2.5.45/include/linux/kernel_stat.h
include/linux/kernel_stat.h +1 -0
@@ -26,6 +26,7 @@unsigned int dk_drive_wio[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_rblk[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_wblk[DK_MAX_MAJOR ][DK_MAX_DISK ]; +unsigned int runque, runocc;#if !defined(CONFIG_ARCH_S390 )unsigned int irqs[NR_CPUS ][NR_IRQS ];#endif
kernel/timer.c +20 -0
@@ -720,6 +720,25 @@ } } +/* +* calc_runq - given tick count, update the runque/runocc counters. +*/ +static inline void calc_runq (unsigned long ticks) +{ +unsigned long active_tasks; +static int count =HZ ; + + count -= ticks; +if (count <0 ) { + count +=HZ ; + active_tasks =nr_running () +nr_uninterruptible (); +if (active_tasks) { + kstat.runque += active_tasks; + kstat.runocc ++; + } + } +} +/* jiffies at the most recent update of wall time */ unsigned long wall_jiffies;
@@ -764,6 +783,7 @@ } last_time_offset =0 ;calc_load (ticks); +calc_runq (ticks); }/*