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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to