From owner-freebsd-hackers  Mon Aug 19 12:57:57 2002
Delivered-To: freebsd-hackers@freebsd.org
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 691DE37B400; Mon, 19 Aug 2002 12:57:52 -0700 (PDT)
Received: from falcon.mail.pas.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 0BEAC43E65; Mon, 19 Aug 2002 12:57:52 -0700 (PDT)
	(envelope-from tlambert2@mindspring.com)
Received: from pool0621.cvx22-bradley.dialup.earthlink.net ([209.179.200.111] helo=mindspring.com)
	by falcon.mail.pas.earthlink.net with esmtp (Exim 3.33 #1)
	id 17gseq-0000Os-00; Mon, 19 Aug 2002 12:57:48 -0700
Message-ID: <3D614D83.3B08815B@mindspring.com>
Date: Mon, 19 Aug 2002 12:56:51 -0700
From: Terry Lambert <tlambert2@mindspring.com>
X-Mailer: Mozilla 4.79 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Poul-Henning Kamp <phk@freebsd.org>
Cc: current@freebsd.org, hackers@freebsd.org
Subject: Re: phk's JKH list
References: <3592.1029771744@critter.freebsd.dk>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-freebsd-hackers@FreeBSD.ORG
Precedence: bulk
List-ID: <freebsd-hackers.FreeBSD.ORG>
List-Archive: <http://docs.freebsd.org/mail/> (Web Archive)
List-Help: <mailto:majordomo@FreeBSD.ORG?subject=help> (List Instructions)
List-Subscribe: <mailto:majordomo@FreeBSD.ORG?subject=subscribe%20freebsd-hackers>
List-Unsubscribe: <mailto:majordomo@FreeBSD.ORG?subject=unsubscribe%20freebsd-hackers>
X-Loop: FreeBSD.ORG

Poul-Henning Kamp wrote:
> I've started to type in my mental sticky notes, have at it:
> 
>         http://people.freebsd.org/~phk/TODO/

| Kernel stack depth warning. 
| 
| Write a function which checks the amount of kernel stack used and
| print a warning if it exceeds a sysctl-able limit.
| The inserted calls should compile to nothing unless the right kernel
| options is used.
| Instrument the kernel strategically and examine the result.


If this is just for testing purposes, then you probably want to
look at `-finstrument-functions'; by ensuring that stacks are
all aligned on an 8K or so boundary, you can write small assembly
functions named:

	void __cyg_profile_func_enter (void *this_fn, void *call_site);
	void __cyg_profile_func_exit  (void *this_fn, void *call_site);

And check the stack pointer against the previous alignment
address (example: stack address mod 8K := current stack depth).

I've used these for non-statistical profiling (e.g. recording
specific arc's in gprof-usable buckets for kernel profiling,
rather than relying on a statistics clock and the current PC),
but the principle should work the same for this purpose.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message