From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org,
eranian@google.com, paulus@samba.org, hpa@zytor.com,
mingo@kernel.org, a.p.zijlstra@chello.nl, namhyung.kim@lge.com,
namhyung@kernel.org, jolsa@redhat.com, dsahern@gmail.com,
tglx@linutronix.de
Subject: [tip:perf/core] perf hists: Move locking to its call-sites
Date: Fri, 31 May 2013 04:38:20 -0700 [thread overview]
Message-ID: <tip-27a0dcb7adb52473dd98d285a46b764b9219d303@git.kernel.org> (raw)
In-Reply-To: <1368497347-9628-5-git-send-email-namhyung@kernel.org>
Commit-ID: 27a0dcb7adb52473dd98d285a46b764b9219d303
Gitweb: http://git.kernel.org/tip/27a0dcb7adb52473dd98d285a46b764b9219d303
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Tue, 14 May 2013 11:09:02 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2013 16:24:00 +0300
perf hists: Move locking to its call-sites
It's a preparation patch to eliminate unneeded locking in the perf
report path.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1368497347-9628-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-report.c | 26 ++++++++++++++------------
tools/perf/builtin-top.c | 3 +++
tools/perf/util/hist.c | 6 +-----
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d45bf9b..63febd2 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -297,6 +297,7 @@ static int process_sample_event(struct perf_tool *tool,
{
struct perf_report *rep = container_of(tool, struct perf_report, tool);
struct addr_location al;
+ int ret;
if (perf_event__preprocess_sample(event, machine, &al, sample,
rep->annotate_init) < 0) {
@@ -311,28 +312,29 @@ static int process_sample_event(struct perf_tool *tool,
if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
return 0;
+ pthread_mutex_lock(&evsel->hists.lock);
+
if (sort__mode == SORT_MODE__BRANCH) {
- if (perf_report__add_branch_hist_entry(tool, &al, sample,
- evsel, machine)) {
+ ret = perf_report__add_branch_hist_entry(tool, &al, sample,
+ evsel, machine);
+ if (ret < 0)
pr_debug("problem adding lbr entry, skipping event\n");
- return -1;
- }
} else if (rep->mem_mode == 1) {
- if (perf_report__add_mem_hist_entry(tool, &al, sample,
- evsel, machine, event)) {
+ ret = perf_report__add_mem_hist_entry(tool, &al, sample,
+ evsel, machine, event);
+ if (ret < 0)
pr_debug("problem adding mem entry, skipping event\n");
- return -1;
- }
} else {
if (al.map != NULL)
al.map->dso->hit = 1;
- if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) {
+ ret = perf_evsel__add_hist_entry(evsel, &al, sample, machine);
+ if (ret < 0)
pr_debug("problem incrementing symbol period, skipping event\n");
- return -1;
- }
}
- return 0;
+ pthread_mutex_unlock(&evsel->hists.lock);
+
+ return ret;
}
static int process_read_event(struct perf_tool *tool,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5cd41ec..c2c9734 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -245,8 +245,11 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
{
struct hist_entry *he;
+ pthread_mutex_lock(&evsel->hists.lock);
he = __hists__add_entry(&evsel->hists, al, NULL, sample->period,
sample->weight);
+ pthread_mutex_unlock(&evsel->hists.lock);
+
if (he == NULL)
return NULL;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 7e0fa62..b11a6cf 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -347,8 +347,6 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
struct hist_entry *he;
int cmp;
- pthread_mutex_lock(&hists->lock);
-
p = &hists->entries_in->rb_node;
while (*p != NULL) {
@@ -394,14 +392,12 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
he = hist_entry__new(entry);
if (!he)
- goto out_unlock;
+ return NULL;
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, hists->entries_in);
out:
hist_entry__add_cpumode_period(he, al->cpumode, period);
-out_unlock:
- pthread_mutex_unlock(&hists->lock);
return he;
}
next prev parent reply other threads:[~2013-05-31 11:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 2:08 [PATCHSET 0/9] perf tools: Assorted fixes and changes on perf top/report Namhyung Kim
2013-05-14 2:08 ` [PATCH 1/9] perf top: Fix -E option behavior Namhyung Kim
2013-05-17 14:21 ` Jiri Olsa
2013-05-31 11:34 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 2/9] perf top: Fix percent output when no samples collected Namhyung Kim
2013-05-17 14:22 ` Jiri Olsa
2013-05-31 11:35 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 3/9] perf top: Get rid of *_threaded() functions Namhyung Kim
2013-05-17 14:28 ` Jiri Olsa
2013-05-31 11:37 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 4/9] perf hists: Move locking to its call-sites Namhyung Kim
2013-05-17 14:39 ` Jiri Olsa
2013-05-31 11:38 ` tip-bot for Namhyung Kim [this message]
2013-05-14 2:09 ` [PATCH 5/9] perf report: Don't be bothered with locking when adding hist entries Namhyung Kim
2013-05-17 14:39 ` Jiri Olsa
2013-05-31 11:39 ` [tip:perf/core] perf report: Don' t bother " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 6/9] perf report: Add --percent-limit option Namhyung Kim
2013-05-31 11:40 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 7/9] perf top: " Namhyung Kim
2013-05-31 11:42 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 8/9] perf report: Add report.percent-limit config variable Namhyung Kim
2013-05-14 11:05 ` Pekka Enberg
2013-05-15 10:08 ` Namhyung Kim
2013-05-16 7:34 ` Pekka Enberg
2013-05-31 11:43 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-05-14 2:09 ` [PATCH 9/9] perf top: Reuse " Namhyung Kim
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=tip-27a0dcb7adb52473dd98d285a46b764b9219d303@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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