Re: [PATCH v3 1/7] perf pmu: Use file system cache to optimize sysfs access

From: Andi Kleen
Date: Mon Oct 28 2019 - 22:14:22 EST


On Mon, Oct 28, 2019 at 11:01:37PM +0100, Jiri Olsa wrote:
> On Fri, Oct 25, 2019 at 11:14:11AM -0700, Andi Kleen wrote:
>
> SNIP
>
> > if (pmu_aliases_parse(path, head))
> > return -1;
> > @@ -525,7 +524,6 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias,
> > */
> > static int pmu_type(const char *name, __u32 *type)
> > {
> > - struct stat st;
> > char path[PATH_MAX];
> > FILE *file;
> > int ret = 0;
> > @@ -537,7 +535,7 @@ static int pmu_type(const char *name, __u32 *type)
> > snprintf(path, PATH_MAX,
> > "%s" EVENT_SOURCE_DEVICE_PATH "%s/type", sysfs, name);
> >
> > - if (stat(path, &st) < 0)
> > + if (access(path, R_OK) < 0)
>
> why not file_available call in here?

iirc it doesn't do any redundant accesses.

-Andi