From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>, Jiri Olsa <jolsa@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 1/3] perf: Rollback callchain buffer refcount under the callchain mutex
Date: Fri, 2 Aug 2013 18:29:54 +0200 [thread overview]
Message-ID: <1375460996-16329-2-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1375460996-16329-1-git-send-email-fweisbec@gmail.com>
When we fail to allocate the callchain buffers, we rollback the refcount
we did and return from get_callchain_buffers().
However we take the refcount and allocate under the callchain lock
but the rollback is done outside the lock.
As a result, while we rollback, some concurrent callchain user may
call get_callchain_buffers(), see the non-zero refcount and give up
because the buffers are NULL without itself retrying the allocation.
The consequences aren't that bad but that behaviour looks weird enough and
it's better to give their chances to the following callchain users where
we failed.
Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
---
kernel/events/callchain.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 76a8bc5..97b67df 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -116,10 +116,11 @@ int get_callchain_buffers(void)
err = alloc_callchain_buffers();
exit:
- mutex_unlock(&callchain_mutex);
if (err)
atomic_dec(&nr_callchain_events);
+ mutex_unlock(&callchain_mutex);
+
return err;
}
--
1.7.5.4
next prev parent reply other threads:[~2013-08-02 16:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 16:29 [PATCH 0/3] perf: Fixes on event accounting Frederic Weisbecker
2013-08-02 16:29 ` Frederic Weisbecker [this message]
2013-08-09 10:28 ` [PATCH 1/3] perf: Rollback callchain buffer refcount under the callchain mutex Jiri Olsa
2013-08-16 18:47 ` [tip:perf/core] perf: Roll back " tip-bot for Frederic Weisbecker
2013-08-02 16:29 ` [PATCH 2/3] perf: Account freq events globally Frederic Weisbecker
2013-08-09 10:33 ` Jiri Olsa
2013-08-16 18:47 ` [tip:perf/core] " tip-bot for Frederic Weisbecker
2013-08-02 16:29 ` [PATCH 3/3] nohz: Include local CPU in full dynticks global kick Frederic Weisbecker
2013-08-16 18:46 ` [tip:timers/nohz] " tip-bot for 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=1375460996-16329-2-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
Powered by JetHome