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: <f73e485eb0d29539722da396555d9fcbd0267642.1629490974.git.rickyman7@gmail.com>
Date:   Sat, 21 Aug 2021 11:19:40 +0200
From:   Riccardo Mancini <rickyman7@...il.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Ian Rogers <irogers@...gle.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org,
        Riccardo Mancini <rickyman7@...il.com>
Subject: [RFC PATCH v1 34/37] perf record: apply multithreading in init and fini phases

This patch grows the multithreaded portion of perf-record, marked by the
perf_set_multithreaded and perf_set_singlethreaded functions to the whole
init and fini part of __cmd_record.
By doing so, perf-record can take advantage of the parallelized evlist
operations (open, enable, disable, close).

This patch also needs to handle the case in which evlist and synthesis
multithreading are not enabled at the same time. Therefore, in
record__synthesize multithreading is enabled/disabled and then
disabled/renabled if needed.

Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
 tools/perf/builtin-record.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e2d2445e05d7c07a..db9ec08db672f994 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1411,6 +1411,7 @@ static int record__synthesize(struct record *rec, bool tail)
 	struct perf_tool *tool = &rec->tool;
 	int err = 0;
 	event_op f = process_synthesized_event;
+	bool perf_was_singlethreaded = perf_singlethreaded;
 
 	if (rec->opts.tail_synthesize != tail)
 		return 0;
@@ -1499,12 +1500,16 @@ static int record__synthesize(struct record *rec, bool tail)
 	if (rec->opts.multithreaded_synthesis) {
 		perf_set_multithreaded();
 		f = process_locked_synthesized_event;
+	} else {
+		perf_set_singlethreaded();
 	}
 
 	err = __machine__synthesize_threads(machine, tool, &opts->target, rec->evlist->core.threads,
 					    f, opts->sample_address);
 
-	if (rec->opts.multithreaded_synthesis)
+	if (!perf_was_singlethreaded && perf_singlethreaded)
+		perf_set_multithreaded();
+	if (perf_was_singlethreaded && !perf_singlethreaded)
 		perf_set_singlethreaded();
 
 out:
@@ -1735,6 +1740,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 
 	record__uniquify_name(rec);
 
+	if (rec->opts.multithreaded_evlist)
+		perf_set_multithreaded();
+
 	if (record__open(rec) != 0) {
 		err = -1;
 		goto out_child;
@@ -1877,6 +1885,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 		}
 	}
 
+	// disable locks in the main thread since there is no multithreading
+	if (rec->opts.multithreaded_evlist)
+		perf_set_singlethreaded();
+
 	trigger_ready(&auxtrace_snapshot_trigger);
 	trigger_ready(&switch_output_trigger);
 	perf_hooks__invoke_record_start();
@@ -1998,6 +2010,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 		}
 	}
 
+	// reenable multithreading for evlist
+	if (rec->opts.multithreaded_evlist)
+		perf_set_multithreaded();
+
 	trigger_off(&auxtrace_snapshot_trigger);
 	trigger_off(&switch_output_trigger);
 
@@ -2099,6 +2115,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 
 	if (!opts->no_bpf_event)
 		evlist__stop_sb_thread(rec->sb_evlist);
+
+	// disable multithreaded mode on exit
+	if (rec->opts.multithreaded_evlist)
+		perf_set_singlethreaded();
 	return status;
 }
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ