From owner-freebsd-hackers Tue Sep 25 4:47:45 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id 5529837B41E for ; Tue, 25 Sep 2001 04:47:38 -0700 (PDT) Received: from elischer.org (InterJet.elischer.org [192.168.1.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id FAA54711; Tue, 25 Sep 2001 05:28:26 -0700 (PDT) Message-ID: <3BB06BFD.F1870676@elischer.org> Date: Tue, 25 Sep 2001 04:35:25 -0700 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: Peter Wemm Cc: Matt Dillon , Ian Dowse , hackers@FreeBSD.ORG Subject: Re: Patch to test kstack usage. References: <20010925051923.6CA2F3808@overcee.netplex.com.au> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit 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 Peter Wemm wrote: > > 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. usb devices allocate 2K on the stack so if you have them too....... so does openning an atapi cdrom... so a combination of interrupts and those, might consume 4K > > 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 -- +------------------------------------+ ______ _ __ | __--_|\ Julian Elischer | \ U \/ / hard at work in | / \ julian@elischer.org +------>x USA \ a very strange | ( OZ ) \___ ___ | country ! +- X_.---._/ presently in San Francisco \_/ \\ v To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message