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

Commit 3aa5939d authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo
Browse files

perf record: Make per-cpu mmaps the default.



This affects the -p, -t and -u options that previously defaulted to
per-thread mmaps.

Consequently add an option to select per-thread mmaps to support the old
behaviour.

Note that per-thread can be used with a workload-only (i.e. none of -p,
-t, -u, -a or -C is selected) to get a per-thread mmap with no
inheritance.

Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
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/5286271D.3020808@intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e944d3d7
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -201,11 +201,11 @@ abort events and some memory events in precise mode on modern Intel CPUs.
--transaction::
Record transaction flags for transaction related events.

--force-per-cpu::
Force the use of per-cpu mmaps.  By default, when tasks are specified (i.e. -p,
-t or -u options) per-thread mmaps are created.  This option overrides that and
forces per-cpu mmaps.  A side-effect of that is that inheritance is
automatically enabled.  Add the -i option also to disable inheritance.
--per-thread::
Use per-thread mmaps.  By default per-cpu mmaps are created.  This option
overrides that and uses per-thread mmaps.  A side-effect of that is that
inheritance is automatically disabled.  --per-thread is ignored with a warning
if combined with -a or -C options.

SEE ALSO
--------
+3 −2
Original line number Diff line number Diff line
@@ -800,6 +800,7 @@ static struct perf_record record = {
		.freq		     = 4000,
		.target		     = {
			.uses_mmap   = true,
			.default_per_cpu = true,
		},
	},
};
@@ -888,8 +889,8 @@ const struct option record_options[] = {
		    "sample by weight (on special events only)"),
	OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
		    "sample transaction flags (special events only)"),
	OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu,
		    "force the use of per-cpu mmaps"),
	OPT_BOOLEAN(0, "per-thread", &record.opts.target.per_thread,
		    "use per-thread mmaps"),
	OPT_END()
};

+1 −1
Original line number Diff line number Diff line
@@ -3,5 +3,5 @@ command = record
args    = -i kill >/dev/null 2>&1

[event:base-record]
sample_type=259
sample_type=263
inherit=0
+4 −2
Original line number Diff line number Diff line
@@ -819,8 +819,10 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
	if (evlist->threads == NULL)
		return -1;

	if (target->force_per_cpu)
		evlist->cpus = cpu_map__new(target->cpu_list);
	if (target->default_per_cpu)
		evlist->cpus = target->per_thread ?
					cpu_map__dummy_new() :
					cpu_map__new(target->cpu_list);
	else if (target__has_task(target))
		evlist->cpus = cpu_map__dummy_new();
	else if (!target__has_cpu(target) && !target->uses_mmap)
+3 −2
Original line number Diff line number Diff line
@@ -574,6 +574,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
	struct perf_evsel *leader = evsel->leader;
	struct perf_event_attr *attr = &evsel->attr;
	int track = !evsel->idx; /* only the first counter needs these */
	bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread;

	attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
	attr->inherit	    = !opts->no_inherit;
@@ -647,7 +648,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
		}
	}

	if (target__has_cpu(&opts->target) || opts->target.force_per_cpu)
	if (target__has_cpu(&opts->target))
		perf_evsel__set_sample_bit(evsel, CPU);

	if (opts->period)
@@ -655,7 +656,7 @@ void perf_evsel__config(struct perf_evsel *evsel,

	if (!perf_missing_features.sample_id_all &&
	    (opts->sample_time || !opts->no_inherit ||
	     target__has_cpu(&opts->target) || opts->target.force_per_cpu))
	     target__has_cpu(&opts->target) || per_cpu))
		perf_evsel__set_sample_bit(evsel, TIME);

	if (opts->raw_samples) {
Loading