lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180124115143.14322-17-jolsa@kernel.org>
Date:   Wed, 24 Jan 2018 12:51:38 +0100
From:   Jiri Olsa <jolsa@...nel.org>
To:     Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ingo Molnar <mingo@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        David Ahern <dsahern@...il.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Andy Lutomirski <luto@...capital.net>,
        Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: [PATCH 16/21] perf record: Enable delayed user data events

Enabling user data events, when the right option
constellation is detected:

  - user space callchains are enabled
  - kernel space is not ommited (it's the only time
    USER DATA events can be generated)

Adding --no-user-data option to prevent this.

Link: http://lkml.kernel.org/n/tip-x2q1z2v9njw3f0nondg779i5@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 tools/perf/builtin-record.c |  2 ++
 tools/perf/perf.h           |  1 +
 tools/perf/util/evsel.c     | 26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f251e824edac..fa87389ebfac 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1633,6 +1633,8 @@ static struct option __record_options[] = {
 		    "append timestamp to output filename"),
 	OPT_BOOLEAN(0, "timestamp-boundary", &record.timestamp_boundary,
 		    "Record timestamp boundary (time of first/last samples)"),
+	OPT_BOOLEAN(0, "no-user-data", &record.opts.no_user_data,
+		    "disable user data events"),
 	OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str,
 			  &record.switch_output.set, "signal,size,time",
 			  "Switch output when receive SIGUSR2 or cross size,time threshold",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 2357f4ccc9c7..23fb0ffac73c 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -42,6 +42,7 @@ struct record_opts {
 	bool	     no_inherit;
 	bool	     no_inherit_set;
 	bool	     no_samples;
+	bool	     no_user_data;
 	bool	     raw_samples;
 	bool	     sample_address;
 	bool	     sample_phys_addr;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 6f6eab6bc108..1d3c9fb91881 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -51,6 +51,7 @@ static struct {
 	bool lbr_flags;
 	bool write_backward;
 	bool group_read;
+	bool user_data;
 } perf_missing_features;
 
 static clockid_t clockid;
@@ -1079,6 +1080,23 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 	apply_config_terms(evsel, opts, track);
 
 	evsel->ignore_missing_thread = opts->ignore_missing_thread;
+
+	/*
+	 * Enable delayed user data processing,
+	 * if it's allowed and if there's any.
+	 */
+	if (!opts->no_user_data) {
+		bool has_callchain = perf_evsel__is_sample_bit(evsel, CALLCHAIN);
+		bool user_data;
+
+		user_data  = !attr->exclude_kernel;
+		user_data &= (has_callchain && !attr->exclude_callchain_user);
+
+		if (user_data) {
+			attr->user_data = 1;
+			perf_evsel__set_sample_bit(evsel, USER_DATA_ID);
+		}
+	}
 }
 
 static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -1762,6 +1780,10 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 				     PERF_SAMPLE_BRANCH_NO_CYCLES);
 	if (perf_missing_features.group_read && evsel->attr.inherit)
 		evsel->attr.read_format &= ~(PERF_FORMAT_GROUP|PERF_FORMAT_ID);
+	if (perf_missing_features.user_data) {
+		evsel->attr.user_data    = 0;
+		evsel->attr.sample_type &= ~PERF_SAMPLE_USER_DATA_ID;
+	}
 retry_sample_id:
 	if (perf_missing_features.sample_id_all)
 		evsel->attr.sample_id_all = 0;
@@ -1923,6 +1945,10 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 		perf_missing_features.group_read = true;
 		pr_debug2("switching off group read\n");
 		goto fallback_missing_features;
+	} else if (!perf_missing_features.user_data) {
+		perf_missing_features.user_data = true;
+		pr_debug2("switching off user data events\n");
+		goto fallback_missing_features;
 	}
 out_close:
 	do {
-- 
2.13.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ