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-next>] [day] [month] [year] [list]
Date:	Thu,  5 Sep 2013 10:59:34 +0800
From:	Chenggang Qin <chenggang.qin@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Chenggang Qin <chenggang.qcg@...bao.com>,
	David Ahern <dsahern@...il.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Namhyung Kim <namhyung@...il.com>,
	Yanmin Zhang <yanmin.zhang@...el.com>,
	Wu Fengguang <fengguang.wu@...el.com>,
	Mike Galbraith <efault@....de>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 1/2] perf core: avoid traverse dsos list while find vdso

From: Chenggang Qin <chenggang.qcg@...bao.com>

Vdso is only one in a system. It is not necessory to traverse the
macine->user_dsos list while finding the dso of vdso.
The flag vdso_found should be replaced by a pointor that point to the dso of
vdso. If the pointer is NULL, dso of vdso have not been created. Else, the
pointor can be returned directly in function vdso__dso_findnew().
The list traversing can be avoided by this method.
Thanks.

Cc: David Ahern <dsahern@...il.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: Arjan van de Ven <arjan@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...il.com>
Cc: Yanmin Zhang <yanmin.zhang@...el.com>
Cc: Wu Fengguang <fengguang.wu@...el.com>
Cc: Mike Galbraith <efault@....de>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Chenggang Qin <chenggang.qcg@...bao.com>

---
 tools/perf/util/vdso.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 3915982..8022ef0 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -13,7 +13,7 @@
 #include "symbol.h"
 #include "linux/string.h"
 
-static bool vdso_found;
+static struct dso *vdso_dso = NULL;
 static char vdso_file[] = "/tmp/perf-vdso.so-XXXXXX";
 
 static int find_vdso_map(void **start, void **end)
@@ -55,9 +55,6 @@ static char *get_file(void)
 	size_t size;
 	int fd;
 
-	if (vdso_found)
-		return vdso_file;
-
 	if (find_vdso_map(&start, &end))
 		return NULL;
 
@@ -79,33 +76,30 @@ static char *get_file(void)
  out:
 	free(buf);
 
-	vdso_found = (vdso != NULL);
 	return vdso;
 }
 
 void vdso__exit(void)
 {
-	if (vdso_found)
+	if (vdso_dso)
 		unlink(vdso_file);
 }
 
 struct dso *vdso__dso_findnew(struct list_head *head)
 {
-	struct dso *dso = dsos__find(head, VDSO__MAP_NAME, true);
-
-	if (!dso) {
+	if (!vdso_dso) {
 		char *file;
 
 		file = get_file();
 		if (!file)
 			return NULL;
 
-		dso = dso__new(VDSO__MAP_NAME);
-		if (dso != NULL) {
-			dsos__add(head, dso);
-			dso__set_long_name(dso, file);
+		vdso_dso = dso__new(VDSO__MAP_NAME);
+		if (vdso_dso != NULL) {
+			dsos__add(head, vdso_dso);
+			dso__set_long_name(vdso_dso, file);
 		}
 	}
 
-	return dso;
+	return vdso_dso;
 }
-- 
1.7.8.rc2.5.g815b

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ