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: <b05793fb68d8e0c50af9a6c600dc70a7f79fb806.1629490974.git.rickyman7@gmail.com>
Date:   Sat, 21 Aug 2021 11:19:36 +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 30/37] perf record: use evlist__open_custom

This patch replace the custom evlist opening implemented in record__open
with the new standard function evlist__open_custom.
Differently from before this patch, in case of a weak group all fds are
closed and then reopened (instead of just closing failing ones).

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

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index cccc2d0f9977d5b3..dc9a814b2e7906fc 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -882,6 +882,37 @@ static int record__mmap(struct record *rec)
 	return record__mmap_evlist(rec, rec->evlist);
 }
 
+struct record_open_custom_fallback {
+	struct evlist_open_custom_fallback fallback;
+	struct record_opts *opts;
+	bool retry;
+};
+
+static bool record__open_fallback(struct evlist_open_custom_fallback *_fallback,
+				struct evlist *evlist, struct evsel *evsel, int err)
+{
+	char msg[BUFSIZ];
+	struct record_open_custom_fallback *fallback = container_of(_fallback,
+		struct record_open_custom_fallback, fallback);
+
+	if (evsel__fallback(evsel, -err, msg, sizeof(msg))) {
+		if (verbose > 0)
+			ui__warning("%s\n", msg);
+		return true;
+	}
+	if ((err == -EINVAL || err == -EBADF) &&
+		evsel->core.leader != &evsel->core &&
+		evsel->weak_group) {
+		evlist__reset_weak_group(evlist, evsel, true);
+		fallback->retry = true;
+		return false;
+	}
+
+	evsel__open_strerror(evsel, &fallback->opts->target, -err, msg, sizeof(msg));
+	ui__error("%s\n", msg);
+	return false;
+}
+
 static int record__open(struct record *rec)
 {
 	char msg[BUFSIZ];
@@ -890,6 +921,12 @@ static int record__open(struct record *rec)
 	struct perf_session *session = rec->session;
 	struct record_opts *opts = &rec->opts;
 	int rc = 0;
+	struct record_open_custom_fallback cust_fb = {
+		.fallback = {
+			.func = record__open_fallback
+		},
+		.opts = opts
+	};
 
 	/*
 	 * For initial_delay, system wide or a hybrid system, we need to add a
@@ -919,28 +956,12 @@ static int record__open(struct record *rec)
 
 	evlist__config(evlist, opts, &callchain_param);
 
-	evlist__for_each_entry(evlist, pos) {
-try_again:
-		if (evsel__open(pos, pos->core.cpus, pos->core.threads) < 0) {
-			if (evsel__fallback(pos, errno, msg, sizeof(msg))) {
-				if (verbose > 0)
-					ui__warning("%s\n", msg);
-				goto try_again;
-			}
-			if ((errno == EINVAL || errno == EBADF) &&
-			    pos->core.leader != &pos->core &&
-			    pos->weak_group) {
-			        pos = evlist__reset_weak_group(evlist, pos, true);
-				goto try_again;
-			}
-			rc = -errno;
-			evsel__open_strerror(pos, &opts->target, errno, msg, sizeof(msg));
-			ui__error("%s\n", msg);
-			goto out;
-		}
 
-		pos->supported = true;
-	}
+	do {
+		cust_fb.retry = false;
+		rc = evlist__open_custom(evlist, &cust_fb.fallback);
+	} while (cust_fb.retry);
+
 
 	if (symbol_conf.kptr_restrict && !evlist__exclude_kernel(evlist)) {
 		pr_warning(
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ