Re: perf-core build fails on powerpc

From: John Garry
Date: Wed Mar 14 2018 - 05:23:51 EST


On 14/03/2018 07:10, John Garry wrote:
On 13/03/2018 21:18, Sukadev Bhattiprolu wrote:
John Garry [john.garry@xxxxxxxxxx] wrote:
On 13/03/2018 20:10, Sukadev Bhattiprolu wrote:

Hi John,

I have an xfs file system which seems to have d_type == DT_UNKNOWN
for all
entries in 'tools/perf/pmu-events/arch/power8'! readdir(3) says
->d_type
may not be supported by all file systems.

Not relying on ->d_type seems to fix it:


Hi Sukadev,

Thanks for debugging this. Jiri Olsa (cc'ed) warned me on this, so I
did add
the check for d_type == DT_UNKNOWN.

But, if all files have d_type == DT_UNKNOWN, you're code would from
visual
observation look to be same as mine (apart from check for '.' or '..'
filename, which I would say is already covered by stat() and
S_ISDIR()). Or
is d_type value just unreliable?

In the current code and with DT_UNKNOWN, is_leaf_dir() returns false when
it sees the "." or ".." entries right? In the new code, we skip those and
return false only if we find some other directory.


OK, that's the real issue, being the "." and ".." entries.

@Arnaldo, I'll try to send a fix for this today. I just need to make an
xfs to test. Sorry for the hassle.


Hi Sukadev,

Even with the xfs I have created I still don't see DT_UNKNOWN. So can you kindly test this change for me:

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 1c018445e757..9f712dafa0b2 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -873,7 +873,10 @@ static int is_leaf_dir(const char *fpath)
return 0;

while ((dir = readdir(d)) != NULL) {
- if (dir->d_type == DT_DIR && dir->d_name[0] != '.') {
+ if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
+ continue;
+
+ if (dir->d_type == DT_DIR) {
res = 0;
break;
} else if (dir->d_type == DT_UNKNOWN) {


It's quite similar to your change, except keeping the check for DT_DIR.

Much appreciated,
John

John

Thanks,

Sukadev