public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, Borislav Petkov <bp@alien8.de>,
	Andi Kleen <andi@firstfloor.org>,
	lkml@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] x86/traps: Don't for in_interrupt() to return true in IST handlers
Date: Tue, 24 May 2016 10:59:45 +0200	[thread overview]
Message-ID: <20160524085945.GE3192@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <ce1cd1d47b486c142d57a9a8189470a1c3809a9c.1464062136.git.luto@kernel.org>

On Mon, May 23, 2016 at 08:57:05PM -0700, Andy Lutomirski wrote:
> Forcing in_interrupt() to return true if we're not in a bona fide
> interrupt confuses the softirq code.  This fixes warnings like:
> 
> NOHZ: local_softirq_pending 282
> 
> that can happen when running things like selftests/x86.
> 
> Cc: stable@vger.kernel.org
> Fixes: 959274753857 ("x86, traps: Track entry into and exit from IST context")
> Signed-off-by: Andy Lutomirski <luto@kernel.org>

> +/*
> + * We want to cause in_atomic() to return true while in an IST handler
> + * so that attempts to schedule will warn.
> + *
> + * We cannot add use HARDIRQ_OFFSET or otherwise cause in_interrupt() to
> + * return true: the softirq code assumes that in_interrupt() only
> + * returns true if we will soon execute softirqs, and we can't do that
> + * if an IST entry interrupts kernel code with interrupts disabled.
> + *
> + * Using 3 * PREEMPT_OFFSET instead of just PREEMPT_OFFSET is pure
> + * paranoia.
> + */
> +#define IST_OFFSET (3 * PREEMPT_OFFSET)

So this has implications for code like
kernel/events/internal.h:get_recursion_context() and
kernel/trace/trace.c:get_trace_buf().

Which use a sequence of: in_nmi(), in_irq(), in_softirq() to pick 1 out
of 4 possible contexts.

I would really like the Changelog to reflect on this. The current code
will have ISTs land in in_irq(), with this chance, not so much.

Now ISTs as a whole invalidate the whole 'we have only 4 contexts' and
the mapping back to those 4 is going to be somewhat arbitrary I suspect,
but changes like this should be very much aware of these things. And
make an explicit choice.

  reply	other threads:[~2016-05-24  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  3:57 [PATCH] x86/traps: Don't for in_interrupt() to return true in IST handlers Andy Lutomirski
2016-05-24  8:59 ` Peter Zijlstra [this message]
2016-05-24  9:36   ` Borislav Petkov
2016-05-24  9:51     ` Peter Zijlstra
2016-05-24 15:43   ` Andy Lutomirski
2016-05-24 17:09     ` Peter Zijlstra
2016-05-24 18:54       ` Andy Lutomirski

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=20160524085945.GE3192@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andi@firstfloor.org \
    --cc=bp@alien8.de \
    --cc=lkml@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=oleg@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.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