public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Li Zefan <lizf@cn.fujitsu.com>, Jason Baron <jbaron@redhat.com>
Subject: Re: [PATCH v2] tracing: Protect the buffer from recursion in perf
Date: Tue, 10 Nov 2009 11:27:42 +0100	[thread overview]
Message-ID: <1257848862.4648.33.camel@twins> (raw)
In-Reply-To: <1257477185-7838-1-git-send-email-fweisbec@gmail.com>

On Fri, 2009-11-06 at 04:13 +0100, Frederic Weisbecker wrote:
> While tracing using events with perf, if one enables the
> lockdep:lock_acquire event, it will infect every other perf trace
> events.
> 
> Basically, you can enable whatever set of trace events through perf
> but if this event is part of the set, the only result we can get is a
> long list of lock_acquire events of rcu read lock, and only that.
> 
> This is because of a recursion inside perf.
> 
> 1) When a trace event is triggered, it will fill a per cpu buffer and
>    submit it to perf.
> 2) Perf will commit this event but will also protect some data using
>    rcu_read_lock
> 3) A recursion appears: rcu_read_lock triggers a lock_acquire event that
>    will fill the per cpu event and then submit the buffer to perf.
> 4) Perf detects a recursion and ignore it
> 5) Perf continue its work on the previous event, but its buffer has been
>    overwritten by the lock_acquire event, it has then been turned into
>    a lock_acquire event of rcu read lock
> 
> Such scenario also happens with lock_release with rcu_read_unlock().
> 
> We could turn the rcu_read_lock() into __rcu_read_lock() to drop the
> lock debugging from perf fast path, but that would make us lose
> the rcu debugging and that doesn't prevent from other possible kind of
> recursion from perf in the future.
> 
> This patch adds a recursion protection based on a counter on the perf
> trace per cpu buffers to solve the problem.

There already is recursion protection in
kernel/perf_event.c:perf_swevent_recursion_context() and thereabouts.
Could you not fix this by widening its scope?

  parent reply	other threads:[~2009-11-10 10:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-04 22:23 [PATCH] tracing: Protect the buffer from recursion in perf Frederic Weisbecker
2009-11-05  3:06 ` Masami Hiramatsu
2009-11-06  3:13   ` [PATCH v2] " Frederic Weisbecker
2009-11-08  9:40     ` [tip:perf/probes] tracing, perf_events: " tip-bot for Frederic Weisbecker
2009-11-10 10:27     ` Peter Zijlstra [this message]
2009-11-10 10:40       ` [PATCH v2] tracing: " Frederic Weisbecker

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=1257848862.4648.33.camel@twins \
    --to=peterz@infradead.org \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=fweisbec@gmail.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.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