aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2015-12-10 21:56:54 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-12-11 06:34:49 -0500
commit151ee834cc946fa159ee406c62b4d5ce1ebd7115 (patch)
tree6fb57dae8b814f4553b62936eccb3edda8468248
parent64226bcf64629996948dc03c38594f00511bfc2b (diff)
perf top: Access hists->lock only if needed
The perf_top__record_precise_ip() releases and regrabs the he->hists->lock because it can sleep if there's an error. But it should be done conditionally as it slows down the fast path. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1449802616-16170-2-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-top.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 3b0978e5578a..586798acf7db 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -194,21 +194,23 @@ static void perf_top__record_precise_ip(struct perf_top *top,
194 194
195 pthread_mutex_unlock(&notes->lock); 195 pthread_mutex_unlock(&notes->lock);
196 196
197 /* 197 if (unlikely(err)) {
198 * This function is now called with he->hists->lock held. 198 /*
199 * Release it before going to sleep. 199 * This function is now called with he->hists->lock held.
200 */ 200 * Release it before going to sleep.
201 pthread_mutex_unlock(&he->hists->lock); 201 */
202 pthread_mutex_unlock(&he->hists->lock);
203
204 if (err == -ERANGE && !he->ms.map->erange_warned)
205 ui__warn_map_erange(he->ms.map, sym, ip);
206 else if (err == -ENOMEM) {
207 pr_err("Not enough memory for annotating '%s' symbol!\n",
208 sym->name);
209 sleep(1);
210 }
202 211
203 if (err == -ERANGE && !he->ms.map->erange_warned) 212 pthread_mutex_lock(&he->hists->lock);
204 ui__warn_map_erange(he->ms.map, sym, ip);
205 else if (err == -ENOMEM) {
206 pr_err("Not enough memory for annotating '%s' symbol!\n",
207 sym->name);
208 sleep(1);
209 } 213 }
210
211 pthread_mutex_lock(&he->hists->lock);
212} 214}
213 215
214static void perf_top__show_details(struct perf_top *top) 216static void perf_top__show_details(struct perf_top *top)