* [PATCH] [2.5.45] SARQ (Run Queue Statistics) [Update]
@ 2002-11-01 2:52 Lev Makhlis
0 siblings, 0 replies; only message in thread
From: Lev Makhlis @ 2002-11-01 2:52 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton
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.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);
}
/*
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-01 2:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-01 2:52 [PATCH] [2.5.45] SARQ (Run Queue Statistics) [Update] Lev Makhlis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox