[PATCH 2/9] perf report: Remove the first overflow check for branch counters

kan.liang@linux.intel.com posted 9 patches 1 year, 7 months ago
There is a newer version of this series
[PATCH 2/9] perf report: Remove the first overflow check for branch counters
Posted by kan.liang@linux.intel.com 1 year, 7 months ago
From: Kan Liang <kan.liang@linux.intel.com>

A false overflow warning is triggered if a sample doesn't have any LBRs
recorded and the branch counters feature is enabled.

The current code does OVERFLOW_CHECK_u64() at the very beginning when
reading the information of branch counters. It assumes that there is at
least one LBR in the PEBS record. But it is a valid case that 0 LBR is
recorded especially in a high context switch.

Remove the OVERFLOW_CHECK_u64(). The later OVERFLOW_CHECK() should be
good enough to check the overflow when reading the information of the
branch counters.

Fixes: 9fbb4b02302b ("perf tools: Add branch counter knob")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/util/evsel.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bc603193c477..a5dd031c9080 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2810,8 +2810,6 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
 		array = (void *)array + sz;
 
 		if (evsel__has_branch_counters(evsel)) {
-			OVERFLOW_CHECK_u64(array);
-
 			data->branch_stack_cntr = (u64 *)array;
 			sz = data->branch_stack->nr * sizeof(u64);
 
-- 
2.38.1
Re: [PATCH 2/9] perf report: Remove the first overflow check for branch counters
Posted by Namhyung Kim 1 year, 6 months ago
On Wed, Jul 3, 2024 at 1:03 PM <kan.liang@linux.intel.com> wrote:
>
> From: Kan Liang <kan.liang@linux.intel.com>
>
> A false overflow warning is triggered if a sample doesn't have any LBRs
> recorded and the branch counters feature is enabled.
>
> The current code does OVERFLOW_CHECK_u64() at the very beginning when
> reading the information of branch counters. It assumes that there is at
> least one LBR in the PEBS record. But it is a valid case that 0 LBR is
> recorded especially in a high context switch.
>
> Remove the OVERFLOW_CHECK_u64(). The later OVERFLOW_CHECK() should be
> good enough to check the overflow when reading the information of the
> branch counters.
>
> Fixes: 9fbb4b02302b ("perf tools: Add branch counter knob")
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/util/evsel.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index bc603193c477..a5dd031c9080 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2810,8 +2810,6 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
>                 array = (void *)array + sz;
>
>                 if (evsel__has_branch_counters(evsel)) {
> -                       OVERFLOW_CHECK_u64(array);
> -
>                         data->branch_stack_cntr = (u64 *)array;
>                         sz = data->branch_stack->nr * sizeof(u64);
>
> --
> 2.38.1
>