public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <song@kernel.org>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	acme@kernel.org, acme@redhat.com, namhyung@kernel.org,
	jolsa@kernel.org, songliubraving@fb.com
Subject: Re: [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events
Date: Mon, 19 Apr 2021 16:26:36 +0200	[thread overview]
Message-ID: <YH2THG9zES3rjvEs@krava> (raw)
In-Reply-To: <20210416221325.2373497-4-song@kernel.org>

On Fri, Apr 16, 2021 at 03:13:24PM -0700, Song Liu wrote:

SNIP

> +/*
> + * Returns:
> + *     0   if all events use BPF;
> + *     1   if some events do NOT use BPF;
> + *     < 0 on errors;
> + */
>  static int read_bpf_map_counters(void)
>  {
> +	bool has_none_bpf_events = false;
>  	struct evsel *counter;
>  	int err;
>  
>  	evlist__for_each_entry(evsel_list, counter) {
> +		if (!evsel__is_bpf(counter)) {
> +			has_none_bpf_events = true;
> +			continue;
> +		}
>  		err = bpf_counter__read(counter);
>  		if (err)
>  			return err;
>  	}
> -	return 0;
> +	return has_none_bpf_events ? 1 : 0;
>  }
>  
>  static void read_counters(struct timespec *rs)
> @@ -442,9 +455,10 @@ static void read_counters(struct timespec *rs)
>  	int err;
>  
>  	if (!stat_config.stop_read_counter) {
> -		if (target__has_bpf(&target))
> -			err = read_bpf_map_counters();
> -		else
> +		err = read_bpf_map_counters();
> +		if (err < 0)
> +			return;
> +		if (err)
>  			err = read_affinity_counters(rs);

this part is confusing for me.. I understand we don't want to enter
read_affinity_counters when there's no bpf counter, so we don't set
affinities in vain.. but there must be better way ;-)

> diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
> index 5de991ab46af9..3189b63714371 100644
> --- a/tools/perf/util/bpf_counter.c
> +++ b/tools/perf/util/bpf_counter.c
> @@ -792,6 +792,8 @@ int bpf_counter__load(struct evsel *evsel, struct target *target)
>  		evsel->bpf_counter_ops = &bpf_program_profiler_ops;
>  	else if (target->use_bpf)
>  		evsel->bpf_counter_ops = &bperf_ops;
> +	else if (evsel__match_bpf_counter_events(evsel->name))
> +		evsel->bpf_counter_ops = &bperf_ops;

please put this with the target->use_bpf check,
it seems like it's another thing

thanks,
jirka


  parent reply	other threads:[~2021-04-19 14:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 22:13 [PATCH v3 0/4] perf util: bpf perf improvements Song Liu
2021-04-16 22:13 ` [PATCH v3 1/4] perf util: move bpf_perf definitions to a libperf header Song Liu
2021-04-16 22:13 ` [PATCH v3 2/4] perf bpf: check perf_attr_map is compatible with the perf binary Song Liu
2021-04-16 22:13 ` [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events Song Liu
2021-04-17 16:45   ` Namhyung Kim
2021-04-19 20:26     ` Song Liu
2021-04-20 17:30       ` Jiri Olsa
2021-04-19 14:26   ` Jiri Olsa [this message]
2021-04-19 20:27     ` Song Liu
2021-04-16 22:13 ` [PATCH v3 4/4] perf-stat: introduce ':b' modifier Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YH2THG9zES3rjvEs@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=song@kernel.org \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox