Re: [PATCH][RFC] 4K stacks default, not a debug thing any more...?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 13, 2007 at 03:20:54PM +0200, Rene Herman wrote:
> On 07/13/2007 06:14 AM, Jeremy Fitzhardinge wrote:
> 
> >Jesper Juhl wrote:
> 
> >>Yes and no.  If that will get things moving in the direction of
> >>getting rid of the stack size as a config option, then I'm all for it.
> >>But on the other hand it is my personal opinion that this is an area
> >>where we should just make up our minds as to whether we want 4K or 8K
> >>stacks and whether we want interrupt stacks or not, and then not have
> >>it configurable at all.  
> >
> >Well, smaller stacks are better where possible, but there's nothing 
> >magic about 4k.
> 
> Except offcourse it happens to also be the value of PAGE_SIZE at least on 
> x86...
> 
> >Sure, its mostly enough, but there's no particular reason to believe it
> >will be enough for everything.  You could state a priori that all kernel
> >code paths must fit into 4k of stack, but that's pretty arbitrary.
> 
> As far as I'm aware, the actual reason for 4K stacks is that after the 
> system has been up and running for some time getting "1 physically 
> contiguous pages" becomes significantly easier than 2 which wouldn't be 
> arbitrary.

If there are exactly two free pages in the system, the odds of them
being buddies (ie adjacent AND properly aligned) is quite small. The
available page pool has to grow quite a bit before the availability of
order-1 page pairs approaches 100%. 

So if we fail to allocate an 8k stack when we could have allocated a
4k stack, we're almost certainly failing significantly prematurely.

As I've pointed out before, it's fairly easy to make our stack
growable with a trampoline in the troublesome paths. Something like:

int growstack(int headroom, int func, void *data)
{
	void *new_stack;
	int ret;

	if (likely(available_stack() > headroom))
		return func(data);

#ifdef CONFIG_GROWSTACK_STATS
	/* gather statistics about stack-heavy paths */
#endif
	/* warn/abort if we're recursing too deeply */

	new_stack = get_free_page();
	switch_to_new_stack(new_stack);
	ret = func(data);
	cleanup_stack(new_stack);
	return ret;
}

-- 
Mathematics is the supreme nostalgia of our time.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux