Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47260645 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo
Browse files

perf callchain: Make callchain cursors TLS



perf top -G has a race on callchain cursor between main thread and
display thread. Since the callchain cursors are used locally make them
thread-local data would solve the problem.

Signed-off-by: default avatarNamhyung Kim <namhyung.kim@lge.com>
Reported-by: default avatarSunjin Yang <fan4326@gmail.com>
Suggested-by: default avatarArnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sunjin Yang <fan4326@gmail.com>
Link: http://lkml.kernel.org/r/1338443007-24857-1-git-send-email-namhyung.kim@lge.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ea1b3eba
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,

	if (symbol_conf.use_callchain) {
		err = callchain_append(he->callchain,
				       &evsel->hists.callchain_cursor,
				       &callchain_cursor,
				       sample->period);
		if (err)
			return err;
+1 −1
Original line number Diff line number Diff line
@@ -787,7 +787,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
		}

		if (symbol_conf.use_callchain) {
			err = callchain_append(he->callchain, &evsel->hists.callchain_cursor,
			err = callchain_append(he->callchain, &callchain_cursor,
					       sample->period);
			if (err)
				return;
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include "util.h"
#include "callchain.h"

__thread struct callchain_cursor callchain_cursor;

bool ip_callchain__valid(struct ip_callchain *chain,
			 const union perf_event *event)
{
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ struct callchain_cursor {
	struct callchain_cursor_node	*curr;
};

extern __thread struct callchain_cursor callchain_cursor;

static inline void callchain_init(struct callchain_root *root)
{
	INIT_LIST_HEAD(&root->node.siblings);
+4 −3
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ void hist_entry__free(struct hist_entry *he)
 * collapse the histogram
 */

static bool hists__collapse_insert_entry(struct hists *hists,
static bool hists__collapse_insert_entry(struct hists *hists __used,
					 struct rb_root *root,
					 struct hist_entry *he)
{
@@ -397,8 +397,9 @@ static bool hists__collapse_insert_entry(struct hists *hists,
			iter->period += he->period;
			iter->nr_events += he->nr_events;
			if (symbol_conf.use_callchain) {
				callchain_cursor_reset(&hists->callchain_cursor);
				callchain_merge(&hists->callchain_cursor, iter->callchain,
				callchain_cursor_reset(&callchain_cursor);
				callchain_merge(&callchain_cursor,
						iter->callchain,
						he->callchain);
			}
			hist_entry__free(he);
Loading