Patch "perf stat: Separate bperf from bpf_profiler" has been added to the 6.3-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf stat: Separate bperf from bpf_profiler

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-stat-separate-bperf-from-bpf_profiler.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bcd513807757f1bfdb28cf3822b9cdfb3e70fa88
Author: Dmitrii Dolgov <9erthalion6@xxxxxxxxx>
Date:   Wed Apr 12 20:23:16 2023 +0200

    perf stat: Separate bperf from bpf_profiler
    
    [ Upstream commit ecc68ee216c6c5b2f84915e1441adf436f1b019b ]
    
    It seems that perf stat -b <prog id> doesn't produce any results:
    
        $ perf stat -e cycles -b 4 -I 10000 -vvv
        Control descriptor is not initialized
        cycles: 0 0 0
                    time        counts unit      events
            10.007641640    <not supported>      cycles
    
    Looks like this happens because fentry/fexit progs are getting loaded, but the
    corresponding perf event is not enabled and not added into the events bpf map.
    I think there is some mixing up between two type of bpf support, one for bperf
    and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
    perf events are enabled, but for the latter (bpf_profiler) a perf event is
    required. Using evsel__is_bperf to check only bperf produces expected results:
    
        $ perf stat -e cycles -b 4 -I 10000 -vvv
        Control descriptor is not initialized
        ------------------------------------------------------------
        perf_event_attr:
          size                             136
          sample_type                      IDENTIFIER
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          exclude_guest                    1
        ------------------------------------------------------------
        sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 3
        ------------------------------------------------------------
        [...perf_event_attr for other CPUs...]
        ------------------------------------------------------------
        cycles: 309426 169009 169009
                    time             counts unit events
            10.010091271             309426      cycles
    
    The final numbers correspond (at least in the level of magnitude) to the
    same metric obtained via bpftool.
    
    Fixes: 112cb56164bc2108 ("perf stat: Introduce config stat.bpf-counter-events")
    Reviewed-by: Song Liu <song@xxxxxxxxxx>
    Signed-off-by: Dmitrii Dolgov <9erthalion6@xxxxxxxxx>
    Tested-by: Song Liu <song@xxxxxxxxxx>
    Cc: Ian Rogers <irogers@xxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
    Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
    Cc: Song Liu <song@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230412182316.11628-1-9erthalion6@xxxxxxxxx
    Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index fa7c40956d0fa..eeba93ae3b584 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -773,7 +773,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 		counter->reset_group = false;
 		if (bpf_counter__load(counter, &target))
 			return -1;
-		if (!evsel__is_bpf(counter))
+		if (!(evsel__is_bperf(counter)))
 			all_counters_use_bpf = false;
 	}
 
@@ -789,7 +789,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 
 		if (counter->reset_group || counter->errored)
 			continue;
-		if (evsel__is_bpf(counter))
+		if (evsel__is_bperf(counter))
 			continue;
 try_again:
 		if (create_perf_stat_counter(counter, &stat_config, &target,
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 24cb807ef6ce0..1a7358b46ad4e 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -267,6 +267,11 @@ static inline bool evsel__is_bpf(struct evsel *evsel)
 	return evsel->bpf_counter_ops != NULL;
 }
 
+static inline bool evsel__is_bperf(struct evsel *evsel)
+{
+	return evsel->bpf_counter_ops != NULL && list_empty(&evsel->bpf_counter_list);
+}
+
 #define EVSEL__MAX_ALIASES 8
 
 extern const char *const evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES];



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux