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

perf hists: Consolidate __hists__add_*entry()



The __hists__add_{branch,mem}_entry() does almost the same thing that
__hists__add_entry() does.  Consolidate them into one.

Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@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: Rodrigo Campos <rodrigo@sdfg.com.ar>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1383202576-28141-2-git-send-email-namhyung@kernel.org


[ Fixup clash with new COMM infrastructure ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 87968f94
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
		return 0;
	}

	he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1, 0);
	he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0);
	if (he == NULL)
		return -ENOMEM;

+2 −1
Original line number Diff line number Diff line
@@ -307,7 +307,8 @@ static int hists__add_entry(struct hists *hists,
			    struct addr_location *al, u64 period,
			    u64 weight, u64 transaction)
{
	if (__hists__add_entry(hists, al, NULL, period, weight, transaction) != NULL)
	if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
			       transaction) != NULL)
		return 0;
	return -ENOMEM;
}
+11 −5
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool,
	 * and this is indirectly achieved by passing period=weight here
	 * and the he_stat__add_period() function.
	 */
	he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost);
	he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi,
				cost, cost, 0);
	if (!he)
		return -ENOMEM;

@@ -200,12 +201,16 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,

		err = -ENOMEM;

		/* overwrite the 'al' to branch-to info */
		al->map = bi[i].to.map;
		al->sym = bi[i].to.sym;
		al->addr = bi[i].to.addr;
		/*
		 * The report shows the percentage of total branches captured
		 * and not events sampled. Thus we use a pseudo period of 1.
		 */
		he = __hists__add_branch_entry(&evsel->hists, al, parent,
				&bi[i], 1, 1);
		he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
					1, 1, 0);
		if (he) {
			struct annotation *notes;
			bx = he->branch_info;
@@ -266,8 +271,9 @@ static int perf_evsel__add_hist_entry(struct perf_tool *tool,
			return err;
	}

	he = __hists__add_entry(&evsel->hists, al, parent, sample->period,
				sample->weight, sample->transaction);
	he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL,
				sample->period, sample->weight,
				sample->transaction);
	if (he == NULL)
		return -ENOMEM;

+3 −2
Original line number Diff line number Diff line
@@ -246,8 +246,9 @@ 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, sample->transaction);
	he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
				sample->period, sample->weight,
				sample->transaction);
	pthread_mutex_unlock(&evsel->hists.lock);
	if (he == NULL)
		return NULL;
+3 −3
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
				goto out;

			he = __hists__add_entry(&evsel->hists, &al, NULL,
						1, 1, 0);
						NULL, NULL, 1, 1, 0);
			if (he == NULL)
				goto out;

@@ -245,8 +245,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
							  &sample) < 0)
				goto out;

			he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1,
						0);
			he = __hists__add_entry(&evsel->hists, &al, NULL,
						NULL, NULL, 1, 1, 0);
			if (he == NULL)
				goto out;

Loading