public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lev Makhlis <mlev@despammed.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@digeo.com>
Subject: [PATCH] [2.5.45] SARQ (Run Queue Statistics) [Update]
Date: Thu, 31 Oct 2002 21:52:19 -0500	[thread overview]
Message-ID: <200210312152.19067.mlev@despammed.com> (raw)

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);
 }
   
 /*

                 reply	other threads:[~2002-11-01  2:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200210312152.19067.mlev@despammed.com \
    --to=mlev@despammed.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox