From: Chenggang Qin <chenggang.qin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Chenggang Qin <chenggang.qcg@taobao.com>,
David Ahern <dsahern@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Arjan van de Ven <arjan@linux.intel.com>,
Namhyung Kim <namhyung@gmail.com>,
Yanmin Zhang <yanmin.zhang@intel.com>,
Wu Fengguang <fengguang.wu@intel.com>,
Mike Galbraith <efault@gmx.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 1/2] perf core: avoid traverse dsos list while find vdso
Date: Thu, 5 Sep 2013 10:59:34 +0800 [thread overview]
Message-ID: <1378349975-3333-1-git-send-email-chenggang.qin@gmail.com> (raw)
From: Chenggang Qin <chenggang.qcg@taobao.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@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Yanmin Zhang <yanmin.zhang@intel.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chenggang Qin <chenggang.qcg@taobao.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
next reply other threads:[~2013-09-05 3:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 2:59 Chenggang Qin [this message]
2013-09-05 2:59 ` [PATCH 2/2] perf core: remove short name compare in dsos__find() Chenggang Qin
2013-09-09 12:05 ` [PATCH 1/2] perf core: avoid traverse dsos list while find vdso Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378349975-3333-1-git-send-email-chenggang.qin@gmail.com \
--to=chenggang.qin@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=chenggang.qcg@taobao.com \
--cc=dsahern@gmail.com \
--cc=efault@gmx.de \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=yanmin.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®