All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Matt Mackall <mpm@selenic.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Light-weight dynamically extended stacks
Date: Mon, 19 Dec 2005 19:36:04 +0100	[thread overview]
Message-ID: <20051219183604.GT23349@stusta.de> (raw)
In-Reply-To: <20051219001249.GD11856@waste.org>

On Sun, Dec 18, 2005 at 04:12:49PM -0800, Matt Mackall wrote:

> Perhaps the time for this has come and gone, but it occurred to me
> that it should be relatively straightforward to make a form of
> dynamically extended stacks that are appropriate to the kernel.
> 
> While we have a good handle on most of the worst stack offenders, we
> can still run into trouble with pathological cases (say, symlink
> recursion for XFS on a RAID built from loopback mounts over NFS
> tunneled over IPSEC through GRE). So there's probably no
> one-size-fits-all when it comes to stack size.

My count of bug reports for problems with in-kernel code with 4k stacks 
after Neil's patch went into -mm is still at 0. That's amazing 
considering how many people have claimed in this thread how unstable
4k stacks were...

> Rather than relying on guard pages and VM faults like userspace, we
> can use a cooperative scheme where we "label" call paths that might be
> extra deep (recursion through the block layer, network tunnels,
> symlinks, etc.) with something like the following:
> 
> 	  ret = grow_stack(function, arg, GFP_ATOMIC);
> 
> This is much like cond_resched() except for stack usage rather than
> CPU usage. grow_stack() checks if we're in the danger zone for stack
> usage (say 1k remaining), and if so, allocates a new stack and
> swizzles the stack pointer over to it.
>...

If more than 3 kB of stack is used on i386 that's a bug.
And we should fix bugs, not work around them.

CONFIG_DEBUG_STACKOVERFLOW in arch/i386/kernel/irq.c shows the correct 
approach:
- a debug option for not harming performance
- dump_stack() when too much stack is used

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


  parent reply	other threads:[~2005-12-19 18:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-19  0:12 Light-weight dynamically extended stacks Matt Mackall
2005-12-19  8:45 ` Arjan van de Ven
2005-12-19 18:36 ` Adrian Bunk [this message]
2005-12-20  0:27   ` Matt Mackall
2005-12-20 16:43     ` Adrian Bunk
2005-12-20 18:30       ` Matt Mackall
2005-12-20 19:40         ` Patrick McLean
2005-12-21  5:57           ` Valdis.Kletnieks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051219183604.GT23349@stusta.de \
    --to=bunk@stusta.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.