Re: 1.3.26 Ooops!

Linus Torvalds (Linus.Torvalds@cs.Helsinki.FI)
Thu, 14 Sep 1995 07:42:15 +0300


The new process allocation stuff (linux now allocates the mm, files, fs
etc structures separately) seems to have brought up a few problems in
getrusage. If you're running 1.3.26 and see Oops messages there, this
small patch should fix that.

(of course, this probably only happens for tcsh which uses wait4(),
which is why I never saw it. Serves people who use that abomination
right 8^)

----------
--- v1.3.26/linux/kernel/sys.c Sun Sep 3 12:27:04 1995
+++ linux/kernel/sys.c Thu Sep 14 07:06:58 1995
@@ -764,6 +764,8 @@
r.ru_utime.tv_usec = CT_TO_USECS(p->utime);
r.ru_stime.tv_sec = CT_TO_SECS(p->stime);
r.ru_stime.tv_usec = CT_TO_USECS(p->stime);
+ if (!p->mm)
+ break;
r.ru_minflt = p->mm->min_flt;
r.ru_majflt = p->mm->maj_flt;
break;
@@ -772,6 +774,8 @@
r.ru_utime.tv_usec = CT_TO_USECS(p->cutime);
r.ru_stime.tv_sec = CT_TO_SECS(p->cstime);
r.ru_stime.tv_usec = CT_TO_USECS(p->cstime);
+ if (!p->mm)
+ break;
r.ru_minflt = p->mm->cmin_flt;
r.ru_majflt = p->mm->cmaj_flt;
break;
@@ -780,6 +784,8 @@
r.ru_utime.tv_usec = CT_TO_USECS(p->utime + p->cutime);
r.ru_stime.tv_sec = CT_TO_SECS(p->stime + p->cstime);
r.ru_stime.tv_usec = CT_TO_USECS(p->stime + p->cstime);
+ if (!p->mm)
+ break;
r.ru_minflt = p->mm->min_flt + p->mm->cmin_flt;
r.ru_majflt = p->mm->maj_flt + p->mm->cmaj_flt;
break;
----------

(this makes sure that we don't try to access the mm information after we
have free'd the process memory maps).

Linus