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

Commit f5fc1412 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Add data object to handle perf data file



This patch is adding 'struct perf_data_file' object as a placeholder for
all attributes regarding perf.data file handling. Changing
perf_session__new to take it as an argument.

The rest of the functionality will be added later to keep this change
simple enough, because all the places using perf_session are changed
now.

Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1381847254-28809-2-git-send-email-jolsa@redhat.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 09600e0f
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "util/hist.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/data.h"
#include "arch/common.h"

#include <dlfcn.h>
@@ -199,9 +200,13 @@ static int __cmd_annotate(struct perf_annotate *ann)
	struct perf_session *session;
	struct perf_evsel *pos;
	u64 total_nr_samples;
	struct perf_data_file file = {
		.path  = input_name,
		.mode  = PERF_DATA_MODE_READ,
		.force = ann->force,
	};

	session = perf_session__new(input_name, O_RDONLY,
				    ann->force, false, &ann->tool);
	session = perf_session__new(&file, false, &ann->tool);
	if (session == NULL)
		return -ENOMEM;

+6 −2
Original line number Diff line number Diff line
@@ -221,8 +221,12 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)

static int build_id_cache__fprintf_missing(const char *filename, bool force, FILE *fp)
{
	struct perf_session *session = perf_session__new(filename, O_RDONLY,
							 force, false, NULL);
	struct perf_data_file file = {
		.path  = filename,
		.mode  = PERF_DATA_MODE_READ,
		.force = force,
	};
	struct perf_session *session = perf_session__new(&file, false, NULL);
	if (session == NULL)
		return -1;

+7 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "util/parse-options.h"
#include "util/session.h"
#include "util/symbol.h"
#include "util/data.h"

static int sysfs__fprintf_build_id(FILE *fp)
{
@@ -52,6 +53,11 @@ static bool dso__skip_buildid(struct dso *dso, int with_hits)
static int perf_session__list_build_ids(bool force, bool with_hits)
{
	struct perf_session *session;
	struct perf_data_file file = {
		.path  = input_name,
		.mode  = PERF_DATA_MODE_READ,
		.force = force,
	};

	symbol__elf_init();
	/*
@@ -60,8 +66,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
	if (filename__fprintf_build_id(input_name, stdout))
		goto out;

	session = perf_session__new(input_name, O_RDONLY, force, false,
				    &build_id__mark_dso_hit_ops);
	session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops);
	if (session == NULL)
		return -1;
	/*
+12 −7
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
#include "util/data.h"

#include <stdlib.h>
#include <math.h>
@@ -42,7 +43,7 @@ struct diff_hpp_fmt {

struct data__file {
	struct perf_session	*session;
	const char		*file;
	struct perf_data_file	file;
	int			 idx;
	struct hists		*hists;
	struct diff_hpp_fmt	 fmt[PERF_HPP_DIFF__MAX_INDEX];
@@ -601,7 +602,7 @@ static void data__fprintf(void)

	data__for_each_file(i, d)
		fprintf(stdout, "#  [%d] %s %s\n",
			d->idx, d->file,
			d->idx, d->file.path,
			!d->idx ? "(Baseline)" : "");

	fprintf(stdout, "#\n");
@@ -663,17 +664,16 @@ static int __cmd_diff(void)
	int ret = -EINVAL, i;

	data__for_each_file(i, d) {
		d->session = perf_session__new(d->file, O_RDONLY, force,
					       false, &tool);
		d->session = perf_session__new(&d->file, false, &tool);
		if (!d->session) {
			pr_err("Failed to open %s\n", d->file);
			pr_err("Failed to open %s\n", d->file.path);
			ret = -ENOMEM;
			goto out_delete;
		}

		ret = perf_session__process_events(d->session, &tool);
		if (ret) {
			pr_err("Failed to process %s\n", d->file);
			pr_err("Failed to process %s\n", d->file.path);
			goto out_delete;
		}

@@ -1016,7 +1016,12 @@ static int data_init(int argc, const char **argv)
		return -ENOMEM;

	data__for_each_file(i, d) {
		d->file = use_default ? defaults[i] : argv[i];
		struct perf_data_file *file = &d->file;

		file->path  = use_default ? defaults[i] : argv[i];
		file->mode  = PERF_DATA_MODE_READ,
		file->force = force,

		d->idx  = i;
	}

+6 −1
Original line number Diff line number Diff line
@@ -14,13 +14,18 @@
#include "util/parse-events.h"
#include "util/parse-options.h"
#include "util/session.h"
#include "util/data.h"

static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
{
	struct perf_session *session;
	struct perf_evsel *pos;
	struct perf_data_file file = {
		.path = file_name,
		.mode = PERF_DATA_MODE_READ,
	};

	session = perf_session__new(file_name, O_RDONLY, 0, false, NULL);
	session = perf_session__new(&file, 0, NULL);
	if (session == NULL)
		return -ENOMEM;

Loading