getrusage() patch

From: Alex Holden (alexh@zereau.net)
Date: Thu Jul 19 2001 - 09:29:22 EST


This patch fixes Squid's cacheMaxResSize statistic by causing
getrusage() to fill in the ru_maxrss member rather than leave it as 0.
Is it correct?

--- linux-2.4.6-clean/kernel/sys.c Thu Jul 19 12:18:15 2001
+++ linux-2.4.6-getrusage-fixed/kernel/sys.c Thu Jul 19 11:59:24 2001

@@ -1154,6 +1154,7 @@
 int getrusage(struct task_struct *p, int who, struct rusage *ru)
 {
        struct rusage r;
+ struct mm_struct *mm;

        memset((char *) &r, 0, sizeof(r));
        switch (who) {
@@ -1165,6 +1166,13 @@
                        r.ru_minflt = p->min_flt;
                        r.ru_majflt = p->maj_flt;
                        r.ru_nswap = p->nswap;
+ task_lock(p);
+ if((mm = p->mm)) atomic_inc(&mm->mm_users);
+ task_unlock(p);
+ if(mm) {
+ r.ru_maxrss = mm->rss;
+ mmput(mm);
+ }
                        break;
                case RUSAGE_CHILDREN:
                        r.ru_utime.tv_sec =
CT_TO_SECS(p->times.tms_cutime);

--------------------------------------------------------------------
This email has been Scanned for Viruses by Zereau Internet
For Info Tel: +44 (0)1642 867700 | www.zereau.net
-
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/



This archive was generated by hypermail 2b29 : Mon Jul 23 2001 - 21:00:12 EST