linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf arm-spe: Report error if set frequency
@ 2025-02-05 18:30 Leo Yan
  2025-02-17  8:20 ` Leo Yan
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Yan @ 2025-02-05 18:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, James Clark, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, linux-arm-kernel, linux-perf-users, linux-kernel
  Cc: Leo Yan

When users set the parameter '-F' to specify frequency for Arm SPE, the
tool reports error:

  perf record -F 1000 -e arm_spe_0// -- sleep 1
  Error:
  Invalid event (arm_spe_0//) in per-thread mode, enable system wide with '-a'.

The output logs are confused and it does not give the correct reminding.
Arm SPE does not support frequency setting given it adopts a statistical
based approach.

Alternatively, Arm SPE supports setting period.  This commit adds a
for frequency setting.  It reports error and reminds users to set period
instead.

After:

  perf record -F 100 -e arm_spe_0// -- sleep 1
  Arm SPE: Frequency is not supported. Check manual 'man perf-record' on how to set period.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/arch/arm64/util/arm-spe.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
index 4301181b8e45..baef0812dc19 100644
--- a/tools/perf/arch/arm64/util/arm-spe.c
+++ b/tools/perf/arch/arm64/util/arm-spe.c
@@ -40,6 +40,19 @@ struct arm_spe_recording {
 	bool			*wrapped;
 };
 
+/* Iterate config list to detect if the "freq" parameter is set */
+static bool arm_spe_is_set_freq(struct evsel *evsel)
+{
+	struct evsel_config_term *term;
+
+	list_for_each_entry(term, &evsel->config_terms, list) {
+		if (term->type == EVSEL__CONFIG_TERM_FREQ)
+			return true;
+	}
+
+	return false;
+}
+
 /*
  * arm_spe_find_cpus() returns a new cpu map, and the caller should invoke
  * perf_cpu_map__put() to release the map after use.
@@ -389,6 +402,13 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
 				return -EINVAL;
 			}
 			opts->full_auxtrace = true;
+
+			if (opts->user_freq != UINT_MAX ||
+			    arm_spe_is_set_freq(evsel)) {
+				pr_err("Arm SPE: Frequency is not supported. "
+				       "Check manual 'man perf-record' on how to set period.\n");
+				return -EINVAL;
+			}
 		}
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf arm-spe: Report error if set frequency
  2025-02-05 18:30 [PATCH] perf arm-spe: Report error if set frequency Leo Yan
@ 2025-02-17  8:20 ` Leo Yan
  2025-02-27  7:05   ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Yan @ 2025-02-17  8:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, James Clark, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, linux-arm-kernel, linux-perf-users, linux-kernel

On Wed, Feb 05, 2025 at 06:30:09PM +0000, Leo Yan wrote:
> When users set the parameter '-F' to specify frequency for Arm SPE, the
> tool reports error:
> 
>   perf record -F 1000 -e arm_spe_0// -- sleep 1
>   Error:
>   Invalid event (arm_spe_0//) in per-thread mode, enable system wide with '-a'.
> 
> The output logs are confused and it does not give the correct reminding.
> Arm SPE does not support frequency setting given it adopts a statistical
> based approach.
> 
> Alternatively, Arm SPE supports setting period.  This commit adds a
> for frequency setting.  It reports error and reminds users to set period
> instead.
> 
> After:
> 
>   perf record -F 100 -e arm_spe_0// -- sleep 1
>   Arm SPE: Frequency is not supported. Check manual 'man perf-record' on how to set period.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Gentle ping.

> ---
>  tools/perf/arch/arm64/util/arm-spe.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
> index 4301181b8e45..baef0812dc19 100644
> --- a/tools/perf/arch/arm64/util/arm-spe.c
> +++ b/tools/perf/arch/arm64/util/arm-spe.c
> @@ -40,6 +40,19 @@ struct arm_spe_recording {
>  	bool			*wrapped;
>  };
>  
> +/* Iterate config list to detect if the "freq" parameter is set */
> +static bool arm_spe_is_set_freq(struct evsel *evsel)
> +{
> +	struct evsel_config_term *term;
> +
> +	list_for_each_entry(term, &evsel->config_terms, list) {
> +		if (term->type == EVSEL__CONFIG_TERM_FREQ)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  /*
>   * arm_spe_find_cpus() returns a new cpu map, and the caller should invoke
>   * perf_cpu_map__put() to release the map after use.
> @@ -389,6 +402,13 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
>  				return -EINVAL;
>  			}
>  			opts->full_auxtrace = true;
> +
> +			if (opts->user_freq != UINT_MAX ||
> +			    arm_spe_is_set_freq(evsel)) {
> +				pr_err("Arm SPE: Frequency is not supported. "
> +				       "Check manual 'man perf-record' on how to set period.\n");
> +				return -EINVAL;
> +			}
>  		}
>  	}
>  
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf arm-spe: Report error if set frequency
  2025-02-17  8:20 ` Leo Yan
@ 2025-02-27  7:05   ` Namhyung Kim
  2025-02-27  8:22     ` Leo Yan
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-02-27  7:05 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, James Clark, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, linux-arm-kernel, linux-perf-users, linux-kernel

Hello,

On Mon, Feb 17, 2025 at 08:20:08AM +0000, Leo Yan wrote:
> On Wed, Feb 05, 2025 at 06:30:09PM +0000, Leo Yan wrote:
> > When users set the parameter '-F' to specify frequency for Arm SPE, the
> > tool reports error:
> > 
> >   perf record -F 1000 -e arm_spe_0// -- sleep 1
> >   Error:
> >   Invalid event (arm_spe_0//) in per-thread mode, enable system wide with '-a'.
> > 
> > The output logs are confused and it does not give the correct reminding.
> > Arm SPE does not support frequency setting given it adopts a statistical
> > based approach.
> > 
> > Alternatively, Arm SPE supports setting period.  This commit adds a
> > for frequency setting.  It reports error and reminds users to set period
> > instead.
> > 
> > After:
> > 
> >   perf record -F 100 -e arm_spe_0// -- sleep 1
> >   Arm SPE: Frequency is not supported. Check manual 'man perf-record' on how to set period.
> > 
> > Signed-off-by: Leo Yan <leo.yan@arm.com>
> 
> Gentle ping.

Sorry for the late reply.

Isn't it just -c <period> to set period for Arm SPE?  If so, it'd be
better to say that explicitly.

Thanks,
Namhyung

> 
> > ---
> >  tools/perf/arch/arm64/util/arm-spe.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
> > index 4301181b8e45..baef0812dc19 100644
> > --- a/tools/perf/arch/arm64/util/arm-spe.c
> > +++ b/tools/perf/arch/arm64/util/arm-spe.c
> > @@ -40,6 +40,19 @@ struct arm_spe_recording {
> >  	bool			*wrapped;
> >  };
> >  
> > +/* Iterate config list to detect if the "freq" parameter is set */
> > +static bool arm_spe_is_set_freq(struct evsel *evsel)
> > +{
> > +	struct evsel_config_term *term;
> > +
> > +	list_for_each_entry(term, &evsel->config_terms, list) {
> > +		if (term->type == EVSEL__CONFIG_TERM_FREQ)
> > +			return true;
> > +	}
> > +
> > +	return false;
> > +}
> > +
> >  /*
> >   * arm_spe_find_cpus() returns a new cpu map, and the caller should invoke
> >   * perf_cpu_map__put() to release the map after use.
> > @@ -389,6 +402,13 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
> >  				return -EINVAL;
> >  			}
> >  			opts->full_auxtrace = true;
> > +
> > +			if (opts->user_freq != UINT_MAX ||
> > +			    arm_spe_is_set_freq(evsel)) {
> > +				pr_err("Arm SPE: Frequency is not supported. "
> > +				       "Check manual 'man perf-record' on how to set period.\n");
> > +				return -EINVAL;
> > +			}
> >  		}
> >  	}
> >  
> > -- 
> > 2.34.1
> > 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf arm-spe: Report error if set frequency
  2025-02-27  7:05   ` Namhyung Kim
@ 2025-02-27  8:22     ` Leo Yan
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2025-02-27  8:22 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, James Clark, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, linux-arm-kernel, linux-perf-users, linux-kernel

Hi Namhyung,

On Wed, Feb 26, 2025 at 11:05:08PM -0800, Namhyung Kim wrote:

[...]

> > > After:
> > >
> > >   perf record -F 100 -e arm_spe_0// -- sleep 1
> > >   Arm SPE: Frequency is not supported. Check manual 'man perf-record' on how to set period.
> > >
> > > Signed-off-by: Leo Yan <leo.yan@arm.com>
> >
> > Gentle ping.
> 
> Sorry for the late reply.
> 
> Isn't it just -c <period> to set period for Arm SPE?  If so, it'd be
> better to say that explicitly.

Yes, '-c' works for Arm SPE.  Will change for this.

Thanks,
Leo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-27  8:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 18:30 [PATCH] perf arm-spe: Report error if set frequency Leo Yan
2025-02-17  8:20 ` Leo Yan
2025-02-27  7:05   ` Namhyung Kim
2025-02-27  8:22     ` Leo Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).