[PATCH] Support for additional proces performance metrics in 2.3.33

Serge Robyns (serge.robyns@advalvas.be)
Sun, 19 Dec 1999 15:43:37 +0100


This is a multi-part message in MIME format.
--------------75C8ECBDCEE03AAD405588B8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

This is a patch to add support for per proces io metrics.
The patch enables the block accouting for (BSD accounting) and also adds
support for io metrics in the getrusage system call.
It also attempt to add the metrics in the /proc/<pid>/stat file by appending
for lu's
to the line. I choose to append them to avoid breaking tools like top by
inserting new
metrics in places where they expect others. Comments and sugestions on this
issue are
welcome.
I personally think to enrich the kstat interface up to Solaris level or like
HP-UX's pstat interface.

Linus, please try to incorporate at least the framework in the pre 2.4 kernel.

It is an essential source of information for performance and capacity planning
people.
I understand that such metrics means less to desktop environment but for sites
which wants
to deploy Linux as server systems it is a major issue (see for example BMC's
e-bussines strategy).

Maybe some should check the ll_rw_blk patch against SMP as I'm affraid it
isn't SMP safe.
(I using the current process pointer without accuiring any lock).

Currently NT lacks the per-proces io metrics, but Win2000 will.
We don't want to give M$ a chance to be ahead of us if we could be before
them.

Also, while I'm stating my pre-2.4 wiches, it would be nice to incorporate the
kernel-profiling
effort, so that at least the framework will be there for enhancing the kernel.

--
 _______________
/               \
|  Serge Robyns  \_______________________________
|                                                \
| RC&S (Robyns Consulting & Services)             \
| 139, avenue De Fre                               |
| 1180 Uccle - Belgium                             |
|                         \|/                      |
| phone: +32(477)29.66.97 -O- fax: +1(801)469-9358 |
|                         /|\                      |
|                                                  |
|   \|/   mailto:serge.robyns@advalvas.be   \|/    |
\___/o\____ http://web.wanadoo.be/rc.s/ ____/o\____/

--------------75C8ECBDCEE03AAD405588B8 Content-Type: text/plain; charset=us-ascii; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch"

--- ./fs/proc/array.c.orig Fri Nov 12 13:29:47 1999 +++ ./fs/proc/array.c Sun Dec 19 14:54:14 1999 @@ -324,7 +324,7 @@ res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \ -%lu %lu %lu %lu %lu %lu %lu %lu %d %d\n", +%lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %lu %lu\n", task->pid, task->comm, state, @@ -367,7 +367,11 @@ task->nswap, task->cnswap, task->exit_signal, - task->processor); + task->processor, + task->inblock, + task->cinblock, + task->oublock, + task->coublock); return res; } --- ./kernel/acct.c.orig Tue Dec 7 19:14:17 1999 +++ ./kernel/acct.c Sun Dec 19 14:59:34 1999 @@ -318,7 +318,7 @@ vsize = vsize / 1024; ac.ac_mem = encode_comp_t(vsize); ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */ - ac.ac_rw = encode_comp_t(ac.ac_io / 1024); + ac.ac_rw = encode_comp_t(current->inblock + current->oublock); ac.ac_minflt = encode_comp_t(current->min_flt); ac.ac_majflt = encode_comp_t(current->maj_flt); ac.ac_swaps = encode_comp_t(current->nswap); --- ./kernel/sys.c.orig Fri Oct 29 22:19:49 1999 +++ ./kernel/sys.c Sun Dec 19 14:54:59 1999 @@ -962,6 +962,8 @@ r.ru_minflt = p->min_flt; r.ru_majflt = p->maj_flt; r.ru_nswap = p->nswap; + r.ru_inblock = p->inblock; + r.ru_oublock = p->oublock; break; case RUSAGE_CHILDREN: r.ru_utime.tv_sec = CT_TO_SECS(p->times.tms_cutime); @@ -971,6 +973,8 @@ r.ru_minflt = p->cmin_flt; r.ru_majflt = p->cmaj_flt; r.ru_nswap = p->cnswap; + r.ru_inblock = p->cinblock; + r.ru_oublock = p->coublock; break; default: r.ru_utime.tv_sec = CT_TO_SECS(p->times.tms_utime + p->times.tms_cutime); @@ -980,6 +984,8 @@ r.ru_minflt = p->min_flt + p->cmin_flt; r.ru_majflt = p->maj_flt + p->cmaj_flt; r.ru_nswap = p->nswap + p->cnswap; + r.ru_inblock = p->inblock + p->cinblock; + r.ru_oublock = p->oublock + p->coublock; break; } return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0; --- ./kernel/fork.c.orig Sat Nov 20 19:09:05 1999 +++ ./kernel/fork.c Sun Dec 19 14:55:05 1999 @@ -369,6 +369,8 @@ tsk->min_flt = tsk->maj_flt = 0; tsk->cmin_flt = tsk->cmaj_flt = 0; tsk->nswap = tsk->cnswap = 0; + tsk->inblock = tsk->oublock = 0; + tsk->cinblock = tsk->coublock = 0; tsk->mm = NULL; tsk->active_mm = NULL; --- ./kernel/exit.c.orig Mon Nov 8 19:19:19 1999 +++ ./kernel/exit.c Sun Dec 19 15:01:53 1999 @@ -45,6 +45,8 @@ current->cmin_flt += p->min_flt + p->cmin_flt; current->cmaj_flt += p->maj_flt + p->cmaj_flt; current->cnswap += p->nswap + p->cnswap; + current->cinblock += p->inblock + p->cinblock; + current->coublock += p->oublock + p->coublock; free_task_struct(p); } else { printk("task releasing itself\n"); --- ./include/linux/sched.h.orig Tue Dec 7 23:10:48 1999 +++ ./include/linux/sched.h Sun Dec 19 14:56:54 1999 @@ -322,6 +322,7 @@ long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS]; /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap; + unsigned long inblock, oublock, cinblock, coublock; int swappable:1; /* process credentials */ uid_t uid,euid,suid,fsuid; @@ -412,6 +413,7 @@ /* utime */ {0,0,0,0},0, \ /* per CPU times */ {0, }, {0, }, \ /* flt */ 0,0,0,0,0,0, \ +/* in/ou blk */ 0,0,0,0, \ /* swp */ 0, \ /* process credentials */ \ /* uid etc */ 0,0,0,0,0,0,0,0, \ --- ./drivers/block/ll_rw_blk.c.orig Sun Dec 19 14:52:21 1999 +++ ./drivers/block/ll_rw_blk.c Sun Dec 19 14:55:26 1999 @@ -519,6 +519,7 @@ if (buffer_uptodate(bh)) /* Hmmph! Already have it */ goto end_io; kstat.pgpgin++; + current->inblock++; max_req = NR_REQUEST; /* reads take precedence */ break; case WRITERAW: @@ -536,6 +537,7 @@ * requests are only for reads. */ kstat.pgpgout++; + current->oublock++; max_req = (NR_REQUEST * 2) / 3; break; default:

--------------75C8ECBDCEE03AAD405588B8--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/