From: Frederic Weisbecker <fweisbec@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@au1.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"H. Peter Anvin" <hpa@zytor.com>,
James Hogan <james.hogan@imgtec.com>,
"James E.J. Bottomley" <jejb@parisc-linux.org>,
Helge Deller <deller@gmx.de>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC GIT PULL] softirq: Consolidation and stack overrun fix
Date: Fri, 20 Sep 2013 11:26:05 -0500 [thread overview]
Message-ID: <20130920162603.GA30381@localhost.localdomain> (raw)
In-Reply-To: <alpine.DEB.2.02.1309201244080.4089@ionos.tec.linutronix.de>
On Fri, Sep 20, 2013 at 01:03:17PM +0200, Thomas Gleixner wrote:
> On Thu, 19 Sep 2013, Linus Torvalds wrote:
>
> > On Thu, Sep 19, 2013 at 2:51 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > >
> > > It fixes stacks overruns reported by Benjamin Herrenschmidt:
> > > http://lkml.kernel.org/r/1378330796.4321.50.camel%40pasglop
> >
> > So I don't really dislike this patch-series, but isn't "irq_exit()"
> > (which calls the new softirq_on_stack()) already running in the
> > context of the irq stack? And it's run at the very end of the irq
> > processing, so the irq stack should be empty too at that point.
>
> Right, but most of the implementations are braindamaged.
>
> irq_enter();
> handle_irq_on_hardirq_stack();
> irq_exit();
>
> instead of doing:
>
> switch_stack()
> irq_enter()
> handle_irq()
> irq_exit()
> restore_stack()
>
> So in the case of softirq processing (the likely case) we end up doing:
>
> switch_to_hardirq_stack()
> ...
> restore_original_stack()
> switch_to_softirq_stack()
> ...
> restore_original_stack()
>
> Two avoidable stack switch operations for no gain.
>
> > I'm assuming that the problem is that since we're already on the irq
> > stack, if *another* irq comes in, now that *other* irq doesn't get yet
> > another irq stack page. And I'm wondering whether we shouldn't just
> > fix that (hopefully unlikely) case instead? So instead of having a
> > softirq stack, we'd have just an extra irq stack for the case where
> > the original irq stack is already in use.
>
> Why not have a single irq_stack large enough to accomodate interrupt
> handling during softirq processing? We have no interrupt nesting so
> the maximum stack depth necessary is
>
> max(softirq_stack_usage) + max(irq_stack_usage)
>
> Today we allocate THREAD_SIZE_ORDER for the hard and the soft context,
> so allocating 2 * THREAD_SIZE_ORDER should be sufficient.
Looks good to me.
Now just for clarity, what do we then do with inline sofirq executions: on local_bh_enable()
for example, or explicit calls to do_softirq() other than irq exit?
Should we keep the current switch to a different softirq stack? If we have a generic irq stack
(used for both hard and soft) that is big enough, perhaps we can also switch to this
generic irq stack for inline softirqs executions? After all there is no much point in keeping
a separate stack for that: this result in cache misses if the inline softirq is interrupted by
a hardirq, also inlined softirqs can't happen in hardirq, so there should be no much risk of overruns.
Or am I missing other things?
>
> Thanks,
>
> tglx
next prev parent reply other threads:[~2013-09-20 16:32 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 19:51 [RFC GIT PULL] softirq: Consolidation and stack overrun fix Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 1/3] irq: Consolidate do_softirq() arch overriden implementations Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 2/3] irq: Execute softirq on its own stack on irq exit Frederic Weisbecker
2013-09-19 19:51 ` [PATCH 3/3] irq: Comment on the use of inline stack for ksoftirqd Frederic Weisbecker
2013-09-20 0:02 ` [RFC GIT PULL] softirq: Consolidation and stack overrun fix Linus Torvalds
2013-09-20 1:53 ` Benjamin Herrenschmidt
2013-09-20 11:03 ` Thomas Gleixner
2013-09-20 11:11 ` Peter Zijlstra
2013-09-21 0:55 ` Benjamin Herrenschmidt
2013-09-20 16:26 ` Frederic Weisbecker [this message]
2013-09-20 17:30 ` Thomas Gleixner
2013-09-20 18:37 ` Frederic Weisbecker
2013-09-20 22:14 ` Linus Torvalds
2013-09-21 7:47 ` Ingo Molnar
2013-09-21 18:58 ` Frederic Weisbecker
2013-09-21 21:45 ` Benjamin Herrenschmidt
2013-09-21 23:27 ` Frederic Weisbecker
2013-09-22 2:01 ` H. Peter Anvin
2013-09-22 4:39 ` Benjamin Herrenschmidt
2013-09-22 4:41 ` Benjamin Herrenschmidt
2013-09-22 16:24 ` Peter Zijlstra
2013-09-22 17:47 ` H. Peter Anvin
2013-09-22 22:00 ` Benjamin Herrenschmidt
2013-09-22 21:56 ` Benjamin Herrenschmidt
2013-09-22 22:22 ` Linus Torvalds
2013-09-22 22:38 ` Benjamin Herrenschmidt
2013-09-23 4:35 ` [PATCH] powerpc/irq: Run softirqs off the top of the irq stack Benjamin Herrenschmidt
2013-09-23 7:56 ` Stephen Rothwell
2013-09-23 10:13 ` Benjamin Herrenschmidt
2013-09-23 16:47 ` Linus Torvalds
2013-09-23 20:51 ` Benjamin Herrenschmidt
2013-09-24 5:42 ` [PATCH v2] " Benjamin Herrenschmidt
2013-09-23 17:59 ` [RFC GIT PULL] softirq: Consolidation and stack overrun fix Chris Metcalf
2013-09-23 20:57 ` Benjamin Herrenschmidt
2013-09-24 19:27 ` Chris Metcalf
2013-09-24 20:58 ` Benjamin Herrenschmidt
2013-09-24 0:10 ` Benjamin Herrenschmidt
2013-09-24 1:19 ` Linus Torvalds
2013-09-24 1:52 ` Benjamin Herrenschmidt
2013-09-24 8:04 ` Peter Zijlstra
2013-09-24 8:16 ` Benjamin Herrenschmidt
2013-09-24 8:21 ` Peter Zijlstra
2013-09-24 9:31 ` Benjamin Herrenschmidt
2013-09-23 4:40 ` Benjamin Herrenschmidt
2013-09-23 5:01 ` David Miller
2013-09-24 2:44 ` Frederic Weisbecker
2013-09-24 4:42 ` Benjamin Herrenschmidt
2013-09-24 13:56 ` Frederic Weisbecker
2013-09-24 20:55 ` Benjamin Herrenschmidt
2013-09-25 8:46 ` Frederic Weisbecker
2013-09-21 0:52 ` Benjamin Herrenschmidt
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=20130920162603.GA30381@localhost.localdomain \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=james.hogan@imgtec.com \
--cc=jejb@parisc-linux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@au1.ibm.com \
--cc=peterz@infradead.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).