public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Kees Cook <keescook@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	syzbot <syzbot+352bd10e338d9a90e5e0@syzkaller.appspotmail.com>,
	Abderrahmane Benbachir <abderrahmane.benbachir@polymtl.ca>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: WARNING in event_function_local
Date: Wed, 13 Feb 2019 11:16:44 +0100	[thread overview]
Message-ID: <20190213101644.GN32534@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190213095726.GM32534@hirez.programming.kicks-ass.net>

On Wed, Feb 13, 2019 at 10:57:26AM +0100, Peter Zijlstra wrote:
> On Wed, Feb 13, 2019 at 10:51:58AM +0100, Peter Zijlstra wrote:
> > On Tue, Feb 12, 2019 at 07:40:12PM -0800, Kees Cook wrote:
> > 
> > > > > Is this maybe just an unlucky condition with the event loop running in
> > > > > an IRQ? Should the WARN be expected, or is running under an IRQ
> > > > > unexpected?
> > > 
> > > Is perf expected to fire during an IRQ? The task == current test seems
> > > suspicious if so...
> > 
> > So the only possible callchain here is:
> > 
> >   <PMI>
> >     ...
> >       perf_event_disable_inatomic()
> >         irq_work_queue()
> > 
> >   <irq_work-IPI>
> >     perf_pending_event()
> >       perf_event_disable_local()
> >         event_function_local()
> > 
> > 
> > The assertion states that:
> > 
> >   if the event is a task event; and the context is active, it _must_ be
> >   the same task.
> > 
> > Because: if the PMI happens during ctxsw (which has IRQs disabled), the
> > IPI will not happen until after the ctxsw, at which point we'll also
> > have switched out the perf context of that task -- IOW the context
> > should be inactive.
> > 
> > 
> > Anyway, it looks like a virt issue; I'll start caring once you can
> > reproduce on real hardware.
> 
> Hurm.. I might have spoken too soon. I still don't give a crap about
> virt, but I think I might see an actual problem.
> 
> The moment we re-enable IRQs after ctxsw, the task can already be
> running on another CPU, and _that_ would trigger failure here.
> 
> Let me think a little about that.

Humm, but in that case:

  context_switch()
    prepare_task_switch()
      perf_event_task_sched_out()
        __perf_event_task_sched_out()
	  perf_event_context_sched_out()
	    task_ctx_sched_out()
	      ctx_sched_out()
	        group_sched_out()
		  event_sched_out()
		    if (event->pending_disable)

Would have already cleared the pending_disable state, so the IPI would
not have ran perf_event_disable_local() in the first place.



      reply	other threads:[~2019-02-13 10:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-27 19:58 WARNING in event_function_local syzbot
2018-05-10  5:18 ` Dmitry Vyukov
2019-02-13  1:27   ` Kees Cook
2019-02-13  2:14     ` Steven Rostedt
2019-02-13  3:40       ` Kees Cook
2019-02-13  3:46         ` Steven Rostedt
2019-02-13  9:51         ` Peter Zijlstra
2019-02-13  9:57           ` Peter Zijlstra
2019-02-13 10:16             ` Peter Zijlstra [this message]

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=20190213101644.GN32534@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=abderrahmane.benbachir@polymtl.ca \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dvyukov@google.com \
    --cc=jolsa@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=syzbot+352bd10e338d9a90e5e0@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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