lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191023094724.GI22919@krava>
Date:   Wed, 23 Oct 2019 11:47:24 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Andi Kleen <andi@...stfloor.org>
Cc:     acme@...nel.org, linux-kernel@...r.kernel.org, jolsa@...nel.org,
        eranian@...gle.com, kan.liang@...ux.intel.com,
        peterz@...radead.org, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v2 3/9] perf pmu: Use file system cache to optimize sysfs
 access

On Sun, Oct 20, 2019 at 10:51:56AM -0700, Andi Kleen wrote:

SNIP

> @@ -92,8 +93,12 @@ static int pmu_format(const char *name, struct list_head *format)
>  	snprintf(path, PATH_MAX,
>  		 "%s" EVENT_SOURCE_DEVICE_PATH "%s/format", sysfs, name);
>  
> -	if (stat(path, &st) < 0)
> +	if (lookup_fncache(path, &res) && !res)
> +		return 0;
> +
> +	if (!res && access(path, R_OK) < 0)
>  		return 0;	/* no error if format does not exist */
> +	update_fncache(path, true);
>  
>  	if (perf_pmu__format_parse(path, format))
>  		return -1;
> @@ -470,9 +475,9 @@ static int pmu_aliases_parse(char *dir, struct list_head *head)
>   */
>  static int pmu_aliases(const char *name, struct list_head *head)
>  {
> -	struct stat st;
>  	char path[PATH_MAX];
>  	const char *sysfs = sysfs__mountpoint();
> +	bool res = false;
>  
>  	if (!sysfs)
>  		return -1;
> @@ -480,8 +485,11 @@ static int pmu_aliases(const char *name, struct list_head *head)
>  	snprintf(path, PATH_MAX,
>  		 "%s/bus/event_source/devices/%s/events", sysfs, name);
>  
> -	if (stat(path, &st) < 0)
> -		return 0;	 /* no error if 'events' does not exist */
> +	if (lookup_fncache(path, &res) && !res)
> +		return 0;
> +	if (!res && access(path, R_OK) < 0)
> +		return 0;
> +	update_fncache(path, true);

I was thinking that maybe you dont need to have the fncache::res,
but then I realized we have 2 kind of information in here:
  - we processed this file
  - is present file present

so I think you should update the result on each update_fncache call,
not only when it's succesful


also, could you please make single function API for this?
sonething like:

  is_the_file_there(path)

that would encapsulate those calls

thanks,
jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ