From: Joe Perches on
On Sat, 2010-03-06 at 18:33 -0800, Joe Perches wrote:
> On Sat, 2010-03-06 at 18:03 -0800, Linus Torvalds wrote:
> > A few noinlines might be appropriate.
> Mark static functions with noinline_for_stack

It's fine by me that the vsnprintf recursion and
(pr|dev|netdev)_<level> text reduction patches didn't make .34.

I'd like to know what you think necessary to get them into .35.

Perhaps it'd be useful if they could go into -next as-is for a
bit of wider testing.

http://patchwork.kernel.org/patch/83940/
http://patchwork.kernel.org/patch/83724/
http://patchwork.kernel.org/patch/83726/
http://patchwork.kernel.org/patch/83725/


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andrew Morton on
On Sat, 06 Mar 2010 18:33:35 -0800
Joe Perches <joe(a)perches.com> wrote:

> On Sat, 2010-03-06 at 18:03 -0800, Linus Torvalds wrote:
> > A few noinlines might be appropriate.
>
> Mark static functions with noinline_for_stack
>

-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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Linus Torvalds on

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Joe Perches on
On Sat, 2010-03-13 at 07:35 -0800, Linus Torvalds wrote:
> On Fri, 12 Mar 2010, Andrew Morton wrote:
> > nice.
> 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).

I sent a patch once about that using a struct
because I didn't like the unbounded sprint
http://lkml.org/lkml/2009/4/15/16

> 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).

Perhaps a new snprint_symbol function with the
other kallsyms... functions changed as necessary.

thoughts?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/