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.c
linux-2.5.45/fs/proc/proc_misc.c
--- linux-2.5.45.orig/fs/proc/proc_misc.c Thu Oct 31 15:34:01 2002
+++ linux-2.5.45/fs/proc/proc_misc.c Thu Oct 31 15:47:19 2002
@@ -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
--- linux-2.5.45.orig/include/linux/kernel_stat.h Sat Oct 19 00:01:50 2002
+++ linux-2.5.45/include/linux/kernel_stat.h Thu Oct 31 15:45:44 2002
@@ -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
diff -urN linux-2.5.45.orig/kernel/timer.c linux-2.5.45/kernel/timer.c
--- linux-2.5.45.orig/kernel/timer.c Thu Oct 31 15:34:05 2002
+++ linux-2.5.45/kernel/timer.c Thu Oct 31 15:54:53 2002
@@ -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);
}
/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/