mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gilboa Davara <gilboad@gmail.com>
To: Satyam Sharma <satyam.sharma@gmail.com>
Cc: linux-kernel@vger.kernel.org, Eric Sandeen <sandeen@sandeen.net>
Subject: Re: [Minor patch] Reduce __print_symbol/sprint_symbol stack usage.
Date: Sat, 15 Sep 2007 18:15:29 +0300	[thread overview]
Message-ID: <1189869329.18191.77.camel@gilboa-home-dev.localdomain> (raw)
In-Reply-To: <a781481a0709150602v6be754caw4fbe0f76c8db5beb@mail.gmail.com>

On Sat, 2007-09-15 at 18:32 +0530, Satyam Sharma wrote:
> Hi,
> 
> 
> On 9/15/07, Gilboa Davara <gilboad@gmail.com> wrote:
> > Hello all,
> >
> > In a small exchange in fedora-kernel-list [1] Eric Sandeen has pointed
> > out a possible stack overflow... when CONFIG_DEBUG_STACKOVERFLOW is
> > enabled. (Though not limited to it)
> 
> Yeah, I have experienced this phenomenon/problem myself.
> 
> 
> > Code path is simple: do_IRQ detects a a near stack overflow condition
> > and calls show_trace_log_lvl which, down the line uses __print_symbol
> > and sprint_symbol to print the call stack.
> > However,  both __print_symbol + sprint_symbol are eating no-less then
> > 128+223 bytes on static char arrays, which, given the fact that this
> > code path is actually generated by low stack warning (< 512 bytes),
> > might turn a minor (?) problem (low stack) into a full blown crash.
> 
> __print_symbol() and sprint_symbol() are called multiple times during
> oopsen / panics. I think those buffers were static char arrays for a good
> reason ...

OK. Point taken.
I pull this patch pending some additional thinking.

> > The patch itself is fairly simple and non-intrusive. [2]
> > Both functions allocate memory for their buffers - falling back to
> > minimal address display if memory allocation fails.
> >
> > P.S. Can anyone please point me to the maintainer of kernel/syms? (I
> > rather not spam world + dog for such a minor patch)
> 
> Anything that touches the panic codepath is important, not minor at all.

Bad wording on my part.
By minor I meant, changes a single source file, doesn't change
interfaces, doesn't change code behavior beyond it's local scope.

> > [2]. In theory, there's a second option: pre-allocating memory on a
> > per_cpu basis, however:
> > A. dump_trace/stack are usually called when something bad has happened -
> > reducing the need for performance optimizations.
> 
> That's not a performance optimization -- avoiding repeated kmalloc()'s in the
> panic codepath sounds like a *requirement* to me.

ACK.

Though in my defense, solution [2] requires a massive surgery that would
have made this patch far more intrusive.

> 
> 
> > B. per_cpu allocation will also require local_irq_disable/enable as both
> > functions are being called from multiple contexts. Too much hassle.
> 
> I think not bothering about any locking in these codepaths may not be an
> entirely unreasonable thing to do (sorry about the triple negation in the
> sentence). What I mean is that there are places in these codepaths where
> we already don't bother with locking ...
> 
> Overall I don't much like introducing kmalloc(GFP_ATOMIC) in these codepaths
> and would ask you guys to consider some other pre-allocation (i.e. static
> allocation not on stack but in .data) alternative instead ...
> 

> Satyam

No locking what-so-ever is a bad idea. dump_stack/trace are being called
by non-fatal sources (sleep while atomic; stack-check; debugging) that
may produce problematic results if a static/shared buffer is being used
with no locks.
We can agree that using in-stack char buffer is very problematic -
especially given the fact that 4K is becoming the default build option.

I'll try and create an option 2 (static allocation, minimal locking)
patch and post ASAP.
Hopefully it'll fare better. (While keeping the current interface intact
and reducing the damage/noise)

- Gilboa


  reply	other threads:[~2007-09-15 15:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-15 11:35 Gilboa Davara
2007-09-15 13:02 ` Satyam Sharma
2007-09-15 15:15   ` Gilboa Davara [this message]
2007-09-15 18:08     ` [PATCH] " Gilboa Davara
2007-09-19  1:00       ` Satyam Sharma
2007-09-19 14:25         ` Paulo Marques
2007-09-21 12:45           ` Gilboa Davara
2007-09-21 14:21             ` Paulo Marques
2007-09-21 14:57               ` Gilboa Davara
2007-09-21 14:56           ` Steven Rostedt
2007-09-21 15:47             ` Paulo Marques
2007-09-21 12:31         ` Gilboa Davara
2007-09-21 14:28       ` [PATCH] Reduce __print_symbol/sprint_symbol stack usage. (v3) Gilboa Davara
2007-09-21 16:02         ` Paulo Marques
2007-09-21 16:19           ` Gilboa Davara
2007-09-21 14:47 ` [Minor patch] Reduce __print_symbol/sprint_symbol stack usage Steven Rostedt
2007-09-21 14:53   ` Gilboa Davara

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=1189869329.18191.77.camel@gilboa-home-dev.localdomain \
    --to=gilboad@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    --cc=satyam.sharma@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®