2002-10-16 20:13:42

by Rik van Riel

[permalink] [raw]
Subject: [PATCH] show nr_running and nr_iowait_tasks

Hi,

this trivial patch, against 2.5-current, exports nr_running
and nr_iowait_tasks in /proc/stat. With this patch in vmstat
will no longer need to walk all the processes in the system
just to determine the number of running and blocked processes.

please apply,

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/ http://distro.conectiva.com/
Current spamtrap: <a href=mailto:"[email protected]">[email protected]</a>


===== fs/proc/proc_misc.c 1.49 vs edited =====
--- 1.49/fs/proc/proc_misc.c Tue Oct 15 20:32:38 2002
+++ edited/fs/proc/proc_misc.c Wed Oct 16 18:17:24 2002
@@ -39,6 +39,7 @@
#include <linux/seq_file.h>
#include <linux/times.h>
#include <linux/profile.h>
+#include <linux/blkdev.h>

#include <asm/uaccess.h>
#include <asm/pgtable.h>
@@ -404,10 +405,14 @@
len += sprintf(page + len,
"\nctxt %lu\n"
"btime %lu\n"
- "processes %lu\n",
+ "processes %lu\n"
+ "procs_running %lu\n"
+ "procs_blocked %u\n",
nr_context_switches(),
xtime.tv_sec - jif / HZ,
- total_forks);
+ total_forks,
+ nr_running(),
+ atomic_read(&nr_iowait_tasks));

return proc_calc_metrics(page, start, off, count, eof, len);
}