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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191115145518.GA4255@krava>
Date:   Fri, 15 Nov 2019 15:55:18 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Andi Kleen <andi@...stfloor.org>
Cc:     jolsa@...nel.org, acme@...nel.org, linux-kernel@...r.kernel.org,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v6 11/12] perf evsel: Add functions to enable/disable for
 a specific CPU

On Mon, Nov 11, 2019 at 04:59:40PM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@...ux.intel.com>
> 
> Refactor the existing functions to use these functions internally.
> 
> Used in the next patch
> 
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
> ---
>  tools/perf/lib/evsel.c              | 49 +++++++++++++++++++++--------
>  tools/perf/lib/include/perf/evsel.h |  2 ++
>  tools/perf/util/evsel.c             | 13 +++++++-
>  tools/perf/util/evsel.h             |  2 ++
>  4 files changed, 52 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c
> index ea775dacbd2d..89ddfade0b96 100644
> --- a/tools/perf/lib/evsel.c
> +++ b/tools/perf/lib/evsel.c
> @@ -198,38 +198,61 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
>  }
>  
>  static int perf_evsel__run_ioctl(struct perf_evsel *evsel,
> -				 int ioc,  void *arg)
> +				 int ioc,  void *arg,
> +				 int cpu)
>  {
> -	int cpu, thread;
> +	int thread;
>  
> -	for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) {
> -		for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {
> -			int fd = FD(evsel, cpu, thread),
> -			    err = ioctl(fd, ioc, arg);
> +	for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) {
> +		int fd = FD(evsel, cpu, thread),
> +		    err = ioctl(fd, ioc, arg);
>  
> -			if (err)
> -				return err;
> -		}
> +		if (err)
> +			return err;
>  	}
>  
>  	return 0;
>  }
>  
> +int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu)
> +{
> +	return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0, cpu);

please use NULL instead of 0, I initialy confused it for index

for all the calls perf_evsel__run_ioctl below

thanks,
jirka

> +}
> +
>  int perf_evsel__enable(struct perf_evsel *evsel)
>  {
> -	return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0);
> +	int i;
> +	int err = 0;
> +
> +	for (i = 0; i < evsel->cpus->nr && !err; i++)
> +		err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_ENABLE, 0, i);
> +	return err;
> +}
> +
> +int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu)
> +{
> +	return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0, cpu);
>  }
>  
>  int perf_evsel__disable(struct perf_evsel *evsel)
>  {
> -	return perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0);
> +	int i;
> +	int err = 0;
> +
> +	for (i = 0; i < evsel->cpus->nr && !err; i++)
> +		err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, 0, i);
> +	return err;
>  }
>  

SNIP

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ