mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-25 19:42:19 +00:00
perf annotate: Save branch counters for each block
When annotating a basic block, it's useful to display the occurrences of other events in the block. The branch counter feature is only available for newer Intel platforms. So a dedicated option to display the branch counters is not introduced. Reuse the existing --total-cycles option, which triggers the annotation of a basic block and displays the cycle-related annotation. When the branch counters information is available, the branch counters are automatically appended after all the cycle-related annotation. Accounting the branch counters as well when accounting the cycles in hist__account_cycles(). In 'struct annotated_branch', introduce a br_cntr array to save the accumulation of each branch counter. In a sample, all the branch counters for a branch are saved in a u64 space. Because the saturation of a branch counter is small, e.g., for Intel Sierra Forest, the saturation is only 3. Add ANNOTATION__BR_CNTR_SATURATED_FLAG to indicate if a branch counter once saturated. That can be used to indicate a potential event lost because of the saturation. Reviewed-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: https://lore.kernel.org/r/20240813160208.2493643-5-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
3a867a6dad
commit
1f2b7fbb04
@@ -14,6 +14,7 @@
|
||||
#include "spark.h"
|
||||
#include "hashmap.h"
|
||||
#include "disasm.h"
|
||||
#include "branch.h"
|
||||
|
||||
struct hist_browser_timer;
|
||||
struct hist_entry;
|
||||
@@ -288,6 +289,9 @@ struct annotated_source {
|
||||
struct annotation_line *annotated_source__get_line(struct annotated_source *src,
|
||||
s64 offset);
|
||||
|
||||
/* A branch counter once saturated */
|
||||
#define ANNOTATION__BR_CNTR_SATURATED_FLAG (1ULL << 63)
|
||||
|
||||
/**
|
||||
* struct annotated_branch - basic block and IPC information for a symbol.
|
||||
*
|
||||
@@ -297,6 +301,7 @@ struct annotation_line *annotated_source__get_line(struct annotated_source *src,
|
||||
* @cover_insn: Number of distinct, actually executed instructions.
|
||||
* @cycles_hist: Array of cyc_hist for each instruction.
|
||||
* @max_coverage: Maximum number of covered basic block (used for block-range).
|
||||
* @br_cntr: Array of the occurrences of events (branch counters) during a block.
|
||||
*
|
||||
* This struct is used by two different codes when the sample has branch stack
|
||||
* and cycles information. annotation__compute_ipc() calculates average IPC
|
||||
@@ -313,6 +318,7 @@ struct annotated_branch {
|
||||
unsigned int cover_insn;
|
||||
struct cyc_hist *cycles_hist;
|
||||
u64 max_coverage;
|
||||
u64 *br_cntr;
|
||||
};
|
||||
|
||||
struct LOCKABLE annotation {
|
||||
@@ -383,7 +389,9 @@ struct annotated_branch *annotation__get_branch(struct annotation *notes);
|
||||
|
||||
int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
|
||||
struct addr_map_symbol *start,
|
||||
unsigned cycles);
|
||||
unsigned cycles,
|
||||
struct evsel *evsel,
|
||||
u64 br_cntr);
|
||||
|
||||
int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
|
||||
struct evsel *evsel, u64 addr);
|
||||
|
||||
Reference in New Issue
Block a user