linux-embedded.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]       ` <alpine.LFD.1.10.0808261019450.3363@nehalem.linux-foundation.org>
@ 2008-08-26 18:30         ` Adrian Bunk
       [not found]           ` <20080826183051.GB10925-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-26 18:30 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded

On Tue, Aug 26, 2008 at 10:35:05AM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 26 Aug 2008, Rusty Russell wrote:
> > 
> > Your workaround is very random, and that scares me.  I think a huge number of 
> > CPUs needs a real solution (an actual cpumask allocator, then do something 
> > clever if we come across an actual fastpath).
> 
> The thing is, the inlining thing is a separate issue.
> 
> Yes, the cpumasks were what made stack pressure so critical to begin with, 
> but no, a 400-byte stack frame in a deep callchain isn't acceptable 
> _regardless_ of any cpumask_t issues.
> 
> Gcc inlining is a total and utter pile of shit. And _that_ is the problem. 
> I seriously think we shouldn't allow gcc to inline anything at all unless 
> we tell it to. That's how it used to work, and quite frankly, that's how 
> it _should_ work.
> 
> The downsides of inlining are big enough from both a debugging and a real 
> code generation angle (eg stack usage like this), that the upsides 
> (_somesimes_ smaller kernel, possibly slightly faster code) simply aren't 
> relevant.
>...
> It would be interesting to see what "-fno-default-inline" does to the 
> kernel. It really would get rid of a _lot_ of gcc version issues too. 
> Inlining behavior of gcc has long been a problem for us.

I added "-fno-inline-functions-called-once -fno-early-inlining" to 
KBUILD_CFLAGS, and (with gcc 4.3) that increased the size of my kernel 
image by 2%.

And when David's "-fwhole-program --combine" will become ready the cost
of disallowing gcc to inline functions will most likely increase.

A debugging option (for better traces) to disallow gcc some inlining 
might make sense (and might even make sense for distributions to 
enable in their kernels), but when you go to use cases that require
really small kernels the cost is too high.

But if you don't trust gcc's inlining you should revert
commit 3f9b5cc018566ad9562df0648395649aebdbc5e0 that increases gcc's 
freedom regarding what to inline in 2.6.27 - what gcc 4.2 does in the 
case of the regression tracked as Bugzilla #11276 is really not funny 
(two callers -> function not inlined; gcc seems to emit the function 
although both callers later get removed (or at least should be removed) 
by dead code elimination).

> 			Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]           ` <20080826183051.GB10925-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
@ 2008-08-26 18:40             ` Linus Torvalds
       [not found]               ` <alpine.LFD.1.10.0808261134530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-26 18:47             ` Linus Torvalds
  1 sibling, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 18:40 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Tue, 26 Aug 2008, Adrian Bunk wrote:
> 
> A debugging option (for better traces) to disallow gcc some inlining 
> might make sense (and might even make sense for distributions to 
> enable in their kernels), but when you go to use cases that require
> really small kernels the cost is too high.

You ignore the fact that it's really not just about debugging.

Inlining really isn't the great tool some people think it is. Especially 
not since gcc stack allocation is so horrid that it won't re-use stack 
slots etc (which I don't disagree with per se - it's _hard_ to re-use 
stack slots while still allowing code scheduling).

NOTE! I also would never claim that _our_ choices of "inline" are all that 
great, and we've often inlined too much or not inlined things that really 
could be inlined. But at least when a developer says "inline" (or forgets 
to say it), we have somebody to blame. When the compiler does insane 
things that doesn't suit us, we're just screwed.

> But if you don't trust gcc's inlining you should revert
> commit 3f9b5cc018566ad9562df0648395649aebdbc5e0 that increases gcc's 
> freedom regarding what to inline in 2.6.27

Actually, that just allows gcc to _not_ inline. Which is probably ok.

(Well, it would be ok if gcc did it well enough, it obviously has some 
problems at times).

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]           ` <20080826183051.GB10925-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
  2008-08-26 18:40             ` Linus Torvalds
@ 2008-08-26 18:47             ` Linus Torvalds
  2008-08-26 19:02               ` Jamie Lokier
       [not found]               ` <alpine.LFD.1.10.0808261144510.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  1 sibling, 2 replies; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 18:47 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Tue, 26 Aug 2008, Adrian Bunk wrote:
> 
> I added "-fno-inline-functions-called-once -fno-early-inlining" to 
> KBUILD_CFLAGS, and (with gcc 4.3) that increased the size of my kernel 
> image by 2%.

Btw, did you check with just "-fno-inline-functions-called-once"?

The -fearly-inlining decisions _should_ be mostly right. If gcc sees early 
that a function is so small (even without any constant propagation etc) 
that it can be inlined, it's probably right. 

The inline-functions-called-once thing is what causes even big functions 
to be inlined, and that's where you find the big downsides too (eg the 
stack usage).

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 18:47             ` Linus Torvalds
@ 2008-08-26 19:02               ` Jamie Lokier
       [not found]                 ` <20080826190213.GA30255-yetKDKU6eevNLxjTenLetw@public.gmane.org>
       [not found]               ` <alpine.LFD.1.10.0808261144510.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  1 sibling, 1 reply; 54+ messages in thread
From: Jamie Lokier @ 2008-08-26 19:02 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded

Linus Torvalds wrote:
> The inline-functions-called-once thing is what causes even big functions 
> to be inlined, and that's where you find the big downsides too (eg the 
> stack usage).

That's a bit bizarre, though, isn't it?

A function which is only called from one place should, if everything
made sense, _never_ use more stack through being inlined.  Inlining
should just increase the opportunities that the called function's
local variables can share the same stack slots are the caller's dead
locals.

Whereas not inlining guarantees they occupy separate, immediately
adjacent regions of the stack, and shouldn't be increasing the total
numbers of local variables.

-- Jamie

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                 ` <20080826190213.GA30255-yetKDKU6eevNLxjTenLetw@public.gmane.org>
@ 2008-08-26 19:18                   ` Linus Torvalds
  0 siblings, 0 replies; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 19:18 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Tue, 26 Aug 2008, Jamie Lokier wrote:
> 
> A function which is only called from one place should, if everything
> made sense, _never_ use more stack through being inlined.

But that's simply not true.

See the whole discussion.

The problem is that if you inline that function, the stack usage of the 
newly inlined function is now added to ALL THE OTHER paths too!

So the case we had in module loading was that yes, we had a function with 
a big stack footprint, but it was NOT in the deep path.

But by inlining it, it now moved the stack footprint "up" one level to 
another function, and now the big stack footprint really _was_ in the deep 
path, because the caller was involved in a much deeper chain. 

So inlining moves the code up the callchain, and that is a problem for the 
backtrace, but that's "just" a debugging issue. But it also moves the 
stack footprint up the callchain, and that can actually be a correctness 
issue.

Of course, a compiler doesn't _have_ to do that. A compiler _could_ have 
multiple different stack footprints for a single function, and do liveness 
analysis etc. But no sane compiler probably does that, because it's very 
painful indeed, and it's not even an issue if you aren't stack-limited 
(and being stack-limited is really just a kernel thing).

(Yeah, it can be an issue even if you have a big stack, in that you get 
worse cache behaviour, so a dense stack footprint _would_ help. But the 
complexity of stack liveness analysis is almost certainly not worth the 
relatively small gains it would get on some odd cases).

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]               ` <alpine.LFD.1.10.0808261134530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-26 20:21                 ` Adrian Bunk
  2008-08-26 20:41                   ` Linus Torvalds
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-26 20:21 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 11:40:10AM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 26 Aug 2008, Adrian Bunk wrote:
> > 
> > A debugging option (for better traces) to disallow gcc some inlining 
> > might make sense (and might even make sense for distributions to 
> > enable in their kernels), but when you go to use cases that require
> > really small kernels the cost is too high.
> 
> You ignore the fact that it's really not just about debugging.

I had in mind that we anyway have to support it for tiny kernels.

I simply don't see that we add kconfig options for 5kB of code for
tiny kernels but remove something like this that can cause size
increases > 1%.

> Inlining really isn't the great tool some people think it is. Especially 
> not since gcc stack allocation is so horrid that it won't re-use stack 
> slots etc (which I don't disagree with per se - it's _hard_ to re-use 
> stack slots while still allowing code scheduling).

gcc's stack allocation has become better
(that's why we disable unit-at-a-time only for gcc 3.4 on i386).

> NOTE! I also would never claim that _our_ choices of "inline" are all that 
> great, and we've often inlined too much or not inlined things that really 
> could be inlined. But at least when a developer says "inline" (or forgets 
> to say it), we have somebody to blame. When the compiler does insane 
> things that doesn't suit us, we're just screwed.

Most LOCs of the kernel are not written by people like you or Al Viro or 
David Miller, and the average kernel developer is unlikely to do it as 
good as gcc.

For the average driver the choice is realistically between
"inline's randomly sprinkled across the driver" and
"no inline's, leave it to gcc".

And code evolves during the years from tiny with 1 caller to huge with 
many callers.

BTW:
I just ran checkstack on a (roughly) allyesconfig kernel, and we have a 
new driver that allocates "unsigned char recvbuf[1500];" on the stack...

> > But if you don't trust gcc's inlining you should revert
> > commit 3f9b5cc018566ad9562df0648395649aebdbc5e0 that increases gcc's 
> > freedom regarding what to inline in 2.6.27
> 
> Actually, that just allows gcc to _not_ inline. Which is probably ok.
> 
> (Well, it would be ok if gcc did it well enough, it obviously has some 
> problems at times).

With the "gcc inline's static functions" you complain about we have
4-5 years of experience.

Suddenly allowing 4 release series of gcc to ignore any inline's is a 
completely new area for us. I'd generally agree with giving gcc more 
freedom here, but I'd rather do it right by removing tons of wrong 
inline's than doing one global change hoping that it will make things 
better.

And whether the "optimized inlining" actually makes the kernel bigger or 
smaller depends in my experience on the .config and the gcc version.

> 			Linus

cu
Adrian

[1] there are some rare exceptions

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 20:21                 ` Adrian Bunk
@ 2008-08-26 20:41                   ` Linus Torvalds
  2008-08-27 16:21                     ` Jamie Lokier
  0 siblings, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 20:41 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded



On Tue, 26 Aug 2008, Adrian Bunk wrote:
> 
> I had in mind that we anyway have to support it for tiny kernels.

I actually don't think that is true.

If we really were to decide to be stricter about it, and it makes a big 
size difference, we can probably also add a tool to warn about functions 
that really should be inline.

> > Inlining really isn't the great tool some people think it is. Especially 
> > not since gcc stack allocation is so horrid that it won't re-use stack 
> > slots etc (which I don't disagree with per se - it's _hard_ to re-use 
> > stack slots while still allowing code scheduling).
> 
> gcc's stack allocation has become better
> (that's why we disable unit-at-a-time only for gcc 3.4 on i386).


I agree that it has become better. But it still absolutely *sucks*.

For example, see the patch I just posted about e1000 stack usage. Even 
though the variables were all in completely separate scopes, they all got 
individual space on the stack over the whole lifetime of the function, 
causing an explosion of stack-space. As such, gcc used 500 bytes too much 
of stack, just because it didn't re-use the stackspace.

That was with gcc-4.3.0, and no, there were hardly any inlining issues 
involevd, although it is true that inlining actually did make it slightly 
worse in that case too (but since it was essentially a leaf function, that 
had little real life impact, since there were no deep callchains below it 
to care).

So the fact is, "better" simply is not "good enough". We still need to do 
a lot of optimizations _manually_, because gcc cannot see that it can 
re-use the stack-slots.

And sometimes those "optimizations" are actually performance 
pessimizations, because in order to make gcc not use all the stack at the 
same time, you simply have to break things out and force-disable inlining.

> Most LOCs of the kernel are not written by people like you or Al Viro or 
> David Miller, and the average kernel developer is unlikely to do it as 
> good as gcc.

Sure. But we do have tools. We do have checkstack.pl, it's just that it 
hasn't been an issue in a long time, so I suspect many people didn't even 
_realize_ we have it, and I certainly can attest to the fact that even 
people who remember it - like me - don't actually tend to run it all that 
often.

> For the average driver the choice is realistically between
> "inline's randomly sprinkled across the driver" and
> "no inline's, leave it to gcc".

And neither is likely to be a big problem.

> BTW:
> I just ran checkstack on a (roughly) allyesconfig kernel, and we have a 
> new driver that allocates "unsigned char recvbuf[1500];" on the stack...

Yeah, it's _way_ too easy to do bad things.

> With the "gcc inline's static functions" you complain about we have
> 4-5 years of experience.

Sure. And most of it isn't all that great.

But I do agree that lettign gcc make more decisions is _dangerous_. 
However, in this case, at least, the decisions it makes would at least 
make for less inlining, and thus less stack space explosion.

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]               ` <alpine.LFD.1.10.0808261144510.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-26 20:59                 ` Adrian Bunk
  2008-08-26 21:04                   ` Linus Torvalds
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-26 20:59 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 11:47:01AM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 26 Aug 2008, Adrian Bunk wrote:
> > 
> > I added "-fno-inline-functions-called-once -fno-early-inlining" to 
> > KBUILD_CFLAGS, and (with gcc 4.3) that increased the size of my kernel 
> > image by 2%.
> 
> Btw, did you check with just "-fno-inline-functions-called-once"?
> 
> The -fearly-inlining decisions _should_ be mostly right. If gcc sees early 
> that a function is so small (even without any constant propagation etc) 
> that it can be inlined, it's probably right. 
> 
> The inline-functions-called-once thing is what causes even big functions 
> to be inlined, and that's where you find the big downsides too (eg the 
> stack usage).

-fno-inline-functions-called-once alone costs me nearly 1% in code size.

And I'd expect it to become more with "-fwhole-program --combine".


If you think we have too many stacksize problems I'd suggest to consider 
removing the choice of 4k stacks on i386, sh and m68knommu instead of 
using -fno-inline-functions-called-once:

Now that 32bit x86 is no longer used for extreme highend configurations 
the only serious usecase for 4k stacks are AFAIK space savings on 
embedded archs.

4k stacks have caused us much pain [1], and the cases where gcc inlined 
too much were the easy ones.

I'm not saying that I'd like removing the choice of 4k stacks, but if we 
want to reduce the number of stack related problems that's IMHO the 
better alternative.


> 			Linus

cu
Adrian

[1] AFAIR some callpaths in the kernel are still too big

BTW: In case anyone wonders about why I suggest removing 4k stacks:
     My position is that 4k stacks should either be enabled 
     unconditionally or no longer offered at all.
     And if we remove 4k stacks from 32bit x86 it's no longer 
     realistically maintainable for other architectures.

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 20:59                 ` Adrian Bunk
@ 2008-08-26 21:04                   ` Linus Torvalds
       [not found]                     ` <alpine.LFD.1.10.0808261403360.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 21:04 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded



On Tue, 26 Aug 2008, Adrian Bunk wrote:
> 
> If you think we have too many stacksize problems I'd suggest to consider 
> removing the choice of 4k stacks on i386, sh and m68knommu instead of 
> using -fno-inline-functions-called-once:

Don't be silly. That makes the problem _worse_.

We're much better off with a 1% code-size reduction than forcing big 
stacks on people. The 4kB stack option is also a good way of saying "if it 
works with this, then 8kB is certainly safe".

And embedded people (the ones that might care about 1% code size) are the 
ones that would also want smaller stacks even more!

		Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                     ` <alpine.LFD.1.10.0808261403360.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-26 22:54                       ` Parag Warudkar
       [not found]                         ` <f7848160808261554j2f4eaaa6i1ee8801ae75ca7bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
                                           ` (2 more replies)
  2008-08-26 23:24                       ` Adrian Bunk
  1 sibling, 3 replies; 54+ messages in thread
From: Parag Warudkar @ 2008-08-26 22:54 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 5:04 PM, Linus Torvalds
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> wrote:

> And embedded people (the ones that might care about 1% code size) are the
> ones that would also want smaller stacks even more!

This is something I never understood - embedded devices are not going
to run more than a few processes and 4K*(Few Processes)
 IMHO is not worth a saving now a days even in embedded world given
falling memory prices. Or do I misunderstand?

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                         ` <f7848160808261554j2f4eaaa6i1ee8801ae75ca7bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-26 23:00                           ` David VomLehn
  2008-08-26 23:45                             ` Adrian Bunk
  0 siblings, 1 reply; 54+ messages in thread
From: David VomLehn @ 2008-08-26 23:00 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

Parag Warudkar wrote:
> On Tue, Aug 26, 2008 at 5:04 PM, Linus Torvalds
> <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> wrote:
> 
>> And embedded people (the ones that might care about 1% code size) are the
>> ones that would also want smaller stacks even more!
> 
> This is something I never understood - embedded devices are not going
> to run more than a few processes and 4K*(Few Processes)
>  IMHO is not worth a saving now a days even in embedded world given
> falling memory prices. Or do I misunderstand?

Embedded applications span a huge range of sizes, from the very small devices to 
which you refer, to quite complex devices. The cable settop boxes we develop have 
over a hundred interrupt sources, typically run 250-300 threads, and have 192+ 
MiB of memory. For all that, we are very cost sensitive and are under constant 
pressure to come up with reliable ways to save memory.

> Parag
--
David VomLehn


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                     ` <alpine.LFD.1.10.0808261403360.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-26 22:54                       ` Parag Warudkar
@ 2008-08-26 23:24                       ` Adrian Bunk
       [not found]                         ` <20080826232411.GC11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
  1 sibling, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-26 23:24 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 02:04:57PM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 26 Aug 2008, Adrian Bunk wrote:
> > 
> > If you think we have too many stacksize problems I'd suggest to consider 
> > removing the choice of 4k stacks on i386, sh and m68knommu instead of 
> > using -fno-inline-functions-called-once:
> 
> Don't be silly. That makes the problem _worse_.
> 
> We're much better off with a 1% code-size reduction than forcing big 
> stacks on people. The 4kB stack option is also a good way of saying "if it 
> works with this, then 8kB is certainly safe".
>...

You implicitely assume both would solve the same problem.

While 4kB stacks are something we anyway never got 100% working, the 
cases where gcc inlining functions causes a critical increase in stack 
usage are usually not that hard to find, and once found the fix is 
trivial.

We should anyway monitor stack usages better since we have frequent 
programming errors in this area, and problems caused by gcc can this
way be detected en passant.

You have a good point that aiming at 4kB makes 8kB a very safe choice.

But I do not think the problem you'd solve with 
-fno-inline-functions-called-once is big enough to warrant the size 
increase it causes.

> 		Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 23:00                           ` David VomLehn
@ 2008-08-26 23:45                             ` Adrian Bunk
  0 siblings, 0 replies; 54+ messages in thread
From: Adrian Bunk @ 2008-08-26 23:45 UTC (permalink / raw)
  To: David VomLehn
  Cc: Parag Warudkar, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded

On Tue, Aug 26, 2008 at 04:00:33PM -0700, David VomLehn wrote:
> Parag Warudkar wrote:
>> On Tue, Aug 26, 2008 at 5:04 PM, Linus Torvalds
>> <torvalds@linux-foundation.org> wrote:
>>
>>> And embedded people (the ones that might care about 1% code size) are the
>>> ones that would also want smaller stacks even more!
>>
>> This is something I never understood - embedded devices are not going
>> to run more than a few processes and 4K*(Few Processes)
>>  IMHO is not worth a saving now a days even in embedded world given
>> falling memory prices. Or do I misunderstand?
>
> Embedded applications span a huge range of sizes, from the very small 
> devices to which you refer, to quite complex devices. The cable settop 
> boxes we develop have over a hundred interrupt sources, typically run 
> 250-300 threads, and have 192+ MiB of memory. For all that, we are very 
> cost sensitive and are under constant pressure to come up with reliable 
> ways to save memory.

As you say correctly the term "embedded" gets used for many different 
devices.

And if you have 192+ MiB of memory you have so much that all these 
kernel size discussions don't really matter.

> David VomLehn

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 22:54                       ` Parag Warudkar
       [not found]                         ` <f7848160808261554j2f4eaaa6i1ee8801ae75ca7bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-26 23:47                         ` Linus Torvalds
       [not found]                           ` <alpine.LFD.1.10.0808261644260.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-27  8:34                         ` Bernd Petrovitsch
  2 siblings, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 23:47 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded



On Tue, 26 Aug 2008, Parag Warudkar wrote:
> 
> This is something I never understood - embedded devices are not going
> to run more than a few processes and 4K*(Few Processes)
>  IMHO is not worth a saving now a days even in embedded world given
> falling memory prices. Or do I misunderstand?

Well, by that argument, 1% of kernel size doesn't matter either..

1% of a kernel for an embedded device is roughly 10-30kB or so depending 
on how small you make the configuration. 

If that matters, then so should the difference of 3-8 processes' kernel 
stack usage when you have a 4k/8k stack choice.

And they _all_ will have at least 3-8 processes on them. Even the simplest 
ones will tend to have many more.

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                         ` <20080826232411.GC11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
@ 2008-08-26 23:51                           ` Linus Torvalds
       [not found]                             ` <alpine.LFD.1.10.0808261648140.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-27  8:25                           ` Alan Cox
  1 sibling, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-26 23:51 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Wed, 27 Aug 2008, Adrian Bunk wrote:
> > 
> > We're much better off with a 1% code-size reduction than forcing big 
> > stacks on people. The 4kB stack option is also a good way of saying "if it 
> > works with this, then 8kB is certainly safe".
> 
> You implicitely assume both would solve the same problem.

I'm just saying that your logic doesn't hold water.

If we can save kernel stack usage, then a 1% increase in kernel size is 
more than worth it.

> While 4kB stacks are something we anyway never got 100% working

What? Don't be silly. 

Linux _historically_ always used 4kB stacks.

No, they are likely not usable on x86-64, but dammit, they should be more 
than usable on x86-32 still.

> But I do not think the problem you'd solve with 
> -fno-inline-functions-called-once is big enough to warrant the size 
> increase it causes.

You continually try to see the inlining as a single solution to one 
problem (debuggability, stack, whatever).

The biggest problem with gcc inlining has always been that it has been 
_unpredictable_. It causes problems in many different ways. It has caused 
stability issues due to gcc versions doing random things. It causes the 
stack expansion. It makes stack traces harder for debugging, etc.

If it was any one thing, I wouldn't care. But it's exactly the fact that 
it causes all these problems in different areas.

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                             ` <alpine.LFD.1.10.0808261648140.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-27  0:23                               ` Adrian Bunk
  2008-08-27  0:28                                 ` Linus Torvalds
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-27  0:23 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 04:51:52PM -0700, Linus Torvalds wrote:
> 
> 
> On Wed, 27 Aug 2008, Adrian Bunk wrote:
> > > 
> > > We're much better off with a 1% code-size reduction than forcing big 
> > > stacks on people. The 4kB stack option is also a good way of saying "if it 
> > > works with this, then 8kB is certainly safe".
> > 
> > You implicitely assume both would solve the same problem.
> 
> I'm just saying that your logic doesn't hold water.
> 
> If we can save kernel stack usage, then a 1% increase in kernel size is 
> more than worth it.

From some tests the size increase seems to become bigger for smaller 
kernels, but I don't have any really good data.


An interesting question is why most of our architectures for embedded 
devices only offer bigger stacks:

The only architectures offering a 4kB stacks option are:
- m68knommu
- sh
- 32bit x86

The following architectures that are used in embedded devices 
always use 8kB stacks (or bigger) in your tree:
- arm
- avr32
- blackfin
- cris
- frv
- h8300
- m32r
- m68k
- mips
- mn10300 (has an #ifdef CONFIG_4KSTACKS but no kconfig option)
- powerpc
- xtensa


> > While 4kB stacks are something we anyway never got 100% working
> 
> What? Don't be silly. 
> 
> Linux _historically_ always used 4kB stacks.
> 
> No, they are likely not usable on x86-64, but dammit, they should be more 
> than usable on x86-32 still.


When did we get callpaths like like nfs+xfs+md+scsi reliably 
working with 4kB stacks on x86-32?


>...
> 			Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  0:23                               ` Adrian Bunk
@ 2008-08-27  0:28                                 ` Linus Torvalds
       [not found]                                   ` <alpine.LFD.1.10.0808261726560.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Linus Torvalds @ 2008-08-27  0:28 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded



On Wed, 27 Aug 2008, Adrian Bunk wrote:
> 
> When did we get callpaths like like nfs+xfs+md+scsi reliably 
> working with 4kB stacks on x86-32?

XFS may never have been usable, but the rest, sure.

And you seem to be making this whole argument an excuse to SUCK, adn an 
excuse to let gcc crap even more on our stack space.

Why?

Why aren't you saying that we should be able to do better? Instead, you 
seem to asking us to do even worse than we do now?

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                           ` <alpine.LFD.1.10.0808261644260.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-27  0:53                             ` Greg Ungerer
  2008-08-27  1:08                               ` Parag Warudkar
  2008-08-27  0:58                             ` Parag Warudkar
  1 sibling, 1 reply; 54+ messages in thread
From: Greg Ungerer @ 2008-08-27  0:53 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Parag Warudkar, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA


Linus Torvalds wrote:
> On Tue, 26 Aug 2008, Parag Warudkar wrote:
>> This is something I never understood - embedded devices are not going
>> to run more than a few processes and 4K*(Few Processes)
>>  IMHO is not worth a saving now a days even in embedded world given
>> falling memory prices. Or do I misunderstand?
> 
> Well, by that argument, 1% of kernel size doesn't matter either..
> 
> 1% of a kernel for an embedded device is roughly 10-30kB or so depending 
> on how small you make the configuration. 
> 
> If that matters, then so should the difference of 3-8 processes' kernel 
> stack usage when you have a 4k/8k stack choice.
> 
> And they _all_ will have at least 3-8 processes on them. Even the simplest 
> ones will tend to have many more.

I have some simple devices (network access/routers) with 8MB of RAM,
at power up not really being configured to do anything running 25
processes. (Heck there is over 10 kernel processes running!). Configure
some interfaces and services and that will easily push past 40.
I'd be happy with a 160k saving :-)

The init memory being freed at the end of the kernel boot is 88k,
4k stacks could save more than that.

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                           ` <alpine.LFD.1.10.0808261644260.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-27  0:53                             ` Greg Ungerer
@ 2008-08-27  0:58                             ` Parag Warudkar
       [not found]                               ` <f7848160808261758q7b84aab1m188c1ebb59304818-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2008-08-27  9:00                               ` Bernd Petrovitsch
  1 sibling, 2 replies; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27  0:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 7:47 PM, Linus Torvalds
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> wrote:

> If that matters, then so should the difference of 3-8 processes' kernel
> stack usage when you have a 4k/8k stack choice.

The savings part -financial ones- are not always realizable with the
way memory is priced/sized/fitted.
Savings in few Mb of Kernel stack are not necessarily going to allow
getting rid of a single memory chip of 64M or so.
Either that or embedded manufacturing/configurations are different
than the desktop world.

(If my device has 2 memory slots and my user space requires 100Mb
including kernel memory - I anyways have to put in 64Mx2 there to take
advantage of mass manufactured, general purpose memory - so no big
deal if I saved 1.2Mb in Kernel stack or not. And savings of 64Mb
Kernel memory are not feasible anyways to allow user space to work
with 64Mb.)

On the other hand reducing  user space memory usage on those devices
(not counting savings from kernel stack size) is a way more attractive
option.

And although you said in your later reply that Linux x86 with 4K
stacks should be more than usable - my experiences running a untainted
desktop/file server with 4K stack have been always disastrous XFS or
not.  It _might_ work for some well defined workloads but you would
not want to risk 4K stacks otherwise.

I understand the having 4K stack option as a non-default for very
specific workloads is a good idea but apart from that I think no one
else seems to bother with reducing stack sizes (by no one I mean other
OSes.)

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  0:53                             ` Greg Ungerer
@ 2008-08-27  1:08                               ` Parag Warudkar
  2008-08-27  1:31                                 ` Greg Ungerer
  0 siblings, 1 reply; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27  1:08 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Tue, Aug 26, 2008 at 8:53 PM, Greg Ungerer <gerg@snapgear.com> wrote:

> I have some simple devices (network access/routers) with 8MB of RAM,
> at power up not really being configured to do anything running 25
> processes. (Heck there is over 10 kernel processes running!). Configure
> some interfaces and services and that will easily push past 40.
> I'd be happy with a 160k saving :-)
>

So you really need to run all 25 processes on that 8Mb box?
(For reference even the NGW100 development board comes with 16Mb RAM).

Even if you do need those all 25 processes on the 8Mb box, fixing the
memory usage of those user space hogs is lot better than trying to
save 160Kb in kernel stacks.
Last I looked, user space wasn't particularly frugal with memory usage.

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  1:08                               ` Parag Warudkar
@ 2008-08-27  1:31                                 ` Greg Ungerer
       [not found]                                   ` <48B4AE68.4040205-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Greg Ungerer @ 2008-08-27  1:31 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded


Parag Warudkar wrote:
> On Tue, Aug 26, 2008 at 8:53 PM, Greg Ungerer <gerg@snapgear.com> wrote:
> 
>> I have some simple devices (network access/routers) with 8MB of RAM,
>> at power up not really being configured to do anything running 25
>> processes. (Heck there is over 10 kernel processes running!). Configure
>> some interfaces and services and that will easily push past 40.
>> I'd be happy with a 160k saving :-)
>>
> 
> So you really need to run all 25 processes on that 8Mb box?

Yes, of course. Considerable effort has been put into running
a minimal set of processes (that still for fills the required function
set of this device).


> (For reference even the NGW100 development board comes with 16Mb RAM).

Lots of development boards are fitted with lots of RAM.

And the pressure will still be on in _real_ products to reduce
the RAM footprint as much as possible. There are exceptions but
generally less is cheaper. Simple economics really.


> Even if you do need those all 25 processes on the 8Mb box, fixing the
> memory usage of those user space hogs is lot better than trying to
> save 160Kb in kernel stacks.

Yep, been done too. You don't squeeze a lot into these smaller
devices without looking at everything in it.


> Last I looked, user space wasn't particularly frugal with memory usage.

Then you haven't looked in the right places :-)

There are plenty of choices for making things small in user space.
Simple stuff like using uClibc, busybox, etc.

In this specific example things like /bin/init is 10k, /bin/inetd
is 10k, /bin/crond is 11k, etc. (Ofcourse it is a shared uClibc setup,
uClibc is ~300k). And XIP can help out here too.

Regards
Greg



------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg@snapgear.com
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                               ` <f7848160808261758q7b84aab1m188c1ebb59304818-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-27  1:49                                 ` Linus Torvalds
       [not found]                                   ` <alpine.LFD.1.10.0808261837530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-27 11:58                                   ` Adrian Bunk
  0 siblings, 2 replies; 54+ messages in thread
From: Linus Torvalds @ 2008-08-27  1:49 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Tue, 26 Aug 2008, Parag Warudkar wrote:
>
> And although you said in your later reply that Linux x86 with 4K
> stacks should be more than usable - my experiences running a untainted
> desktop/file server with 4K stack have been always disastrous XFS or
> not.  It _might_ work for some well defined workloads but you would
> not want to risk 4K stacks otherwise.

Umm. How long?

4kB used to be the _only_ choice. And no, there weren't even irq stacks. 
So that 4kB was not just the whole kernel call-chain, it was also all the 
irq nesting above it.

And yes, we've gotten much worse over time, and no, I can't really suggest 
going back to that in general. The code bloat has certainly been 
accompanied by a stack bloat too.

But part of it is definitely gcc. Some versions of gcc used to be 
absolutely _horrid_ when it came to stack usage, especially with some 
flags, and especially with the crazy inlining that module-at-a-time 
caused.

But I'd be really happy if some embedded people tried to take some of that 
bloat back, and aim for 4kB stacks. Because it's definitely not 
unrealistic. At least it _shouldn't_ be. And a lot of the cases of us 
having structures on the stack is actually not worth it, and tends to be 
about being lazy rather than anything else.

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                   ` <48B4AE68.4040205-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org>
@ 2008-08-27  2:16                                     ` Parag Warudkar
  2008-08-27  8:44                                       ` Bernd Petrovitsch
  0 siblings, 1 reply; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27  2:16 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 9:31 PM, Greg Ungerer <gerg-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org> wrote:

>
> And the pressure will still be on in _real_ products to reduce
> the RAM footprint as much as possible. There are exceptions but
> generally less is cheaper. Simple economics really.

Well, sure  - but the industry as a whole seems to have gone the other
way - do more with more at the similar or lower price points!
By that definition of less is better we should try and make the kernel
memory pageable (or has someone already done that?) - Windows does it,
by default ;)

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                   ` <alpine.LFD.1.10.0808261837530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-27  2:36                                     ` Parag Warudkar
       [not found]                                       ` <f7848160808261936m18c69dc0r26f41850efae4b91-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2008-08-27  8:32                                       ` Alan Cox
  2008-08-27  6:01                                     ` Paul Mackerras
  1 sibling, 2 replies; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27  2:36 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 9:49 PM, Linus Torvalds
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> wrote:
>
>
> On Tue, 26 Aug 2008, Parag Warudkar wrote:
>>
>> And although you said in your later reply that Linux x86 with 4K
>> stacks should be more than usable - my experiences running a untainted
>> desktop/file server with 4K stack have been always disastrous XFS or
>> not.  It _might_ work for some well defined workloads but you would
>> not want to risk 4K stacks otherwise.
>
> Umm. How long?
>

IIRC the last I tried 4K stacks with x86 was on 2.6.21 - Fedora 7
kernel, around June 07 time frame.
The oops included a ugly and long call trace that I still remember.

> And a lot of the cases of us
> having structures on the stack is actually not worth it, and tends to be
> about being lazy rather than anything else.

What about deep call chains? The problem with the uptake of 4K stacks
seems to be that is not reliably provable that it will work under all
circumstances.

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                       ` <f7848160808261936m18c69dc0r26f41850efae4b91-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-27  2:52                                         ` Linus Torvalds
  0 siblings, 0 replies; 54+ messages in thread
From: Linus Torvalds @ 2008-08-27  2:52 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA



On Tue, 26 Aug 2008, Parag Warudkar wrote:
> 
> What about deep call chains? The problem with the uptake of 4K stacks
> seems to be that is not reliably provable that it will work under all
> circumstances.

Umm. Neither is 8k stacks. Nobody "proved" anything.

But yes, some subsystems have insanely deep call chains. And yes, things 
like the VFS recursion (for symlinks) makes that deeper yet for 
filesystems, although only on the lookup path. And that is exactly the 
kind of thing that can exacerbate the problem of the compiler artificially 
making for a bigger stack footprint of a function (*).

For things like the VFS layer, right now we allow a nesting level of 8, I 
think. If I remember correctly, it was 5 historically. Part of raising 
that depth, though, was that we actually moved the recursive part into 
fs/namei.c, and the nesting stack-depth was something pretty damn small 
when the filesystem used "follow_link" properly and let the VFS do it for 
it (ie the callchain to actually look up the link could be deep, but it 
would not recurse back, and instead just return a pointer, so that the 
actual _recursive_ part was just __do_follow_link() and is just a few 
words on the stack).

So yes, we do have some deep callchains, but they tend to be pretty well 
managed for _good_ code. The problems tend to be the areas with lots of 
indirection layers, and yeah, XFS, MD and ACPI all have those kinds of 
things.

In an embdedded world, many of those should be a non-issue, though. 

			Linus

(*) ie the function that _is_ on the deep chain doesn't actually need much 
of a stack footprint at all itself, but it may call a helper function that 
is _not_ in the deep chain, and if it gets inlined it may give its 
excessive stack footprint to the deep chain - and this is _exactly_ the 
problem that happened with inlining "load_module()".

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                   ` <alpine.LFD.1.10.0808261837530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
  2008-08-27  2:36                                     ` Parag Warudkar
@ 2008-08-27  6:01                                     ` Paul Mackerras
       [not found]                                       ` <18612.60878.887716.452936-nUko2b1QN/1kfgV4h6NXRTJtLkR7yuzc@public.gmane.org>
  2008-08-27 15:18                                       ` Linus Torvalds
  1 sibling, 2 replies; 54+ messages in thread
From: Paul Mackerras @ 2008-08-27  6:01 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Parag Warudkar, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

Linus Torvalds writes:

> 4kB used to be the _only_ choice. And no, there weren't even irq stacks. 
> So that 4kB was not just the whole kernel call-chain, it was also all the 
> irq nesting above it.

I think your memory is failing you.  In 2.4 and earlier, the kernel
stack was 8kB minus the size of the task_struct, which sat at the
start of the 8kB.  For instance, from include/asm-i386/processor.h for
2.4.29:

#define THREAD_SIZE (2*PAGE_SIZE)
#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
#define free_task_struct(p) free_pages((unsigned long) (p), 1)

Paul.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                         ` <20080826232411.GC11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
  2008-08-26 23:51                           ` Linus Torvalds
@ 2008-08-27  8:25                           ` Alan Cox
  2008-08-27 12:52                             ` Parag Warudkar
  1 sibling, 1 reply; 54+ messages in thread
From: Alan Cox @ 2008-08-27  8:25 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

> You have a good point that aiming at 4kB makes 8kB a very safe choice.

Not really no - we use separate IRQ stacks in 4K but not 8K mode on
x86-32. That means you've actually got no more space if you are unlucky
with the timing of events. The 8K mode is merely harder to debug.

If 4K stacks really are not safe then x86-32 really really needs to
switch to using IRQ stacks in 8K stack mode as well.

Alan

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  2:36                                     ` Parag Warudkar
       [not found]                                       ` <f7848160808261936m18c69dc0r26f41850efae4b91-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-27  8:32                                       ` Alan Cox
  1 sibling, 0 replies; 54+ messages in thread
From: Alan Cox @ 2008-08-27  8:32 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

> What about deep call chains? The problem with the uptake of 4K stacks
> seems to be that is not reliably provable that it will work under all
> circumstances.

On x86-32 with 8K stacks your IRQ paths share them so that is even harder
to prove (not that you can prove any of them) and the bugs are more
obscure and random.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 22:54                       ` Parag Warudkar
       [not found]                         ` <f7848160808261554j2f4eaaa6i1ee8801ae75ca7bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2008-08-26 23:47                         ` Linus Torvalds
@ 2008-08-27  8:34                         ` Bernd Petrovitsch
  2 siblings, 0 replies; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27  8:34 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Tue, 2008-08-26 at 18:54 -0400, Parag Warudkar wrote:
> On Tue, Aug 26, 2008 at 5:04 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> 
> > And embedded people (the ones that might care about 1% code size) are the
> > ones that would also want smaller stacks even more!
> 
> This is something I never understood - embedded devices are not going
> to run more than a few processes and 4K*(Few Processes)
>  IMHO is not worth a saving now a days even in embedded world given
> falling memory prices. Or do I misunderstand?

Falling prices are no reason to increase the amount of available RAM (or
other hardware).
Especially if you (intend to) build >1E5 devices - where every Euro
counts.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  2:16                                     ` Parag Warudkar
@ 2008-08-27  8:44                                       ` Bernd Petrovitsch
  0 siblings, 0 replies; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27  8:44 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Greg Ungerer, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded

On Tue, 2008-08-26 at 22:16 -0400, Parag Warudkar wrote:
[...]
> Well, sure  - but the industry as a whole seems to have gone the other

"The industry as a whole" doesn't exist on that low level. You can't
compare the laptop and/or desktop computer market (where one may buy
today hardware that runs in 3 years with the next generation/release of
the OS and applications) with the e.g. "WLAN router" market where - from
the commercial point of view - every Euro counts (and where the
requirements for the lifetime of the device are long frozen before the
thing gets in a shop).

> way - do more with more at the similar or lower price points!
> By that definition of less is better we should try and make the kernel
> memory pageable (or has someone already done that?) - Windows does it,

That doesn't help as in really small devices (like WLAN routers, cable
modems, etc.) you run without any means of paging/swapping. And even
binaries/read-only files are not necessarily executable in place (but
must be loaded into RAM). So you can't flush these pages.

And pageable kernel memory doesn't come for free - even if one only
counts the increased code and it's complexity.

> by default ;)

Which is more a sign that it is probably a very bad idea.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  0:58                             ` Parag Warudkar
       [not found]                               ` <f7848160808261758q7b84aab1m188c1ebb59304818-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-27  9:00                               ` Bernd Petrovitsch
       [not found]                                 ` <1219827609.30209.29.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
  1 sibling, 1 reply; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27  9:00 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Tue, 2008-08-26 at 20:58 -0400, Parag Warudkar wrote:
[...]
> The savings part -financial ones- are not always realizable with the
> way memory is priced/sized/fitted.
> Savings in few Mb of Kernel stack are not necessarily going to allow
> getting rid of a single memory chip of 64M or so.

No, but you can put an additional service(s) on it and sales people have
one (or two or ....) line more for their sales brochures.

> Either that or embedded manufacturing/configurations are different
> than the desktop world.

They are different. Think of running the complete system acting as a
bridge, router and/or firewall (Kernel early 2.4 though) from 4MB flash
in 32MB RAM and - listing the outside visible services - having a
command-line interface, web-GUI (implying a http server) and and a
(net-)SNMP agent on it.
Running a glibc without thread support is win there (implying that there
is no thread support available on that device).

> (If my device has 2 memory slots and my user space requires 100Mb
> including kernel memory - I anyways have to put in 64Mx2 there to take
> advantage of mass manufactured, general purpose memory - so no big
> deal if I saved 1.2Mb in Kernel stack or not. And savings of 64Mb
> Kernel memory are not feasible anyways to allow user space to work
> with 64Mb.)

As soon as product management realizes that there is space left on the
device, they get new ideas and/or customer requirements to run more
services on that device.

> On the other hand reducing  user space memory usage on those devices
> (not counting savings from kernel stack size) is a way more attractive
> option.

There is no question if save space here or there. You save it - sooner
or later - on all fronts. Period.

> And although you said in your later reply that Linux x86 with 4K
> stacks should be more than usable - my experiences running a untainted
> desktop/file server with 4K stack have been always disastrous XFS or
> not.  It _might_ work for some well defined workloads but you would
> not want to risk 4K stacks otherwise.

The embedded world of really small devices usually doesn't run XFS (or
ext? or reiser* of jfs or NFS or ...) or stacks block devices on files
or .....

> I understand the having 4K stack option as a non-default for very
> specific workloads is a good idea but apart from that I think no one
> else seems to bother with reducing stack sizes (by no one I mean other
> OSes.)

They probably gave the idea pretty soon because you need to
rework/improve large parts of the kernel + drivers (and that has two
major problems - it consumes a lot of man power for "no new features and
everything must be completely tested again"[0] and it adds new risks).
And that is practically impossible if one sells "stable driver APIs" for
3rd party (commercial) drivers because these must be changed too.

	Bernd

[0]: Let alone if you (or your customers) need certificates from some
     governmental agencys.
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                       ` <18612.60878.887716.452936-nUko2b1QN/1kfgV4h6NXRTJtLkR7yuzc@public.gmane.org>
@ 2008-08-27 10:58                                         ` Arjan van de Ven
  0 siblings, 0 replies; 54+ messages in thread
From: Arjan van de Ven @ 2008-08-27 10:58 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Linus Torvalds, Parag Warudkar, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

Paul Mackerras wrote:
> Linus Torvalds writes:
> 
>> 4kB used to be the _only_ choice. And no, there weren't even irq stacks. 
>> So that 4kB was not just the whole kernel call-chain, it was also all the 
>> irq nesting above it.
> 
> I think your memory is failing you.  In 2.4 and earlier, the kernel
> stack was 8kB minus the size of the task_struct, which sat at the
> start of the 8kB.  For instance, from include/asm-i386/processor.h for
> 2.4.29:

but was shared with interrupts; so out of the 6Kb left, you had still really only 4Kb for user context stack

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                   ` <alpine.LFD.1.10.0808261726560.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-27 11:58                                     ` Adrian Bunk
       [not found]                                       ` <20080827115829.GF11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-27 11:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 26, 2008 at 05:28:37PM -0700, Linus Torvalds wrote:
> 
> 
> On Wed, 27 Aug 2008, Adrian Bunk wrote:
> > 
> > When did we get callpaths like like nfs+xfs+md+scsi reliably 
> > working with 4kB stacks on x86-32?
> 
> XFS may never have been usable, but the rest, sure.
> 
> And you seem to be making this whole argument an excuse to SUCK, adn an 
> excuse to let gcc crap even more on our stack space.
> 
> Why?
> 
> Why aren't you saying that we should be able to do better? Instead, you 
> seem to asking us to do even worse than we do now?

My main point is:
- getting 4kB stacks working reliably is a hard task
- having an eye on gcc increasing the stack usage, and fixing it if
  required, is relatively easy

If we should be able to do better at getting (and keeping) 4kB stacks 
working, then coping with possible inlining problems caused by gcc
should not be a big problem for us.

> 			Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  1:49                                 ` Linus Torvalds
       [not found]                                   ` <alpine.LFD.1.10.0808261837530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
@ 2008-08-27 11:58                                   ` Adrian Bunk
  1 sibling, 0 replies; 54+ messages in thread
From: Adrian Bunk @ 2008-08-27 11:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Parag Warudkar, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Tue, Aug 26, 2008 at 06:49:19PM -0700, Linus Torvalds wrote:
>...
> But part of it is definitely gcc. Some versions of gcc used to be 
> absolutely _horrid_ when it came to stack usage, especially with some 
> flags, and especially with the crazy inlining that module-at-a-time 
> caused.
>...

That was gcc 3.4.

And due to that we disable unit-at-a-time for gcc 3.4 on 32bit x86.

> 			Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  8:25                           ` Alan Cox
@ 2008-08-27 12:52                             ` Parag Warudkar
       [not found]                               ` <f7848160808270552u2ee66167x912a68e0bf8b25bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27 12:52 UTC (permalink / raw)
  To: Alan Cox
  Cc: Adrian Bunk, Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Wed, Aug 27, 2008 at 4:25 AM, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>> You have a good point that aiming at 4kB makes 8kB a very safe choice.
>
> Not really no - we use separate IRQ stacks in 4K but not 8K mode on
> x86-32. That means you've actually got no more space if you are unlucky
> with the timing of events. The 8K mode is merely harder to debug.
>

By your logic though, XFS on x86 should work fine with 4K stacks -
many will attest that it does not and blows up due to stack issues.

I have first hand experiences of things blowing up with deep call
chains when using 4K stacks where 8K worked just fine on same
workload.

So there is definitely some other problem with 4K stacks.

Thanks
Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                 ` <1219827609.30209.29.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
@ 2008-08-27 12:56                                   ` Parag Warudkar
  2008-08-27 13:17                                     ` Bernd Petrovitsch
  0 siblings, 1 reply; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27 12:56 UTC (permalink / raw)
  To: Bernd Petrovitsch
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 27, 2008 at 5:00 AM, Bernd Petrovitsch <bernd-GBwJepH+xoVeoWH0uzbU5w@public.gmane.org> wrote:

>
> They probably gave the idea pretty soon because you need to
> rework/improve large parts of the kernel + drivers (and that has two
> major problems - it consumes a lot of man power for "no new features and
> everything must be completely tested again"[0] and it adds new risks).
> And that is practically impossible if one sells "stable driver APIs" for
> 3rd party (commercial) drivers because these must be changed too.
>

But not many embedded Linux arches support 4K stacks like Adrian
pointed out earlier.
So the same (lot of man power requirement) would apply to Linux.

Sure it will be good - but how reasonable it is to attempt it and how
reliably it will work under all conceived loads - those are the
questions.

Thanks

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 12:56                                   ` Parag Warudkar
@ 2008-08-27 13:17                                     ` Bernd Petrovitsch
       [not found]                                       ` <1219843032.30209.51.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27 13:17 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Linus Torvalds, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded


On Wed, 2008-08-27 at 08:56 -0400, Parag Warudkar wrote:
> On Wed, Aug 27, 2008 at 5:00 AM, Bernd Petrovitsch <bernd@firmix.at> wrote:
> > They probably gave the idea pretty soon because you need to
> > rework/improve large parts of the kernel + drivers (and that has two
> > major problems - it consumes a lot of man power for "no new features and
> > everything must be completely tested again"[0] and it adds new risks).
> > And that is practically impossible if one sells "stable driver APIs" for
> > 3rd party (commercial) drivers because these must be changed too.
> 
> But not many embedded Linux arches support 4K stacks like Adrian

What is an "embedded Linux arch"?
Personally I encountered i386, ARM, MIPS and PPC in the embedded world.

> pointed out earlier.
> So the same (lot of man power requirement) would apply to Linux.

Of course. Look at the amount of work done by lots of people in that
area (including stack frame size reductions) and on-going discussions.

> Sure it will be good - but how reasonable it is to attempt it and how
> reliably it will work under all conceived loads - those are the
> questions.

If you "develop" an embedded system (which is partly system integration
of existing apps) to be installed in the field, you don't have that many
conceivable work loads compared to a desktop/server system. And you have
a fixed list of drivers and applications.
A usual approach is to run stress tests on several (or all)
subsystems/services/... in parallel and if the device survives it
functioning correctly, it is at least good enough.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                               ` <f7848160808270552u2ee66167x912a68e0bf8b25bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-08-27 13:21                                 ` Alan Cox
       [not found]                                   ` <20080827142142.303cdba8-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
  0 siblings, 1 reply; 54+ messages in thread
From: Alan Cox @ 2008-08-27 13:21 UTC (permalink / raw)
  To: Parag Warudkar
  Cc: Adrian Bunk, Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

> By your logic though, XFS on x86 should work fine with 4K stacks -
> many will attest that it does not and blows up due to stack issues.
> 
> I have first hand experiences of things blowing up with deep call
> chains when using 4K stacks where 8K worked just fine on same
> workload.
> 
> So there is definitely some other problem with 4K stacks.

Nothing of the sort. If it blows up with a 4K stack it will almost
certainly blow up with an 8K stack *eventually* - when a heavy stack usage
coincides with a heavy stack using IRQ handler.

You won't catch it in simple testing, you won't catch it in trivial
simulation and it'll be incredibly hard to reproduce. Not the kind of bug
you want in a production system really. IRQ stacks make things much more
predictable.

Alan

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27  6:01                                     ` Paul Mackerras
       [not found]                                       ` <18612.60878.887716.452936-nUko2b1QN/1kfgV4h6NXRTJtLkR7yuzc@public.gmane.org>
@ 2008-08-27 15:18                                       ` Linus Torvalds
  1 sibling, 0 replies; 54+ messages in thread
From: Linus Torvalds @ 2008-08-27 15:18 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Parag Warudkar, Adrian Bunk, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded



On Wed, 27 Aug 2008, Paul Mackerras wrote:
> 
> I think your memory is failing you.  In 2.4 and earlier, the kernel
> stack was 8kB minus the size of the task_struct, which sat at the
> start of the 8kB.

Yup, you're right.

			Linus

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                       ` <1219843032.30209.51.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
@ 2008-08-27 15:48                                         ` Jamie Lokier
  2008-08-27 16:38                                           ` Bernd Petrovitsch
       [not found]                                           ` <20080827154805.GA25387-yetKDKU6eevNLxjTenLetw@public.gmane.org>
  0 siblings, 2 replies; 54+ messages in thread
From: Jamie Lokier @ 2008-08-27 15:48 UTC (permalink / raw)
  To: Bernd Petrovitsch
  Cc: Parag Warudkar, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

Bernd Petrovitsch wrote:
> If you "develop" an embedded system (which is partly system integration
> of existing apps) to be installed in the field, you don't have that many
> conceivable work loads compared to a desktop/server system. And you have
> a fixed list of drivers and applications.

Hah!  Not in my line of embedded device.

32MB no-MMU ARM boards which people run new things and attach new
devices to rather often - without making new hardware.  Volume's too
low per individual application to get new hardware designed and made.

I'm seriously thinking of forwarding porting the 4 year old firmware
from 2.4.26 to 2.6.current, just to get new drivers and capabilities.
Backporting is tedious, so's feeling wretchedly far from the mainline
world.

> A usual approach is to run stress tests on several (or all)
> subsystems/services/... in parallel and if the device survives it
> functioning correctly, it is at least good enough.

Per application.

Some little devices run hundreds of different applications and
customers expect to customise, script themselves, and attach different
devices (over USB).  The next customer in the chain expects the bits
you supplied to work in a variety of unexpected situations, even when
you advise that it probably won't do that.

Much like desktop/server Linux, but on a small device where silly
little things like 'create a process' are a stress for the dear little
thing.

(My biggest lesson: insist on an MMU next time!)

-- Jamie

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                       ` <20080827115829.GF11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
@ 2008-08-27 16:00                                         ` Paul Mundt
  2008-08-27 17:35                                           ` Adrian Bunk
  2008-08-28  1:05                                           ` Greg Ungerer
  0 siblings, 2 replies; 54+ messages in thread
From: Paul Mundt @ 2008-08-27 16:00 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 27, 2008 at 02:58:30PM +0300, Adrian Bunk wrote:
> On Tue, Aug 26, 2008 at 05:28:37PM -0700, Linus Torvalds wrote:
> > On Wed, 27 Aug 2008, Adrian Bunk wrote:
> > > 
> > > When did we get callpaths like like nfs+xfs+md+scsi reliably 
> > > working with 4kB stacks on x86-32?
> > 
> > XFS may never have been usable, but the rest, sure.
> > 
> > And you seem to be making this whole argument an excuse to SUCK, adn an 
> > excuse to let gcc crap even more on our stack space.
> > 
> > Why?
> > 
> > Why aren't you saying that we should be able to do better? Instead, you 
> > seem to asking us to do even worse than we do now?
> 
> My main point is:
> - getting 4kB stacks working reliably is a hard task
> - having an eye on gcc increasing the stack usage, and fixing it if
>   required, is relatively easy
> 
> If we should be able to do better at getting (and keeping) 4kB stacks 
> working, then coping with possible inlining problems caused by gcc
> should not be a big problem for us.
> 
Out of the architectures you've mentioned for 4k stacks, they also tend
to do IRQ stacks, which is something you seem to have overlooked.

In addition to that, debugging the runaway stack users on 4k tends to be
easier anyways since you end up blowing the stack a lot sooner. On sh
we've had pretty good luck with it, though most of our users are using
fairly deterministic workloads and continually profiling the footprint.
Anything that runs away or uses an insane amount of stack space needs to
be fixed well before that anyways, so catching it sooner is always
preferable. I imagine the same case is true for m68knommu (even sans IRQ
stacks).

Things might be more sensitive on x86, but it's certainly not something
that's a huge problem for the various embedded platforms to wire up,
whether they want to go the IRQ stack route or not.

In any event, lack of support for something on embedded architectures in
the kernel is more often due to apathy/utter indifference on the part of
the architecture maintainer rather than being indicative of any intrinsic
difficulty in supporting the thing in question. Most new "features" on the
lesser maintained architectures tend to end up there either out of peer
pressure or copying-and-pasting accidents rather than any sort of design.
;-)

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-26 20:41                   ` Linus Torvalds
@ 2008-08-27 16:21                     ` Jamie Lokier
  0 siblings, 0 replies; 54+ messages in thread
From: Jamie Lokier @ 2008-08-27 16:21 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Adrian Bunk, Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded

Linus Torvalds wrote:
> > Most LOCs of the kernel are not written by people like you or Al Viro or 
> > David Miller, and the average kernel developer is unlikely to do it as 
> > good as gcc.
> 
> Sure. But we do have tools. We do have checkstack.pl, it's just that it 
> hasn't been an issue in a long time, so I suspect many people didn't even 
> _realize_ we have it, and I certainly can attest to the fact that even 
> people who remember it - like me - don't actually tend to run it all that 
> often.

Sounds like what's really desired here isn't more worry and
unpredictability, but for GCC+Binutils to gain the ability to
calculate the stack depth over all callchains (doesn't have to be
exact, just an upper bound; annotate recursions) in a way that's good
enough to do on every compile, complain if a depth is exceeded
statically (or it can't be proven), and to gain the
architecture-independent option "optimise to reduce stack usage".

> > BTW:
> > I just ran checkstack on a (roughly) allyesconfig kernel, and we have a 
> > new driver that allocates "unsigned char recvbuf[1500];" on the stack...
> 
> Yeah, it's _way_ too easy to do bad things.

In my userspace code, I have macros tmp_alloc and tmp_free.  They must
be matched in the same function:

     unsigned char * recvbuf = tmp_alloc(1500);
     ....
     tmp_free(recvbuf);

When stack is plentiful, it maps to alloca() which is roughly
equivalent to using a stack variable.

When stack is constrained (as it is on my little devices), that maps
to xmalloc/free.  The kernel equivalent would be kmalloc GFP_ATOMIC
(perhaps).

With different macros to mine, it may be possible to map small
fixed-size requests exactly onto local variables, and large ones to
kmalloc().  A stab at it (not tested):

    #define LOCAL_ALLOC_THRESHOLD     128

    #define LOCAL_ALLOC(type, ptr)                                        \
        __typeof__(type) __attribute__((__unused__)) ptr##_local_struct;  \
        __typeof__(type) * ptr =                                          \
              ((__builtin_constant_p(sizeof(type))                        \
                && sizeof(type) <= LOCAL_ALLOC_THRESHOLD)                 \
               ? &ptr##_local_struct : kmalloc(sizeof(type), GFP_ATOMIC))

    #define LOCAL_FREE(ptr)                           \
        ((__builtin_constant_p(sizeof (*(ptr)))       \
          && sizeof(*(ptr)) <= LOCAL_ALLOC_THRESHOLD) \
         ? (void) 0 : kfree(ptr))

Would that be useful in the kernel?

I'm thinking if it were a commonly used pattern for temporary buffers,
unknown structures and arrays of macro-determined size, the "new
driver" author would be less likely to accidentally drop a big object
on the stack.

Obviously it would be nicer for GCC to code such a thing
automatically, but that really is wishful thinking.

-- Jamie

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                   ` <20080827142142.303cdba8-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
@ 2008-08-27 16:24                                     ` Parag Warudkar
  0 siblings, 0 replies; 54+ messages in thread
From: Parag Warudkar @ 2008-08-27 16:24 UTC (permalink / raw)
  To: Alan Cox
  Cc: Adrian Bunk, Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 27, 2008 at 9:21 AM, Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org> wrote:
>> By your logic though, XFS on x86 should work fine with 4K stacks -
>> many will attest that it does not and blows up due to stack issues.
>>
>> I have first hand experiences of things blowing up with deep call
>> chains when using 4K stacks where 8K worked just fine on same
>> workload.
>>
>> So there is definitely some other problem with 4K stacks.
>
> Nothing of the sort. If it blows up with a 4K stack it will almost
> certainly blow up with an 8K stack *eventually* - when a heavy stack usage
> coincides with a heavy stack using IRQ handler.
>
> You won't catch it in simple testing, you won't catch it in trivial
> simulation and it'll be incredibly hard to reproduce. Not the kind of bug
> you want in a production system really. IRQ stacks make things much more
> predictable.


I see - so if I end up having a workload on 8k where heavy stack using
IRQs and deep kernel call chains come at the same time - even 8K will
blow up.
So 4K will blow too except that it doesn't require IRQs also to use
heavy stack, just XFS is good enough :)

It then seems like the IRQs using lot of stack is not so much of a
problem in the current kernel as much as deeper call chains and stack
usage of normal non-irq path code is.
So 8k makes it possible for the deeper call chains of non-irq path to
survive since they get better part of the 8K to themselves and IRQs
can do with less almost always.

At least that's what I can derive from the fact that we do not have
lots of reports of 8K stack blowing up.

Thanks

Parag

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 15:48                                         ` Jamie Lokier
@ 2008-08-27 16:38                                           ` Bernd Petrovitsch
       [not found]                                             ` <1219855121.30209.112.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
       [not found]                                           ` <20080827154805.GA25387-yetKDKU6eevNLxjTenLetw@public.gmane.org>
  1 sibling, 1 reply; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27 16:38 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Parag Warudkar, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded

On Wed, 2008-08-27 at 16:48 +0100, Jamie Lokier wrote:
> Bernd Petrovitsch wrote:
> > If you "develop" an embedded system (which is partly system integration
> > of existing apps) to be installed in the field, you don't have that many
> > conceivable work loads compared to a desktop/server system. And you have
> > a fixed list of drivers and applications.
> 
> Hah!  Not in my line of embedded device.
> 
> 32MB no-MMU ARM boards which people run new things and attach new
> devices to rather often - without making new hardware.  Volume's too
> low per individual application to get new hardware designed and made.

Yes, you may have several products on the same hardware with somewhat
differing requirements (or not). But that is much less than a general
purpose system IMHO.

> I'm seriously thinking of forwarding porting the 4 year old firmware
> from 2.4.26 to 2.6.current, just to get new drivers and capabilities.

That sounds reasonable (and I never meant maintaining the old system
infinitely. Actually once the thing is shipped it usually enters deep
maintenance mode and the next is more a fork from the old).

> Backporting is tedious, so's feeling wretchedly far from the mainline
> world.

ACK. But that also depends on amount local changes (and sorry, but not
all locally necessary patches would be accepted in mainline in any way).

> > A usual approach is to run stress tests on several (or all)
> > subsystems/services/... in parallel and if the device survives it
> > functioning correctly, it is at least good enough.
> 
> Per application.
> 
> Some little devices run hundreds of different applications and
> customers expect to customise, script themselves, and attach different
> devices (over USB).  The next customer in the chain expects the bits
> you supplied to work in a variety of unexpected situations, even when
> you advise that it probably won't do that.

Basically their problem. Yes, "they" actually think they get a Linux
system where they can do everything and it simply works.

Oh, that's obviously not a usual "WLAN-router style" of product (where
you are not expected to actually login on a console or per ssh).

> Much like desktop/server Linux, but on a small device where silly
> little things like 'create a process' are a stress for the dear little
> thing.
> 
> (My biggest lesson: insist on an MMU next time!)

ACK. We avoid MMU-less hardware too - especially since there is enough
hardware with a MMU around.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 16:00                                         ` Paul Mundt
@ 2008-08-27 17:35                                           ` Adrian Bunk
  2008-08-28  0:32                                             ` Paul Mundt
  2008-08-28  1:05                                           ` Greg Ungerer
  1 sibling, 1 reply; 54+ messages in thread
From: Adrian Bunk @ 2008-08-27 17:35 UTC (permalink / raw)
  To: Paul Mundt, Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael 

On Thu, Aug 28, 2008 at 01:00:52AM +0900, Paul Mundt wrote:
> On Wed, Aug 27, 2008 at 02:58:30PM +0300, Adrian Bunk wrote:
> > On Tue, Aug 26, 2008 at 05:28:37PM -0700, Linus Torvalds wrote:
> > > On Wed, 27 Aug 2008, Adrian Bunk wrote:
> > > > 
> > > > When did we get callpaths like like nfs+xfs+md+scsi reliably 
> > > > working with 4kB stacks on x86-32?
> > > 
> > > XFS may never have been usable, but the rest, sure.
> > > 
> > > And you seem to be making this whole argument an excuse to SUCK, adn an 
> > > excuse to let gcc crap even more on our stack space.
> > > 
> > > Why?
> > > 
> > > Why aren't you saying that we should be able to do better? Instead, you 
> > > seem to asking us to do even worse than we do now?
> > 
> > My main point is:
> > - getting 4kB stacks working reliably is a hard task
> > - having an eye on gcc increasing the stack usage, and fixing it if
> >   required, is relatively easy
> > 
> > If we should be able to do better at getting (and keeping) 4kB stacks 
> > working, then coping with possible inlining problems caused by gcc
> > should not be a big problem for us.
> > 
> Out of the architectures you've mentioned for 4k stacks, they also tend
> to do IRQ stacks, which is something you seem to have overlooked.

No, I am aware of that, and on i386 IRQ stacks are only used with
4kB stacks.

On i386 it is effectively a step from 6kB to 4kB.

> In addition to that, debugging the runaway stack users on 4k tends to be
> easier anyways since you end up blowing the stack a lot sooner. On sh
> we've had pretty good luck with it, though most of our users are using
> fairly deterministic workloads and continually profiling the footprint.
> Anything that runs away or uses an insane amount of stack space needs to
> be fixed well before that anyways, so catching it sooner is always
> preferable. I imagine the same case is true for m68knommu (even sans IRQ
> stacks).

CONFIG_DEBUG_STACKOVERFLOW should give you the same information, and if
wanted with an arbitrary limit.

> Things might be more sensitive on x86, but it's certainly not something
> that's a huge problem for the various embedded platforms to wire up,
> whether they want to go the IRQ stack route or not.

How many platforms use 4kB stacks on sh?

Only 1 out of 34 defconfigs uses it.

Are there any numbers for real life usage.

> In any event, lack of support for something on embedded architectures in
> the kernel is more often due to apathy/utter indifference on the part of
> the architecture maintainer rather than being indicative of any intrinsic
> difficulty in supporting the thing in question. Most new "features" on the
> lesser maintained architectures tend to end up there either out of peer
> pressure or copying-and-pasting accidents rather than any sort of design.
> ;-)

arm or powerpc aren't exactly lesser maintained architectures.

4kB has shown to be a hard to achieve limit. After more than 4 years in 
mainline being available on i386 there are still cases where 4kB are not 
enough.

IMHO there seems to currently be a mismatch between it's maintainance 
cost and the actual number of users. That's in my opinion the main 
problem with it, no matter in which direction it gets resolved.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                             ` <1219855121.30209.112.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
@ 2008-08-27 17:51                                               ` Jamie Lokier
  2008-08-27 19:30                                                 ` Bernd Petrovitsch
  2008-08-28  0:06                                                 ` Greg Ungerer
  0 siblings, 2 replies; 54+ messages in thread
From: Jamie Lokier @ 2008-08-27 17:51 UTC (permalink / raw)
  To: Bernd Petrovitsch
  Cc: Parag Warudkar, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

Bernd Petrovitsch wrote:
> > 32MB no-MMU ARM boards which people run new things and attach new
> > devices to rather often - without making new hardware.  Volume's too
> > low per individual application to get new hardware designed and made.
> 
> Yes, you may have several products on the same hardware with somewhat
> differing requirements (or not). But that is much less than a general
> purpose system IMHO.

It is, but the idea that small embedded systems go through a 'all
components are known, drivers are known, test and if it passes it's
shippable' does not always apply.

> > I'm seriously thinking of forwarding porting the 4 year old firmware
> > from 2.4.26 to 2.6.current, just to get new drivers and capabilities.
> 
> That sounds reasonable (and I never meant maintaining the old system
> infinitely.

Sounds reasonable, but it's vetoed for anticipated time and cost,
compared with backporting on demand.  Fair enough, since 2.6.current
doesn't support ARM no-MMU last I heard ('soon'?).

On the other hand, the 2.6 anti-fragmentation patches, including
latest SLUB stuff, ironically meant to help big machines, sound really
appealing for my current problem and totally unrealistic to
backport...

> ACK. We avoid MMU-less hardware too - especially since there is enough
> hardware with a MMU around.

I can't emphasise enough how much difference MMU makes to Linux userspace.

It's practically: MMU = standard Linux (with less RAM), have everything.
No-MMU = lots of familiar 'Linux' things not available or break.

-- Jamie

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 17:51                                               ` Jamie Lokier
@ 2008-08-27 19:30                                                 ` Bernd Petrovitsch
  2008-08-28  0:06                                                 ` Greg Ungerer
  1 sibling, 0 replies; 54+ messages in thread
From: Bernd Petrovitsch @ 2008-08-27 19:30 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Parag Warudkar, Linus Torvalds, Adrian Bunk, Rusty Russell,
	Alan D. Brunelle, Rafael J. Wysocki, Linux Kernel Mailing List,
	Kernel Testers List, Andrew Morton, Arjan van de Ven, Ingo Molnar,
	linux-embedded

On Mit, 2008-08-27 at 18:51 +0100, Jamie Lokier wrote:
> Bernd Petrovitsch wrote:
[...]
> It is, but the idea that small embedded systems go through a 'all
> components are known, drivers are known, test and if it passes it's
> shippable' does not always apply.

Not always but often enough. And yes, there is ARM-based embedded
hardware with 1GB Flash-RAM and 128MB RAM.

> > > I'm seriously thinking of forwarding porting the 4 year old firmware
> > > from 2.4.26 to 2.6.current, just to get new drivers and capabilities.
> > 
> > That sounds reasonable (and I never meant maintaining the old system
> > infinitely.
> 
> Sounds reasonable, but it's vetoed for anticipated time and cost,

That is to be expected;-)

[....]
> > ACK. We avoid MMU-less hardware too - especially since there is enough
> > hardware with a MMU around.
> 
> I can't emphasise enough how much difference MMU makes to Linux userspace.
> 
> It's practically: MMU = standard Linux (with less RAM), have everything.
> No-MMU = lots of familiar 'Linux' things not available or break.

ACK. And tell that a customer that everything is more effort and more
risk and not just "simply cross-compile it as it runs on my desktop
too".

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 17:51                                               ` Jamie Lokier
  2008-08-27 19:30                                                 ` Bernd Petrovitsch
@ 2008-08-28  0:06                                                 ` Greg Ungerer
  1 sibling, 0 replies; 54+ messages in thread
From: Greg Ungerer @ 2008-08-28  0:06 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Bernd Petrovitsch, Parag Warudkar, Linus Torvalds, Adrian Bunk,
	Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar, linux-embedded


Jamie Lokier wrote:
> Bernd Petrovitsch wrote:
>>> 32MB no-MMU ARM boards which people run new things and attach new
>>> devices to rather often - without making new hardware.  Volume's too
>>> low per individual application to get new hardware designed and made.
>> Yes, you may have several products on the same hardware with somewhat
>> differing requirements (or not). But that is much less than a general
>> purpose system IMHO.
> 
> It is, but the idea that small embedded systems go through a 'all
> components are known, drivers are known, test and if it passes it's
> shippable' does not always apply.
> 
>>> I'm seriously thinking of forwarding porting the 4 year old firmware
>>> from 2.4.26 to 2.6.current, just to get new drivers and capabilities.
>> That sounds reasonable (and I never meant maintaining the old system
>> infinitely.
> 
> Sounds reasonable, but it's vetoed for anticipated time and cost,
> compared with backporting on demand.  Fair enough, since 2.6.current
> doesn't support ARM no-MMU last I heard ('soon'?).
> 
> On the other hand, the 2.6 anti-fragmentation patches, including
> latest SLUB stuff, ironically meant to help big machines, sound really
> appealing for my current problem and totally unrealistic to
> backport...
> 
>> ACK. We avoid MMU-less hardware too - especially since there is enough
>> hardware with a MMU around.
> 
> I can't emphasise enough how much difference MMU makes to Linux userspace.
> 
> It's practically: MMU = standard Linux (with less RAM), have everything.
> No-MMU = lots of familiar 'Linux' things not available or break.

And lots of things work in the usual way...

Of course the flip side is that for people who have platforms
without MMU they can run something more than the mostly "toy"
like operating systems typically available. There are plenty of
problem domains that the non-MMU limitations are not a problem for.
(Yours doesn't sound like one of them :-)

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg@snapgear.com
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                           ` <20080827154805.GA25387-yetKDKU6eevNLxjTenLetw@public.gmane.org>
@ 2008-08-28  0:11                                             ` Greg Ungerer
  0 siblings, 0 replies; 54+ messages in thread
From: Greg Ungerer @ 2008-08-28  0:11 UTC (permalink / raw)
  To: Jamie Lokier
  Cc: Bernd Petrovitsch, Parag Warudkar, Linus Torvalds, Adrian Bunk,
	Rusty Russell, Alan D. Brunelle, Rafael J. Wysocki,
	Linux Kernel Mailing List, Kernel Testers List, Andrew Morton,
	Arjan van de Ven, Ingo Molnar,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA


Jamie Lokier wrote:
> Bernd Petrovitsch wrote:
>> If you "develop" an embedded system (which is partly system integration
>> of existing apps) to be installed in the field, you don't have that many
>> conceivable work loads compared to a desktop/server system. And you have
>> a fixed list of drivers and applications.
> 
> Hah!  Not in my line of embedded device.
> 
> 32MB no-MMU ARM boards which people run new things and attach new
> devices to rather often - without making new hardware.  Volume's too
> low per individual application to get new hardware designed and made.
> 
> I'm seriously thinking of forwarding porting the 4 year old firmware
> from 2.4.26 to 2.6.current, just to get new drivers and capabilities.
> Backporting is tedious, so's feeling wretchedly far from the mainline
> world.
> 
>> A usual approach is to run stress tests on several (or all)
>> subsystems/services/... in parallel and if the device survives it
>> functioning correctly, it is at least good enough.
> 
> Per application.
> 
> Some little devices run hundreds of different applications and
> customers expect to customise, script themselves, and attach different
> devices (over USB).  The next customer in the chain expects the bits
> you supplied to work in a variety of unexpected situations, even when
> you advise that it probably won't do that.
> 
> Much like desktop/server Linux, but on a small device where silly
> little things like 'create a process' are a stress for the dear little
> thing.
> 
> (My biggest lesson: insist on an MMU next time!)

But given you have hardware you can't change would you choose
to not run Linux, even with the limitations of non-MMU?

Hell no :-)

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 17:35                                           ` Adrian Bunk
@ 2008-08-28  0:32                                             ` Paul Mundt
  2008-08-28  0:46                                               ` David Miller
  2008-08-28 16:16                                               ` Adrian Bunk
  0 siblings, 2 replies; 54+ messages in thread
From: Paul Mundt @ 2008-08-28  0:32 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael J. Wysocki, Linux Kernel Mailing List, Kernel Testers List,
	Andrew Morton, Arjan van de Ven, Ingo Molnar, linux-embedded

On Wed, Aug 27, 2008 at 08:35:44PM +0300, Adrian Bunk wrote:
> On Thu, Aug 28, 2008 at 01:00:52AM +0900, Paul Mundt wrote:
> > On Wed, Aug 27, 2008 at 02:58:30PM +0300, Adrian Bunk wrote:
> > In addition to that, debugging the runaway stack users on 4k tends to be
> > easier anyways since you end up blowing the stack a lot sooner. On sh
> > we've had pretty good luck with it, though most of our users are using
> > fairly deterministic workloads and continually profiling the footprint.
> > Anything that runs away or uses an insane amount of stack space needs to
> > be fixed well before that anyways, so catching it sooner is always
> > preferable. I imagine the same case is true for m68knommu (even sans IRQ
> > stacks).
> 
> CONFIG_DEBUG_STACKOVERFLOW should give you the same information, and if
> wanted with an arbitrary limit.
> 
In some cases, yes. In the CONFIG_DEBUG_STACKOVERFLOW case the check is
only performed from do_IRQ(), which is sporadic at best, especially on
tickless. While it catches some things, it's not a complete solution in
and of iteslf.

In addition to this, there are even fewer platforms that support it than
there are platforms that do 4k stacks. At first glance, it looks like
it's only m32r, powerpc, sh, x86, and xtensa. Others support the Kconfig
option, but don't seem to realize that it's not an option that the kernel
does anything with by itself, and so don't actually do anything (ie,
FRV).

> > Things might be more sensitive on x86, but it's certainly not something
> > that's a huge problem for the various embedded platforms to wire up,
> > whether they want to go the IRQ stack route or not.
> 
> How many platforms use 4kB stacks on sh?
> 
> Only 1 out of 34 defconfigs uses it.
> 
The defconfigs tend to enable as much random stuff as people are
interested in for development and testing purposes. Most of these end up
being reference boards and are the basis for products, rather than
shipping products themselves. In the latter case, everything is gradually
tightened down, and 4k stack utilization in that case is the norm, rather
than the exception.

> > In any event, lack of support for something on embedded architectures in
> > the kernel is more often due to apathy/utter indifference on the part of
> > the architecture maintainer rather than being indicative of any intrinsic
> > difficulty in supporting the thing in question. Most new "features" on the
> > lesser maintained architectures tend to end up there either out of peer
> > pressure or copying-and-pasting accidents rather than any sort of design.
> > ;-)
> 
> arm or powerpc aren't exactly lesser maintained architectures.
> 
Indeed, which is why I find it bizarre that you would even bother
applying what was said to those platforms. Specifically I was referring
to the embedded platforms that don't do 4k stacks today. The fact they
don't support them today has much less to do with 4k being an
unattainable limit as it does with people simply not bothering to
implement it on their platform.

> IMHO there seems to currently be a mismatch between it's maintainance 
> cost and the actual number of users. That's in my opinion the main 
> problem with it, no matter in which direction it gets resolved.
> 
Perhaps that's true on x86, but in general I take issue with that. On sh
we've had to do very little maintenance for it and most shipping products
are using it today (at least on MMU-Linux, we don't bother with it on
nommu). Most of the problems we ran in to with 4k stacks tended to be
stuff that we wanted to fix for 8k anyways. I suspect that this case is
true for the other embedded platforms also.

Note that on sh we also conditionalize IRQ stacks separately, so while
they are often used together, it's possible to use 4k stacks without
resorting to IRQ stacks (as m68knommu also seems to do).

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-28  0:32                                             ` Paul Mundt
@ 2008-08-28  0:46                                               ` David Miller
       [not found]                                                 ` <20080827.174605.85608276.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  2008-08-28 16:16                                               ` Adrian Bunk
  1 sibling, 1 reply; 54+ messages in thread
From: David Miller @ 2008-08-28  0:46 UTC (permalink / raw)
  To: lethal
  Cc: bunk, torvalds, rusty, Alan.Brunelle, rjw, linux-kernel,
	kernel-testers, akpm, arjan, mingo, linux-embedded

From: Paul Mundt <lethal@linux-sh.org>
Date: Thu, 28 Aug 2008 09:32:13 +0900

> On Wed, Aug 27, 2008 at 08:35:44PM +0300, Adrian Bunk wrote:
> > CONFIG_DEBUG_STACKOVERFLOW should give you the same information, and if
> > wanted with an arbitrary limit.
>
> In some cases, yes. In the CONFIG_DEBUG_STACKOVERFLOW case the check is
> only performed from do_IRQ(), which is sporadic at best, especially on
> tickless. While it catches some things, it's not a complete solution in
> and of iteslf.

BTW, on sparc64 we have a stack overflow checker that runs via
the profiling _mcount hook.  So every function call we check
if the stack is getting overused.

If so, we jump onto a special static debugging stack and print
the stack overflow message.

And yes it works with IRQ stacks which is all that sparc64 uses
nowadays.

Perhaps this is useful enough to make generic.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
       [not found]                                                 ` <20080827.174605.85608276.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2008-08-28  1:02                                                   ` Paul Mundt
  0 siblings, 0 replies; 54+ messages in thread
From: Paul Mundt @ 2008-08-28  1:02 UTC (permalink / raw)
  To: David Miller
  Cc: bunk-DgEjT+Ai2ygdnm+yROfE0A,
	torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	rusty-8n+1lVoiYb80n/F98K4Iww, Alan.Brunelle-VXdhtT5mjnY,
	rjw-KKrjLPT3xs0, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-testers-u79uwXL29TY76Z2rM5mHXA,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	arjan-VuQAYsv1563Yd54FQh9/CA, mingo-X9Un+BFzKDI,
	linux-embedded-u79uwXL29TY76Z2rM5mHXA

On Wed, Aug 27, 2008 at 05:46:05PM -0700, David Miller wrote:
> From: Paul Mundt <lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org>
> Date: Thu, 28 Aug 2008 09:32:13 +0900
> 
> > On Wed, Aug 27, 2008 at 08:35:44PM +0300, Adrian Bunk wrote:
> > > CONFIG_DEBUG_STACKOVERFLOW should give you the same information, and if
> > > wanted with an arbitrary limit.
> >
> > In some cases, yes. In the CONFIG_DEBUG_STACKOVERFLOW case the check is
> > only performed from do_IRQ(), which is sporadic at best, especially on
> > tickless. While it catches some things, it's not a complete solution in
> > and of iteslf.
> 
> BTW, on sparc64 we have a stack overflow checker that runs via
> the profiling _mcount hook.  So every function call we check
> if the stack is getting overused.
> 
> If so, we jump onto a special static debugging stack and print
> the stack overflow message.
> 
> And yes it works with IRQ stacks which is all that sparc64 uses
> nowadays.
> 
> Perhaps this is useful enough to make generic.

Thanks for the pointer, I'll take a look at it!

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-27 16:00                                         ` Paul Mundt
  2008-08-27 17:35                                           ` Adrian Bunk
@ 2008-08-28  1:05                                           ` Greg Ungerer
  1 sibling, 0 replies; 54+ messages in thread
From: Greg Ungerer @ 2008-08-28  1:05 UTC (permalink / raw)
  To: Paul Mundt, Adrian Bunk, Linus Torvalds, Rusty Russell,
	"Alan D. Brunelle" <Alan.Brunel>


Paul Mundt wrote:
> On Wed, Aug 27, 2008 at 02:58:30PM +0300, Adrian Bunk wrote:
>> On Tue, Aug 26, 2008 at 05:28:37PM -0700, Linus Torvalds wrote:
>>> On Wed, 27 Aug 2008, Adrian Bunk wrote:
>>>> When did we get callpaths like like nfs+xfs+md+scsi reliably 
>>>> working with 4kB stacks on x86-32?
>>> XFS may never have been usable, but the rest, sure.
>>>
>>> And you seem to be making this whole argument an excuse to SUCK, adn an 
>>> excuse to let gcc crap even more on our stack space.
>>>
>>> Why?
>>>
>>> Why aren't you saying that we should be able to do better? Instead, you 
>>> seem to asking us to do even worse than we do now?
>> My main point is:
>> - getting 4kB stacks working reliably is a hard task
>> - having an eye on gcc increasing the stack usage, and fixing it if
>>   required, is relatively easy
>>
>> If we should be able to do better at getting (and keeping) 4kB stacks 
>> working, then coping with possible inlining problems caused by gcc
>> should not be a big problem for us.
>>
> Out of the architectures you've mentioned for 4k stacks, they also tend
> to do IRQ stacks, which is something you seem to have overlooked.
> 
> In addition to that, debugging the runaway stack users on 4k tends to be
> easier anyways since you end up blowing the stack a lot sooner. On sh
> we've had pretty good luck with it, though most of our users are using
> fairly deterministic workloads and continually profiling the footprint.
> Anything that runs away or uses an insane amount of stack space needs to
> be fixed well before that anyways, so catching it sooner is always
> preferable. I imagine the same case is true for m68knommu (even sans IRQ
> stacks).

Yep, definitely true for m68knommu in my experience. I haven't had
any problems with 4k stacks recently. But yes the workloads do tend
to be constrained - and almost never use any of the more exotic
filesystems or drivers.



> Things might be more sensitive on x86, but it's certainly not something
> that's a huge problem for the various embedded platforms to wire up,
> whether they want to go the IRQ stack route or not.
> 
> In any event, lack of support for something on embedded architectures in
> the kernel is more often due to apathy/utter indifference on the part of
> the architecture maintainer rather than being indicative of any intrinsic
> difficulty in supporting the thing in question. Most new "features" on the
> lesser maintained architectures tend to end up there either out of peer
> pressure or copying-and-pasting accidents rather than any sort of design.
> ;-)

Indeed :-)

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg@snapgear.com
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
  2008-08-28  0:32                                             ` Paul Mundt
  2008-08-28  0:46                                               ` David Miller
@ 2008-08-28 16:16                                               ` Adrian Bunk
  1 sibling, 0 replies; 54+ messages in thread
From: Adrian Bunk @ 2008-08-28 16:16 UTC (permalink / raw)
  To: Paul Mundt, Linus Torvalds, Rusty Russell, Alan D. Brunelle,
	Rafael 

On Thu, Aug 28, 2008 at 09:32:13AM +0900, Paul Mundt wrote:
> On Wed, Aug 27, 2008 at 08:35:44PM +0300, Adrian Bunk wrote:
> > On Thu, Aug 28, 2008 at 01:00:52AM +0900, Paul Mundt wrote:
> > > On Wed, Aug 27, 2008 at 02:58:30PM +0300, Adrian Bunk wrote:
> > > In addition to that, debugging the runaway stack users on 4k tends to be
> > > easier anyways since you end up blowing the stack a lot sooner. On sh
> > > we've had pretty good luck with it, though most of our users are using
> > > fairly deterministic workloads and continually profiling the footprint.
> > > Anything that runs away or uses an insane amount of stack space needs to
> > > be fixed well before that anyways, so catching it sooner is always
> > > preferable. I imagine the same case is true for m68knommu (even sans IRQ
> > > stacks).
> > 
> > CONFIG_DEBUG_STACKOVERFLOW should give you the same information, and if
> > wanted with an arbitrary limit.
> > 
> In some cases, yes. In the CONFIG_DEBUG_STACKOVERFLOW case the check is
> only performed from do_IRQ(), which is sporadic at best, especially on
> tickless. While it catches some things, it's not a complete solution in
> and of iteslf.
> 
> In addition to this, there are even fewer platforms that support it than
> there are platforms that do 4k stacks. At first glance, it looks like
> it's only m32r, powerpc, sh, x86, and xtensa.
>...

As far as I can see the only architectures that optionally offer 4kB 
stacks today are m68knommu, s390, sh and x86.

Did I miss some architectures or is 5 < 4 ;) ?

> Others support the Kconfig
> option, but don't seem to realize that it's not an option that the kernel
> does anything with by itself, and so don't actually do anything (ie,
> FRV).

Unless I miss anything these "others" include only FRV.

> > IMHO there seems to currently be a mismatch between it's maintainance 
> > cost and the actual number of users. That's in my opinion the main 
> > problem with it, no matter in which direction it gets resolved.
> > 
> Perhaps that's true on x86, but in general I take issue with that. On sh
> we've had to do very little maintenance for it and most shipping products
> are using it today (at least on MMU-Linux, we don't bother with it on
> nommu). Most of the problems we ran in to with 4k stacks tended to be
> stuff that we wanted to fix for 8k anyways. I suspect that this case is
> true for the other embedded platforms also.
>...

Most stack issues are not platform or architecture specific.

The maintainance effort therefore mostly depends on whether a non-zero 
number of architectures uses 4kB stacks.

And if something is considered to be important for small embedded 
systems, but not supported on ARM, MIPS or PowerPC, then that's 
a bit strange.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2008-08-28 16:16 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mzBsPw3QUOF.A.87F.wZGsIB@albercik>
     [not found] ` <48B313E0.1000501@hp.com>
     [not found]   ` <alpine.LFD.1.10.0808251326500.3363@nehalem.linux-foundation.org>
     [not found]     ` <200808261111.19205.rusty@rustcorp.com.au>
     [not found]       ` <alpine.LFD.1.10.0808261019450.3363@nehalem.linux-foundation.org>
2008-08-26 18:30         ` [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected Adrian Bunk
     [not found]           ` <20080826183051.GB10925-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
2008-08-26 18:40             ` Linus Torvalds
     [not found]               ` <alpine.LFD.1.10.0808261134530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-26 20:21                 ` Adrian Bunk
2008-08-26 20:41                   ` Linus Torvalds
2008-08-27 16:21                     ` Jamie Lokier
2008-08-26 18:47             ` Linus Torvalds
2008-08-26 19:02               ` Jamie Lokier
     [not found]                 ` <20080826190213.GA30255-yetKDKU6eevNLxjTenLetw@public.gmane.org>
2008-08-26 19:18                   ` Linus Torvalds
     [not found]               ` <alpine.LFD.1.10.0808261144510.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-26 20:59                 ` Adrian Bunk
2008-08-26 21:04                   ` Linus Torvalds
     [not found]                     ` <alpine.LFD.1.10.0808261403360.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-26 22:54                       ` Parag Warudkar
     [not found]                         ` <f7848160808261554j2f4eaaa6i1ee8801ae75ca7bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-26 23:00                           ` David VomLehn
2008-08-26 23:45                             ` Adrian Bunk
2008-08-26 23:47                         ` Linus Torvalds
     [not found]                           ` <alpine.LFD.1.10.0808261644260.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-27  0:53                             ` Greg Ungerer
2008-08-27  1:08                               ` Parag Warudkar
2008-08-27  1:31                                 ` Greg Ungerer
     [not found]                                   ` <48B4AE68.4040205-XXXsiaCtIV5Wk0Htik3J/w@public.gmane.org>
2008-08-27  2:16                                     ` Parag Warudkar
2008-08-27  8:44                                       ` Bernd Petrovitsch
2008-08-27  0:58                             ` Parag Warudkar
     [not found]                               ` <f7848160808261758q7b84aab1m188c1ebb59304818-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-27  1:49                                 ` Linus Torvalds
     [not found]                                   ` <alpine.LFD.1.10.0808261837530.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-27  2:36                                     ` Parag Warudkar
     [not found]                                       ` <f7848160808261936m18c69dc0r26f41850efae4b91-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-27  2:52                                         ` Linus Torvalds
2008-08-27  8:32                                       ` Alan Cox
2008-08-27  6:01                                     ` Paul Mackerras
     [not found]                                       ` <18612.60878.887716.452936-nUko2b1QN/1kfgV4h6NXRTJtLkR7yuzc@public.gmane.org>
2008-08-27 10:58                                         ` Arjan van de Ven
2008-08-27 15:18                                       ` Linus Torvalds
2008-08-27 11:58                                   ` Adrian Bunk
2008-08-27  9:00                               ` Bernd Petrovitsch
     [not found]                                 ` <1219827609.30209.29.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
2008-08-27 12:56                                   ` Parag Warudkar
2008-08-27 13:17                                     ` Bernd Petrovitsch
     [not found]                                       ` <1219843032.30209.51.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
2008-08-27 15:48                                         ` Jamie Lokier
2008-08-27 16:38                                           ` Bernd Petrovitsch
     [not found]                                             ` <1219855121.30209.112.camel-7sPfb3biEqGJZy4MaDjwDw@public.gmane.org>
2008-08-27 17:51                                               ` Jamie Lokier
2008-08-27 19:30                                                 ` Bernd Petrovitsch
2008-08-28  0:06                                                 ` Greg Ungerer
     [not found]                                           ` <20080827154805.GA25387-yetKDKU6eevNLxjTenLetw@public.gmane.org>
2008-08-28  0:11                                             ` Greg Ungerer
2008-08-27  8:34                         ` Bernd Petrovitsch
2008-08-26 23:24                       ` Adrian Bunk
     [not found]                         ` <20080826232411.GC11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
2008-08-26 23:51                           ` Linus Torvalds
     [not found]                             ` <alpine.LFD.1.10.0808261648140.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-27  0:23                               ` Adrian Bunk
2008-08-27  0:28                                 ` Linus Torvalds
     [not found]                                   ` <alpine.LFD.1.10.0808261726560.3363-nfNrOhbfy2R17+2ddN/4kux8cNe9sq/dYPYVAmT7z5s@public.gmane.org>
2008-08-27 11:58                                     ` Adrian Bunk
     [not found]                                       ` <20080827115829.GF11734-re2QNgSbS3j4D6uPqz5PAwR5/fbUUdgG@public.gmane.org>
2008-08-27 16:00                                         ` Paul Mundt
2008-08-27 17:35                                           ` Adrian Bunk
2008-08-28  0:32                                             ` Paul Mundt
2008-08-28  0:46                                               ` David Miller
     [not found]                                                 ` <20080827.174605.85608276.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2008-08-28  1:02                                                   ` Paul Mundt
2008-08-28 16:16                                               ` Adrian Bunk
2008-08-28  1:05                                           ` Greg Ungerer
2008-08-27  8:25                           ` Alan Cox
2008-08-27 12:52                             ` Parag Warudkar
     [not found]                               ` <f7848160808270552u2ee66167x912a68e0bf8b25bf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-27 13:21                                 ` Alan Cox
     [not found]                                   ` <20080827142142.303cdba8-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2008-08-27 16:24                                     ` Parag Warudkar

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