Date: Mon, 24 Sep 2001 22:19:23 -0700 From: Peter Wemm <peter@wemm.org> To: Matt Dillon <dillon@earth.backplane.com> Cc: Ian Dowse <iedowse@maths.tcd.ie>, Julian Elischer <julian@elischer.org>, hackers@FreeBSD.ORG Subject: Re: Patch to test kstack usage. Message-ID: <20010925051923.6CA2F3808@overcee.netplex.com.au> In-Reply-To: <200109250426.f8P4Q7a99088@earth.backplane.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/param.h>
#include <sys/user.h>
#include <stdio.h>
#include <stddef.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010925051923.6CA2F3808>
