From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Jonathan Lundell <linux@lundell-bros.com>,
root@chaos.analogic.com,
Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: top stack (l)users for 2.5.69
Date: Thu, 8 May 2003 10:41:01 +0200 [thread overview]
Message-ID: <20030508084101.GE1469@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <3EB96916.7080900@us.ibm.com>
On Wed, 7 May 2003 13:14:14 -0700, Dave Hansen wrote:
> Jörn Engel wrote:
> >>The stack overflow checking in -mjb uses gcc's mcount mechanism to
> >>detect overflows. It should get called on every single function call.
> >
> > Nice trick. Do you have better documentation on that machanism than
> > man gcc? The paragraph to -p is quite short and I cannot make the
> > connection to the rest of the patch immediately.
>
> It is a nice trick, but I didn't write it :) I stole the code from Ben
> LaHaise, around 2.5.20. All that I've needed to know to maintain the
> patch is that a "jmp mcount" gets placed in the critical places.
Sure. But exactly that information is not contained in the manpage (as
of Debians 3.2.3). I guess I'll have to dig deeper.
> I've attached a fairly recent version of the stack check patch. If you
> need some more examples, check out kernprof's use of it. It's acg
> functionality used mcount as well.
Oh, kernprof was too advanced already. It basically worked out of the
box for me, porting it to ppc took maybe one hour, not counting a
linker problem that was loosely related to that patch. Never bothered
to really understand what it does. :(
> diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
> --- a/arch/i386/kernel/process.c Mon Jan 27 11:40:03 2003
> +++ b/arch/i386/kernel/process.c Mon Jan 27 11:40:03 2003
> @@ -159,7 +159,22 @@
>
> __setup("idle=", idle_setup);
>
> -void show_regs(struct pt_regs * regs)
> +void stack_overflow(unsigned long esp, unsigned long eip)
> +{
> + int panicing = ((esp&(THREAD_SIZE-1)) <= STACK_PANIC);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +
> + if (panicing)
> + print_symbol("stack overflow from %s\n", eip);
> + else
> + print_symbol("excessive stack use from %s\n", eip);
> + printk("esp: %p\n", (void*)esp);
> + show_trace((void*)esp);
> +
> + if (panicing)
> + panic("stack overflow\n");
> +}
> +
> +asmlinkage void show_regs(struct pt_regs * regs)
> {
> unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
>
> diff -Nru a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
> --- a/include/asm-i386/thread_info.h Mon Jan 27 11:40:03 2003
> +++ b/include/asm-i386/thread_info.h Mon Jan 27 11:40:03 2003
> @@ -63,6 +63,8 @@
> */
> #define THREAD_ORDER 1
> #define INIT_THREAD_SIZE THREAD_SIZE
> +#define STACK_PANIC 0x200ul
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +#define STACK_WARN ((THREAD_SIZE)>>1)
>
> #ifndef __ASSEMBLY__
If I read this correctly, your patch doesn't catch everything, if
there are functions remaining that use stack frames >0x200ul. Ok,
tell me I'm wrong and should go through the assembler code first.
Jörn
--
Fantasy is more important than knowlegde. Knowlegde is limited,
while fantasy embraces the whole world.
-- Albert Einstein
next prev parent reply other threads:[~2003-05-08 8:28 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-07 13:20 top stack (l)users for 2.5.69 Jörn Engel
2003-05-07 13:45 ` Richard B. Johnson
2003-05-07 13:56 ` Jörn Engel
2003-05-07 14:16 ` Richard B. Johnson
2003-05-07 17:13 ` Jonathan Lundell
2003-05-07 17:40 ` Richard B. Johnson
2003-05-07 18:12 ` Roland Dreier
2003-05-07 18:28 ` Richard B. Johnson
2003-05-07 18:44 ` Timothy Miller
2003-05-07 18:46 ` Roland Dreier
2003-05-07 19:30 ` Richard B. Johnson
2003-05-07 19:42 ` Roland Dreier
2003-05-07 20:04 ` Richard B. Johnson
2003-05-07 20:23 ` Roland Dreier
2003-05-07 20:42 ` Timothy Miller
2003-05-08 9:06 ` Jörn Engel
2003-05-08 11:33 ` Richard B. Johnson
2003-05-08 12:00 ` Helge Hafting
2003-05-08 15:42 ` Timothy Miller
2003-05-09 8:57 ` Miles Bader
2003-05-09 16:50 ` Timothy Miller
2003-05-08 16:47 ` Davide Libenzi
2003-05-07 18:51 ` Davide Libenzi
2003-05-07 19:22 ` Richard B. Johnson
2003-05-07 19:31 ` Davide Libenzi
2003-05-07 19:39 ` Hua Zhong
2003-05-07 21:47 ` Martin J. Bligh
2003-05-08 10:29 ` David Howells
2003-05-07 17:55 ` Jörn Engel
2003-05-07 16:20 ` Martin J. Bligh
2003-05-07 19:01 ` Dave Hansen
2003-05-07 20:06 ` Jörn Engel
2003-05-07 20:14 ` Dave Hansen
2003-05-08 8:41 ` Jörn Engel [this message]
2003-05-08 16:51 ` Dave Hansen
2003-05-08 22:12 ` Jörn Engel
2003-05-07 21:30 ` Jesse Pollard
2003-05-07 21:54 ` Timothy Miller
2003-05-07 22:01 ` Jesse Pollard
2003-05-07 14:33 ` Torsten Landschoff
2003-05-07 14:47 ` William Lee Irwin III
2003-05-07 15:04 ` Torsten Landschoff
2003-05-07 16:01 ` William Lee Irwin III
2003-05-08 15:36 ` Ingo Oeser
2003-05-08 18:04 ` William Lee Irwin III
2003-05-07 15:23 ` Timothy Miller
2003-05-07 15:47 ` William Lee Irwin III
2003-05-07 16:49 ` Jörn Engel
2003-05-07 17:18 ` Davide Libenzi
2003-05-07 17:40 ` Jörn Engel
2003-05-07 18:35 ` Davide Libenzi
2003-05-07 19:45 ` Jörn Engel
2003-05-07 18:23 ` William Lee Irwin III
2003-05-07 17:38 ` William Lee Irwin III
2003-05-07 17:47 ` Jörn Engel
2003-05-07 14:49 ` Richard B. Johnson
2003-05-07 18:36 ` Linus Torvalds
2003-05-07 19:17 ` Jeff Garzik
2003-05-07 20:38 ` Randy.Dunlap
2003-05-07 21:27 ` Marcus Alanen
2003-05-07 21:27 ` Randy.Dunlap
2003-05-08 15:10 ` Ingo Oeser
2003-05-08 17:12 ` Randy.Dunlap
2003-05-07 19:38 Chuck Ebbert
2003-05-08 14:08 Chuck Ebbert
2003-05-08 18:04 ` Jonathan Lundell
2003-05-08 19:05 ` Timothy Miller
2003-05-08 21:00 ` Jonathan Lundell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030508084101.GE1469@wohnheim.fh-wedel.de \
--to=joern@wohnheim.fh-wedel.de \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@lundell-bros.com \
--cc=root@chaos.analogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).