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]
Date:   Mon, 17 Jan 2022 09:59:12 +0000
From:   James Clark <james.clark@....com>
To:     German Gomez <german.gomez@....com>, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org
Cc:     Chase Conklin <chase.conklin@....com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, Ian Rogers <irogers@...gle.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Stephane Eranian <eranian@...gle.com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, "acme@...nel.org" <acme@...nel.org>
Subject: Re: [PATCH] perf record/arm-spe: Override attr->sample_period for
 non-libpfm4 events



On 14/01/2022 21:21, German Gomez wrote:
> A previous commit preventing attr->sample_period values from being
> overridden in pfm events changed a related behaviour in arm_spe.
> 
> Before this patch:
> perf record -c 10000 -e arm_spe_0// -- sleep 1
> 
> Would not yield an SPE event with period=10000, because the arm-spe code

Just to clarify, this seems like it should say "Would yield", not "Would not yield",
as in it was previously working?

> initializes sample_period to a non-0 value, so the "-c 10000" is ignored.
> 
> This patch restores the previous behaviour for non-libpfm4 events.
> 
> Reported-by: Chase Conklin <chase.conklin@....com>
> Fixes: ae5dcc8abe31 (“perf record: Prevent override of attr->sample_period for libpfm4 events”)
> Signed-off-by: German Gomez <german.gomez@....com>
> ---
>  tools/perf/util/evsel.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a59fb2ecb84e..86ab038f020f 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1065,6 +1065,17 @@ void __weak arch_evsel__fixup_new_cycles(struct perf_event_attr *attr __maybe_un
>  {
>  }
>  
> +static void evsel__set_default_freq_period(struct record_opts *opts,
> +					   struct perf_event_attr *attr)
> +{
> +	if (opts->freq) {
> +		attr->freq = 1;
> +		attr->sample_freq = opts->freq;
> +	} else {
> +		attr->sample_period = opts->default_interval;
> +	}
> +}
> +
>  /*
>   * The enable_on_exec/disabled value strategy:
>   *
> @@ -1131,14 +1142,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
>  	 * We default some events to have a default interval. But keep
>  	 * it a weak assumption overridable by the user.
>  	 */
> -	if (!attr->sample_period) {
> -		if (opts->freq) {
> -			attr->freq		= 1;
> -			attr->sample_freq	= opts->freq;
> -		} else {
> -			attr->sample_period = opts->default_interval;
> -		}
> -	}
> +	if ((evsel->is_libpfm_event && !attr->sample_period) ||
> +	    (!evsel->is_libpfm_event && (!attr->sample_period ||
> +					 opts->user_freq != UINT_MAX ||
> +					 opts->user_interval != ULLONG_MAX)))
> +		evsel__set_default_freq_period(opts, attr);
> +
>  	/*
>  	 * If attr->freq was set (here or earlier), ask for period
>  	 * to be sampled.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ