From: Linus Torvalds <torvalds@linux-foundation.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Joe Perches <joe@perches.com>, Nick Andrew <nick@nick-andrew.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@suse.de>,
netdev@vger.kernel.org, Bjorn Helgaas <bjorn.helgaas@hp.com>
Subject: Re: [PATCH] vsprintf.c: Use noinline_for_stack
Date: Sat, 13 Mar 2010 07:35:41 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.00.1003130734420.3719@i5.linux-foundation.org> (raw)
In-Reply-To: <20100312162559.a8e51777.akpm@linux-foundation.org>
On Fri, 12 Mar 2010, Andrew Morton wrote:
>
> -ENOTESTINGRESULTS.
>
> Before:
>
> akpm:/usr/src/25> objdump -d lib/vsprintf.o | perl scripts/checkstack.pl
> 0x00000e82 pointer [vsprintf.o]: 344
> 0x0000198c pointer [vsprintf.o]: 344
> 0x000025d6 scnprintf [vsprintf.o]: 216
> 0x00002648 scnprintf [vsprintf.o]: 216
> 0x00002565 snprintf [vsprintf.o]: 208
> 0x0000267c sprintf [vsprintf.o]: 208
> 0x000030a3 bprintf [vsprintf.o]: 208
> 0x00003b1e sscanf [vsprintf.o]: 208
> 0x00000608 number [vsprintf.o]: 136
> 0x00000937 number [vsprintf.o]: 136
>
> After:
>
> akpm:/usr/src/25> objdump -d lib/vsprintf.o | perl scripts/checkstack.pl
> 0x00000a7c symbol_string [vsprintf.o]: 248
> 0x00000ae8 symbol_string [vsprintf.o]: 248
> 0x00002310 scnprintf [vsprintf.o]: 216
> 0x00002382 scnprintf [vsprintf.o]: 216
> 0x0000229f snprintf [vsprintf.o]: 208
> 0x000023b6 sprintf [vsprintf.o]: 208
> 0x00002ddd bprintf [vsprintf.o]: 208
> 0x00003858 sscanf [vsprintf.o]: 208
> 0x00000625 number [vsprintf.o]: 136
> 0x00000954 number [vsprintf.o]: 136
>
> nice.
Note that the fact that the numbers are smaller is to some degree less
important than _where_ the numbers are.
In the "before" side, it's the "pointer()" function that has a big stack
depth. And the recursion that is going to happen is very much about
vsnprintf -> pointer -> vsnprintf, so that is bad.
Now it's the new non-inlined leaf functions that still have a big stack
footprint, and that's much better, because they wouldn't be part of any
recursive behavior.
Not that I think it's wonderful even now. Especially that whole
'symbol_string()' thing is not only a big stack user, it ends up calling
down a fair number of other functions. Non-recursively, but still.
That, in turn, is due to this:
- include/linux/kallsyms.h:
#define KSYM_NAME_LEN 128
#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
- symbol_string():
char sym[KSYM_SYMBOL_LEN];
ie we "need" about 150 bytes for just that silly symbol expansion (rounded
up etc). Which is ridiculous, since we could/should limit it to something
sane. But the kallsyms_lookup()/sprint_symbol() functions don't take a
length parameter, so we have to do the worst-case thing (which itself has
tons of unnecessary padding).
Gaah. We do _not_ want a kmalloc() or something like that in this path,
since its' very much used for oopses (which in turn may be due to various
slab bugs etc).
Linus
next prev parent reply other threads:[~2010-03-13 15:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 6:21 [PATCH 0/2] Make functions of dev_<level> macros, recursive vsnprintf Joe Perches
2010-03-04 6:21 ` [PATCH 1/2] vsprintf: Recursive vsnprintf: Add "%pV", struct va_format Joe Perches
2010-03-04 6:21 ` [PATCH 2/2] device.h drivers/base/core.c Convert dev_<level> macros to functions Joe Perches
2010-03-05 0:56 ` Andrew Morton
2010-03-05 1:00 ` Andrew Morton
2010-03-05 2:46 ` Joe Perches
2010-03-04 22:38 ` [RESEND PATCH 0/2] Make functions of dev_<level> macros, recursive vsnprintf Andrew Morton
2010-03-04 23:06 ` Linus Torvalds
2010-03-06 21:36 ` Joe Perches
2010-03-06 22:03 ` Linus Torvalds
2010-03-06 22:30 ` Joe Perches
2010-03-06 22:52 ` Linus Torvalds
2010-03-06 22:57 ` Linus Torvalds
2010-03-06 23:35 ` Joe Perches
2010-03-06 23:46 ` Linus Torvalds
2010-03-06 23:48 ` Linus Torvalds
2010-03-06 23:57 ` Joe Perches
2010-03-06 23:58 ` Linus Torvalds
2010-03-07 1:10 ` [PATCH] vsprintf.c: Reduce sizeof struct printf_spec from 24 to 8 bytes Joe Perches
2010-03-07 2:03 ` Linus Torvalds
2010-03-07 2:24 ` Linus Torvalds
2010-03-07 2:33 ` [PATCH] vsprintf.c: Use noinline_for_stack Joe Perches
2010-03-08 23:39 ` Joe Perches
2010-03-13 0:25 ` Andrew Morton
2010-03-13 15:35 ` Linus Torvalds [this message]
2010-03-13 17:44 ` Joe Perches
2010-03-13 19:54 ` [PATCH] vsprintf.c: remove stack variable ksym from Joe Perches
2010-03-15 15:01 ` Paulo Marques
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=alpine.LFD.2.00.1003130734420.3719@i5.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=bjorn.helgaas@hp.com \
--cc=gregkh@suse.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nick@nick-andrew.net \
/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
all inboxes | Powered by JetHome®