From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Riccardo Mancini <rickyman7@gmail.com>
Cc: Ian Rogers <irogers@google.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v1 19/37] perf evsel: separate missing feature detection from evsel__open_cpu
Date: Tue, 31 Aug 2021 16:39:04 -0300 [thread overview]
Message-ID: <YS6FWEf41ApoxBee@kernel.org> (raw)
In-Reply-To: <cba0b7d939862473662adeedb0f9c9b69566ee9a.1629490974.git.rickyman7@gmail.com>
Em Sat, Aug 21, 2021 at 11:19:25AM +0200, Riccardo Mancini escreveu:
> This is a preparatory patch for the following patches with the goal to
> separate in evlist__open_cpu the actual opening, which could be
> performed in parallel, from the existing fallback mechanisms, which
> should be handled sequentially.
>
> This patch separates the missing feature detection in evsel__open_cpu
> into a new evsel__detect_missing_features function.
Thanks, applied.
- Arnaldo
> Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> ---
> tools/perf/util/evsel.c | 174 +++++++++++++++++++++-------------------
> tools/perf/util/evsel.h | 1 +
> 2 files changed, 92 insertions(+), 83 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 4e9a3e62075305f1..c393bd992322d925 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1841,6 +1841,96 @@ int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus,
> return err;
> }
>
> +bool evsel__detect_missing_features(struct evsel *evsel)
> +{
> + /*
> + * Must probe features in the order they were added to the
> + * perf_event_attr interface.
> + */
> + if (!perf_missing_features.weight_struct &&
> + (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) {
> + perf_missing_features.weight_struct = true;
> + pr_debug2("switching off weight struct support\n");
> + return true;
> + } else if (!perf_missing_features.code_page_size &&
> + (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) {
> + perf_missing_features.code_page_size = true;
> + pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n");
> + return false;
> + } else if (!perf_missing_features.data_page_size &&
> + (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) {
> + perf_missing_features.data_page_size = true;
> + pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n");
> + return false;
> + } else if (!perf_missing_features.cgroup && evsel->core.attr.cgroup) {
> + perf_missing_features.cgroup = true;
> + pr_debug2_peo("Kernel has no cgroup sampling support, bailing out\n");
> + return false;
> + } else if (!perf_missing_features.branch_hw_idx &&
> + (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX)) {
> + perf_missing_features.branch_hw_idx = true;
> + pr_debug2("switching off branch HW index support\n");
> + return true;
> + } else if (!perf_missing_features.aux_output && evsel->core.attr.aux_output) {
> + perf_missing_features.aux_output = true;
> + pr_debug2_peo("Kernel has no attr.aux_output support, bailing out\n");
> + return false;
> + } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) {
> + perf_missing_features.bpf = true;
> + pr_debug2_peo("switching off bpf_event\n");
> + return true;
> + } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) {
> + perf_missing_features.ksymbol = true;
> + pr_debug2_peo("switching off ksymbol\n");
> + return true;
> + } else if (!perf_missing_features.write_backward && evsel->core.attr.write_backward) {
> + perf_missing_features.write_backward = true;
> + pr_debug2_peo("switching off write_backward\n");
> + return false;
> + } else if (!perf_missing_features.clockid_wrong && evsel->core.attr.use_clockid) {
> + perf_missing_features.clockid_wrong = true;
> + pr_debug2_peo("switching off clockid\n");
> + return true;
> + } else if (!perf_missing_features.clockid && evsel->core.attr.use_clockid) {
> + perf_missing_features.clockid = true;
> + pr_debug2_peo("switching off use_clockid\n");
> + return true;
> + } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FLAG_FD_CLOEXEC)) {
> + perf_missing_features.cloexec = true;
> + pr_debug2_peo("switching off cloexec flag\n");
> + return true;
> + } else if (!perf_missing_features.mmap2 && evsel->core.attr.mmap2) {
> + perf_missing_features.mmap2 = true;
> + pr_debug2_peo("switching off mmap2\n");
> + return true;
> + } else if (!perf_missing_features.exclude_guest &&
> + (evsel->core.attr.exclude_guest || evsel->core.attr.exclude_host)) {
> + perf_missing_features.exclude_guest = true;
> + pr_debug2_peo("switching off exclude_guest, exclude_host\n");
> + return true;
> + } else if (!perf_missing_features.sample_id_all) {
> + perf_missing_features.sample_id_all = true;
> + pr_debug2_peo("switching off sample_id_all\n");
> + return true;
> + } else if (!perf_missing_features.lbr_flags &&
> + (evsel->core.attr.branch_sample_type &
> + (PERF_SAMPLE_BRANCH_NO_CYCLES |
> + PERF_SAMPLE_BRANCH_NO_FLAGS))) {
> + perf_missing_features.lbr_flags = true;
> + pr_debug2_peo("switching off branch sample type no (cycles/flags)\n");
> + return true;
> + } else if (!perf_missing_features.group_read &&
> + evsel->core.attr.inherit &&
> + (evsel->core.attr.read_format & PERF_FORMAT_GROUP) &&
> + evsel__is_group_leader(evsel)) {
> + perf_missing_features.group_read = true;
> + pr_debug2_peo("switching off group read\n");
> + return true;
> + } else {
> + return false;
> + }
> +}
> +
> static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
> struct perf_thread_map *threads,
> int start_cpu, int end_cpu)
> @@ -1979,90 +2069,8 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
> if (err != -EINVAL || cpu > 0 || thread > 0)
> goto out_close;
>
> - /*
> - * Must probe features in the order they were added to the
> - * perf_event_attr interface.
> - */
> - if (!perf_missing_features.weight_struct &&
> - (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) {
> - perf_missing_features.weight_struct = true;
> - pr_debug2("switching off weight struct support\n");
> + if (evsel__detect_missing_features(evsel))
> goto fallback_missing_features;
> - } else if (!perf_missing_features.code_page_size &&
> - (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) {
> - perf_missing_features.code_page_size = true;
> - pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n");
> - goto out_close;
> - } else if (!perf_missing_features.data_page_size &&
> - (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) {
> - perf_missing_features.data_page_size = true;
> - pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n");
> - goto out_close;
> - } else if (!perf_missing_features.cgroup && evsel->core.attr.cgroup) {
> - perf_missing_features.cgroup = true;
> - pr_debug2_peo("Kernel has no cgroup sampling support, bailing out\n");
> - goto out_close;
> - } else if (!perf_missing_features.branch_hw_idx &&
> - (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX)) {
> - perf_missing_features.branch_hw_idx = true;
> - pr_debug2("switching off branch HW index support\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.aux_output && evsel->core.attr.aux_output) {
> - perf_missing_features.aux_output = true;
> - pr_debug2_peo("Kernel has no attr.aux_output support, bailing out\n");
> - goto out_close;
> - } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) {
> - perf_missing_features.bpf = true;
> - pr_debug2_peo("switching off bpf_event\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) {
> - perf_missing_features.ksymbol = true;
> - pr_debug2_peo("switching off ksymbol\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.write_backward && evsel->core.attr.write_backward) {
> - perf_missing_features.write_backward = true;
> - pr_debug2_peo("switching off write_backward\n");
> - goto out_close;
> - } else if (!perf_missing_features.clockid_wrong && evsel->core.attr.use_clockid) {
> - perf_missing_features.clockid_wrong = true;
> - pr_debug2_peo("switching off clockid\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.clockid && evsel->core.attr.use_clockid) {
> - perf_missing_features.clockid = true;
> - pr_debug2_peo("switching off use_clockid\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FLAG_FD_CLOEXEC)) {
> - perf_missing_features.cloexec = true;
> - pr_debug2_peo("switching off cloexec flag\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.mmap2 && evsel->core.attr.mmap2) {
> - perf_missing_features.mmap2 = true;
> - pr_debug2_peo("switching off mmap2\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.exclude_guest &&
> - (evsel->core.attr.exclude_guest || evsel->core.attr.exclude_host)) {
> - perf_missing_features.exclude_guest = true;
> - pr_debug2_peo("switching off exclude_guest, exclude_host\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.sample_id_all) {
> - perf_missing_features.sample_id_all = true;
> - pr_debug2_peo("switching off sample_id_all\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.lbr_flags &&
> - (evsel->core.attr.branch_sample_type &
> - (PERF_SAMPLE_BRANCH_NO_CYCLES |
> - PERF_SAMPLE_BRANCH_NO_FLAGS))) {
> - perf_missing_features.lbr_flags = true;
> - pr_debug2_peo("switching off branch sample type no (cycles/flags)\n");
> - goto fallback_missing_features;
> - } else if (!perf_missing_features.group_read &&
> - evsel->core.attr.inherit &&
> - (evsel->core.attr.read_format & PERF_FORMAT_GROUP) &&
> - evsel__is_group_leader(evsel)) {
> - perf_missing_features.group_read = true;
> - pr_debug2_peo("switching off group read\n");
> - goto fallback_missing_features;
> - }
> out_close:
> if (err)
> threads->err_thread = thread;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 58aa998e1814ac9e..a83fb7f69b1ead73 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -288,6 +288,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
> void evsel__close(struct evsel *evsel);
> int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus,
> struct perf_thread_map *threads);
> +bool evsel__detect_missing_features(struct evsel *evsel);
>
> struct perf_sample;
>
> --
> 2.31.1
--
- Arnaldo
next prev parent reply other threads:[~2021-08-31 19:39 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-21 9:19 [RFC PATCH v1 00/37] perf: use workqueue for evlist operations Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 01/37] libperf cpumap: improve idx function Riccardo Mancini
2021-08-31 18:46 ` Arnaldo Carvalho de Melo
2021-10-08 14:29 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 02/37] libperf cpumap: improve max function Riccardo Mancini
2021-08-31 18:47 ` Arnaldo Carvalho de Melo
2021-08-31 19:16 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 03/37] perf evlist: replace evsel__cpu_iter* functions with evsel__find_cpu Riccardo Mancini
2021-10-08 14:38 ` [RFC PATCH v1 03/37] perf evlist: replace evsel__cpu_iter* functions with evsel__find_cpu() Arnaldo Carvalho de Melo
2021-12-11 0:20 ` [RFC PATCH v1 03/37] perf evlist: replace evsel__cpu_iter* functions with evsel__find_cpu Ian Rogers
2021-08-21 9:19 ` [RFC PATCH v1 04/37] perf util: add mmap_cpu_mask__duplicate function Riccardo Mancini
2021-08-31 19:21 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 05/37] perf util/mmap: add missing bitops.h header Riccardo Mancini
2021-08-31 19:22 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 06/37] perf workqueue: add affinities to threadpool Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 07/37] perf workqueue: add support for setting affinities to workers Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 08/37] perf workqueue: add method to execute work on specific CPU Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 09/37] perf python: add workqueue dependency Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 10/37] perf evlist: add multithreading helper Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 11/37] perf evlist: add multithreading to evlist__disable Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 12/37] perf evlist: add multithreading to evlist__enable Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 13/37] perf evlist: add multithreading to evlist__close Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 14/37] perf evsel: remove retry_sample_id goto label Riccardo Mancini
2021-08-31 19:25 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 15/37] perf evsel: separate open preparation from open itself Riccardo Mancini
2021-08-31 19:27 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 16/37] perf evsel: save open flags in evsel Riccardo Mancini
2021-08-31 19:31 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 17/37] perf evsel: separate missing feature disabling from evsel__open_cpu Riccardo Mancini
2021-08-31 19:35 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 18/37] perf evsel: add evsel__prepare_open function Riccardo Mancini
2021-08-31 19:36 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 19/37] perf evsel: separate missing feature detection from evsel__open_cpu Riccardo Mancini
2021-08-31 19:39 ` Arnaldo Carvalho de Melo [this message]
2021-08-21 9:19 ` [RFC PATCH v1 20/37] perf evsel: separate rlimit increase " Riccardo Mancini
2021-08-31 19:41 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 21/37] perf evsel: move ignore_missing_thread to fallback code Riccardo Mancini
2021-08-31 19:44 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 22/37] perf evsel: move test_attr__open to success path in evsel__open_cpu Riccardo Mancini
2021-08-31 19:47 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 23/37] perf evsel: move bpf_counter__install_pe " Riccardo Mancini
2021-08-31 19:50 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 24/37] perf evsel: handle precise_ip fallback " Riccardo Mancini
2021-08-31 19:52 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 25/37] perf evsel: move event open in evsel__open_cpu to separate function Riccardo Mancini
2021-08-31 19:54 ` Arnaldo Carvalho de Melo
2021-09-03 21:52 ` Riccardo Mancini
2021-09-11 19:10 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 26/37] perf evsel: add evsel__open_per_cpu_no_fallback function Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 27/37] perf evlist: add evlist__for_each_entry_from macro Riccardo Mancini
2021-08-31 20:06 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 28/37] perf evlist: add multithreading to evlist__open Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 29/37] perf evlist: add custom fallback " Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 30/37] perf record: use evlist__open_custom Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 31/37] tools lib/subcmd: add OPT_UINTEGER_OPTARG option type Riccardo Mancini
2021-08-31 18:44 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 32/37] perf record: add --threads option Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 33/37] perf record: pin threads to monitored cpus if enough threads available Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 34/37] perf record: apply multithreading in init and fini phases Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 35/37] perf test/evlist-open-close: add multithreading Riccardo Mancini
2021-08-21 9:19 ` [RFC PATCH v1 36/37] perf test/evlist-open-close: use inline func to convert timeval to usec Riccardo Mancini
2021-10-08 14:46 ` Arnaldo Carvalho de Melo
2021-08-21 9:19 ` [RFC PATCH v1 37/37] perf test/evlist-open-close: add detailed output mode Riccardo Mancini
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=YS6FWEf41ApoxBee@kernel.org \
--to=acme@kernel.org \
--cc=irogers@google.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=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.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;
as well as URLs for NNTP newsgroup(s).