diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-12-19 16:40:28 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-28 04:18:37 -0500 |
commit | 659d8cfbb225f1fa5a4f8671a847ef3ab5a89660 (patch) | |
tree | 5eb4d89c29110f8d82edbb86b6bf3a6aee431e4a /tools/perf/builtin-kmem.c | |
parent | fd2a50a0240f5f5b59070474eabd83a85720a406 (diff) |
perf tools: Do a few more directory handling optimizations
A few more optimizations for perf when dealing with directories.
Some of them significantly cut down the work which has to be
done. d_type should always be set; otherwise fix the kernel
code. And there are functions available to parse fstab-like
files, so use them.
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: a.p.zijlstra@chello.nl
Cc: acme@redhat.com
Cc: eranian@google.com
Cc: fweisbec@gmail.com
Cc: lizf@cn.fujitsu.com
Cc: paulus@samba.org
Cc: xiaoguangrong@cn.fujitsu.com
LKML-Reference: <200912192140.nBJLeSfA028905@hs20-bc2-1.build.redhat.com>
[ v2: two small stylistic fixlets ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-kmem.c')
-rw-r--r-- | tools/perf/builtin-kmem.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 4c06828fe39d..05dc5a735039 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -92,23 +92,18 @@ static void setup_cpunode_map(void) | |||
92 | if (!dir1) | 92 | if (!dir1) |
93 | return; | 93 | return; |
94 | 94 | ||
95 | while (true) { | 95 | while ((dent1 = readdir(dir1)) != NULL) { |
96 | dent1 = readdir(dir1); | 96 | if (dent1->d_type != DT_DIR || |
97 | if (!dent1) | 97 | sscanf(dent1->d_name, "node%u", &mem) < 1) |
98 | break; | ||
99 | |||
100 | if (sscanf(dent1->d_name, "node%u", &mem) < 1) | ||
101 | continue; | 98 | continue; |
102 | 99 | ||
103 | snprintf(buf, PATH_MAX, "%s/%s", PATH_SYS_NODE, dent1->d_name); | 100 | snprintf(buf, PATH_MAX, "%s/%s", PATH_SYS_NODE, dent1->d_name); |
104 | dir2 = opendir(buf); | 101 | dir2 = opendir(buf); |
105 | if (!dir2) | 102 | if (!dir2) |
106 | continue; | 103 | continue; |
107 | while (true) { | 104 | while ((dent2 = readdir(dir2)) != NULL) { |
108 | dent2 = readdir(dir2); | 105 | if (dent2->d_type != DT_LNK || |
109 | if (!dent2) | 106 | sscanf(dent2->d_name, "cpu%u", &cpu) < 1) |
110 | break; | ||
111 | if (sscanf(dent2->d_name, "cpu%u", &cpu) < 1) | ||
112 | continue; | 107 | continue; |
113 | cpunode_map[cpu] = mem; | 108 | cpunode_map[cpu] = mem; |
114 | } | 109 | } |