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]
Date:	Wed, 1 Jun 2016 23:34:49 -0700
From:	tip-bot for Masami Hiramatsu <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	mhiramat@...nel.org, linux-kernel@...r.kernel.org, hpa@...or.com,
	namhyung@...nel.org, ananth@...ux.vnet.ibm.com,
	hemant@...ux.vnet.ibm.com, peterz@...radead.org,
	brendan.d.gregg@...il.com, acme@...hat.com, mingo@...nel.org,
	tglx@...utronix.de
Subject: [tip:perf/core] perf symbols: Cleanup the code flow of
 dso__find_kallsyms

Commit-ID:  4e4b6c0668dcd907a36d281802beafa96c916548
Gitweb:     http://git.kernel.org/tip/4e4b6c0668dcd907a36d281802beafa96c916548
Author:     Masami Hiramatsu <mhiramat@...nel.org>
AuthorDate: Sun, 29 May 2016 00:15:28 +0900
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 30 May 2016 13:15:02 -0300

perf symbols: Cleanup the code flow of dso__find_kallsyms

Cleanup the code flow of dso__find_kallsyms() to remove redundant
checking code and add some comment for readability.

Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
Acked-by: Namhyung Kim <namhyung@...nel.org>
Cc: Ananth N Mavinakayanahalli <ananth@...ux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@...il.com>
Cc: Hemant Kumar <hemant@...ux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20160528151522.16098.43446.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/symbol.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a469346..1df6092 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1674,21 +1674,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 				 sizeof(host_build_id)) == 0)
 		is_host = dso__build_id_equal(dso, host_build_id);
 
-	build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
-
-	scnprintf(path, sizeof(path), "%s/%s/%s", buildid_dir,
-		  DSO__NAME_KCORE, sbuild_id);
-
-	/* Use /proc/kallsyms if possible */
+	/* Try a fast path for /proc/kallsyms if possible */
 	if (is_host) {
-		DIR *d;
-
-		/* If no cached kcore go with /proc/kallsyms */
-		d = opendir(path);
-		if (!d)
-			goto proc_kallsyms;
-		closedir(d);
-
 		/*
 		 * Do not check the build-id cache, unless we know we cannot use
 		 * /proc/kcore or module maps don't match to /proc/kallsyms.
@@ -1699,18 +1686,24 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 		if (filename__readable("/proc/kcore") &&
 		    !validate_kcore_addresses("/proc/kallsyms", map))
 			goto proc_kallsyms;
-
-		/* Find kallsyms in build-id cache with kcore */
-		if (!find_matching_kcore(map, path, sizeof(path)))
-			return strdup(path);
-
-		goto proc_kallsyms;
 	}
 
+	build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
+
 	/* Find kallsyms in build-id cache with kcore */
+	scnprintf(path, sizeof(path), "%s/%s/%s",
+		  buildid_dir, DSO__NAME_KCORE, sbuild_id);
+
 	if (!find_matching_kcore(map, path, sizeof(path)))
 		return strdup(path);
 
+	/* Use current /proc/kallsyms if possible */
+	if (is_host) {
+proc_kallsyms:
+		return strdup("/proc/kallsyms");
+	}
+
+	/* Finally, find a cache of kallsyms */
 	scnprintf(path, sizeof(path), "%s/%s/%s",
 		  buildid_dir, DSO__NAME_KALLSYMS, sbuild_id);
 
@@ -1721,9 +1714,6 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 	}
 
 	return strdup(path);
-
-proc_kallsyms:
-	return strdup("/proc/kallsyms");
 }
 
 static int dso__load_kernel_sym(struct dso *dso, struct map *map,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ