From owner-freebsd-hackers Mon Sep 24 22:19:31 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from peter3.wemm.org (c1315225-a.plstn1.sfba.home.com [24.14.150.180]) by hub.freebsd.org (Postfix) with ESMTP id 24C6737B40D for ; Mon, 24 Sep 2001 22:19:24 -0700 (PDT) Received: from overcee.netplex.com.au (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id f8P5JNM20685 for ; Mon, 24 Sep 2001 22:19:23 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id 6CA2F3808; Mon, 24 Sep 2001 22:19:23 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Matt Dillon Cc: Ian Dowse , Julian Elischer , hackers@FreeBSD.ORG Subject: Re: Patch to test kstack usage. In-Reply-To: <200109250426.f8P4Q7a99088@earth.backplane.com> Date: Mon, 24 Sep 2001 22:19:23 -0700 From: Peter Wemm Message-Id: <20010925051923.6CA2F3808@overcee.netplex.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Matt Dillon wrote: > This isn't perfect but it should be a good start in regards to > testing kstack use. This patch is against -stable. It reports > kernel stack use on process exit and will generate a 'Kernel stack > underflow' message if it detects an underflow. It doesn't panic, > so for a fun time you can leave UPAGES at 2 and watch in horror. It is checking against the wrong guard value. It should be u_guard2. FWIW; the max stack available is 4688 bytes on a standard 4.x system. Yes, that is too freaking close. Also, the maximum usage depends on what sort of cards you have in the system.. If you have a heavy tty user (eg: a 32+ port serial card) then you have lots of tty interrupts nesting as well. Having the ppp/sl/plip drivers in the system partly negates the effect of this though since it wires the net/tty interrupt masks together. peter@thunder[10:13pm]~-111> ./tu stack base = 3504 stack size = 4688 peter@thunder[10:13pm]~-112> cat tu.c #include #include #include #include int main(int ac, char **av) { int stack_base = offsetof(struct user, u_kproc); printf("stack base = %d\n", stack_base); printf("stack size = %d\n", UPAGES * PAGE_SIZE - stack_base); } > --- sys/user.h 1999/12/29 04:24:49 1.24 > +++ sys/user.h 2001/09/25 03:41:04 > @@ -109,9 +109,13 @@ > * Remaining fields only for core dump and/or ptrace-- > * not valid at other times! > */ > + u_int32_t u_guard2; /* guard the base of the kstack */ > struct kinfo_proc u_kproc; /* proc + eproc */ > struct md_coredump u_md; /* machine dependent glop */ > + u_int32_t u_guard; /* guard the base of the kstack */ > }; Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message