Skip to contentSkip to conversation

getrusage() patch

DISCUSSION Alex Holden 1 participant 1 message Jul 19, 2001

lore
Share & tools
lore
#0 lore raw

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