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>
This commit is contained in:
committed by
Ingo Molnar
parent
fd2a50a024
commit
659d8cfbb2
@ -92,23 +92,18 @@ static void setup_cpunode_map(void)
|
||||
if (!dir1)
|
||||
return;
|
||||
|
||||
while (true) {
|
||||
dent1 = readdir(dir1);
|
||||
if (!dent1)
|
||||
break;
|
||||
|
||||
if (sscanf(dent1->d_name, "node%u", &mem) < 1)
|
||||
while ((dent1 = readdir(dir1)) != NULL) {
|
||||
if (dent1->d_type != DT_DIR ||
|
||||
sscanf(dent1->d_name, "node%u", &mem) < 1)
|
||||
continue;
|
||||
|
||||
snprintf(buf, PATH_MAX, "%s/%s", PATH_SYS_NODE, dent1->d_name);
|
||||
dir2 = opendir(buf);
|
||||
if (!dir2)
|
||||
continue;
|
||||
while (true) {
|
||||
dent2 = readdir(dir2);
|
||||
if (!dent2)
|
||||
break;
|
||||
if (sscanf(dent2->d_name, "cpu%u", &cpu) < 1)
|
||||
while ((dent2 = readdir(dir2)) != NULL) {
|
||||
if (dent2->d_type != DT_LNK ||
|
||||
sscanf(dent2->d_name, "cpu%u", &cpu) < 1)
|
||||
continue;
|
||||
cpunode_map[cpu] = mem;
|
||||
}
|
||||
|
Reference in New Issue
Block a user