aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-05-13 22:09:02 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-05-28 09:24:00 -0400
commit27a0dcb7adb52473dd98d285a46b764b9219d303 (patch)
tree52deb89bf5ef67e3749b2e2a026837a76f93d3f2 /tools/perf
parent3a5714f8b58913ded4d9e90abdd30e7e5993f863 (diff)
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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-report.c26
-rw-r--r--tools/perf/builtin-top.c3
-rw-r--r--tools/perf/util/hist.c6
3 files changed, 18 insertions, 17 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d45bf9b0361d..63febd24e912 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,
297{ 297{
298 struct perf_report *rep = container_of(tool, struct perf_report, tool); 298 struct perf_report *rep = container_of(tool, struct perf_report, tool);
299 struct addr_location al; 299 struct addr_location al;
300 int ret;
300 301
301 if (perf_event__preprocess_sample(event, machine, &al, sample, 302 if (perf_event__preprocess_sample(event, machine, &al, sample,
302 rep->annotate_init) < 0) { 303 rep->annotate_init) < 0) {
@@ -311,28 +312,29 @@ static int process_sample_event(struct perf_tool *tool,
311 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) 312 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
312 return 0; 313 return 0;
313 314
315 pthread_mutex_lock(&evsel->hists.lock);
316
314 if (sort__mode == SORT_MODE__BRANCH) { 317 if (sort__mode == SORT_MODE__BRANCH) {
315 if (perf_report__add_branch_hist_entry(tool, &al, sample, 318 ret = perf_report__add_branch_hist_entry(tool, &al, sample,
316 evsel, machine)) { 319 evsel, machine);
320 if (ret < 0)
317 pr_debug("problem adding lbr entry, skipping event\n"); 321 pr_debug("problem adding lbr entry, skipping event\n");
318 return -1;
319 }
320 } else if (rep->mem_mode == 1) { 322 } else if (rep->mem_mode == 1) {
321 if (perf_report__add_mem_hist_entry(tool, &al, sample, 323 ret = perf_report__add_mem_hist_entry(tool, &al, sample,
322 evsel, machine, event)) { 324 evsel, machine, event);
325 if (ret < 0)
323 pr_debug("problem adding mem entry, skipping event\n"); 326 pr_debug("problem adding mem entry, skipping event\n");
324 return -1;
325 }
326 } else { 327 } else {
327 if (al.map != NULL) 328 if (al.map != NULL)
328 al.map->dso->hit = 1; 329 al.map->dso->hit = 1;
329 330
330 if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) { 331 ret = perf_evsel__add_hist_entry(evsel, &al, sample, machine);
332 if (ret < 0)
331 pr_debug("problem incrementing symbol period, skipping event\n"); 333 pr_debug("problem incrementing symbol period, skipping event\n");
332 return -1;
333 }
334 } 334 }
335 return 0; 335 pthread_mutex_unlock(&evsel->hists.lock);
336
337 return ret;
336} 338}
337 339
338static int process_read_event(struct perf_tool *tool, 340static int process_read_event(struct perf_tool *tool,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5cd41ec43ce1..c2c973476479 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,
245{ 245{
246 struct hist_entry *he; 246 struct hist_entry *he;
247 247
248 pthread_mutex_lock(&evsel->hists.lock);
248 he = __hists__add_entry(&evsel->hists, al, NULL, sample->period, 249 he = __hists__add_entry(&evsel->hists, al, NULL, sample->period,
249 sample->weight); 250 sample->weight);
251 pthread_mutex_unlock(&evsel->hists.lock);
252
250 if (he == NULL) 253 if (he == NULL)
251 return NULL; 254 return NULL;
252 255
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 7e0fa628e9ab..b11a6cfdb414 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,
347 struct hist_entry *he; 347 struct hist_entry *he;
348 int cmp; 348 int cmp;
349 349
350 pthread_mutex_lock(&hists->lock);
351
352 p = &hists->entries_in->rb_node; 350 p = &hists->entries_in->rb_node;
353 351
354 while (*p != NULL) { 352 while (*p != NULL) {
@@ -394,14 +392,12 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
394 392
395 he = hist_entry__new(entry); 393 he = hist_entry__new(entry);
396 if (!he) 394 if (!he)
397 goto out_unlock; 395 return NULL;
398 396
399 rb_link_node(&he->rb_node_in, parent, p); 397 rb_link_node(&he->rb_node_in, parent, p);
400 rb_insert_color(&he->rb_node_in, hists->entries_in); 398 rb_insert_color(&he->rb_node_in, hists->entries_in);
401out: 399out:
402 hist_entry__add_cpumode_period(he, al->cpumode, period); 400 hist_entry__add_cpumode_period(he, al->cpumode, period);
403out_unlock:
404 pthread_mutex_unlock(&hists->lock);
405 return he; 401 return he;
406} 402}
407 403