From: Jiri Olsa <olsajiri@gmail.com>
To: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@redhat.com, namhyung@kernel.org,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v2 5/7] libperf: Add perf_evsel__check_overflow() functions
Date: Wed, 30 Mar 2022 15:50:36 +0200 [thread overview]
Message-ID: <YkRgLBTHVQbdX8rK@krava> (raw)
In-Reply-To: <20220325043829.224045-6-nakamura.shun@fujitsu.com>
On Fri, Mar 25, 2022 at 01:38:27PM +0900, Shunsuke Nakamura wrote:
> Add the following functions:
>
> perf_evsel__check_overflow
> perf_evsel__check_overflow_cpu
>
> to check for perf events with the file descriptor specified in the
> argument.
> These functions can be used in signal handlers to check overflow.
>
> Signed-off-by: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
> ---
> tools/lib/perf/Documentation/libperf.txt | 3 +++
> tools/lib/perf/evsel.c | 34 ++++++++++++++++++++++++
> tools/lib/perf/include/perf/evsel.h | 4 +++
> tools/lib/perf/libperf.map | 2 ++
> 4 files changed, 43 insertions(+)
>
> diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
> index 700c1ce15159..4ae8d738b948 100644
> --- a/tools/lib/perf/Documentation/libperf.txt
> +++ b/tools/lib/perf/Documentation/libperf.txt
> @@ -165,6 +165,9 @@ SYNOPSIS
> int cpu_map_idx);
> int perf_evsel__period(struct perf_evsel *evsel, int period);
> int perf_evsel__period_cpu(struct perf_evsel *evsel, int period, int cpu_map_idx);
> + int perf_evsel__check_overflow(struct perf_evsel *evsel, int sig_fd, bool *overflow);
> + int perf_evsel__check_overflow_cpu(struct perf_evsel *evsel, int cpu_map_idx,
> + int sig_fd, bool *overflow);
should this be more like:
perf_evsel__has_fd(struct perf_evsel *evsel, int fd)
also why do we need to export *_cpu version for this?
I don't see it used in the test
> struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
> struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
> struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
> diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
> index db9b7274feb5..6ff3cf692df3 100644
> --- a/tools/lib/perf/evsel.c
> +++ b/tools/lib/perf/evsel.c
> @@ -616,3 +616,37 @@ int perf_evsel__open_opts(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
>
> return err;
> }
> +
> +int perf_evsel__check_overflow_cpu(struct perf_evsel *evsel, int cpu_map_idx,
> + int sig_fd, bool *overflow)
> +{
> + int thread;
> + int *fd;
> + int err = 0;
> +
> + if (!overflow)
> + return -EINVAL;
> +
> + *overflow = false;
> +
> + for (thread = 0; thread < xyarray__max_y(evsel->fd) && !err; ++thread) {
> + fd = FD(evsel, cpu_map_idx, thread);
> + if (sig_fd <= 0 || !fd || *fd < 0)
> + err = -EINVAL;
sig_fd check should be before the loop
jirka
next prev parent reply other threads:[~2022-03-30 13:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 4:38 [RFC PATCH v2 0/7] libperf: Add interface for overflow check of sampling events Shunsuke Nakamura
2022-03-25 4:38 ` [RFC PATCH v2 1/7] libperf tests: Fix typo in the error message Shunsuke Nakamura
2022-03-25 19:52 ` Arnaldo Carvalho de Melo
2022-03-25 4:38 ` [RFC PATCH v2 2/7] libperf: Move 'open_flags' from tools/perf to evsel::open_flags Shunsuke Nakamura
2022-03-30 13:50 ` Jiri Olsa
2022-04-11 8:27 ` nakamura.shun
2022-03-25 4:38 ` [RFC PATCH v2 3/7] libperf: Add perf_evsel__{refresh, period}() functions Shunsuke Nakamura
2022-03-30 13:50 ` Jiri Olsa
2022-04-11 8:29 ` nakamura.shun
2022-03-25 4:38 ` [RFC PATCH v2 4/7] libperf: Introduce perf_{evsel, evlist}__open_opt with extensible struct opts Shunsuke Nakamura
2022-03-30 13:50 ` Jiri Olsa
2022-04-11 8:31 ` nakamura.shun
2022-03-30 13:50 ` Jiri Olsa
2022-04-11 8:34 ` nakamura.shun
2022-03-25 4:38 ` [RFC PATCH v2 5/7] libperf: Add perf_evsel__check_overflow() functions Shunsuke Nakamura
2022-03-30 13:50 ` Jiri Olsa [this message]
2022-04-11 8:35 ` nakamura.shun
2022-03-25 4:38 ` [RFC PATCH v2 6/7] libperf test: Add test_stat_overflow() Shunsuke Nakamura
2022-03-25 4:38 ` [RFC PATCH v2 7/7] libperf test: Add test_stat_overflow_event() Shunsuke Nakamura
2022-03-30 13:50 ` [RFC PATCH v2 0/7] libperf: Add interface for overflow check of sampling events Jiri Olsa
2022-04-11 8:23 ` nakamura.shun
2022-04-19 20:15 ` Jiri Olsa
2022-04-20 8:22 ` nakamura.shun
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=YkRgLBTHVQbdX8rK@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=nakamura.shun@fujitsu.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).