Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf callchain: Make display use of branch_type_stat const

Display code doesn't modify the branch_type_stat so switch uses to
const. This is done to aid refactoring struct callchain_list where
current the branch_type_stat is embedded even if not used.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: James Clark <james.clark@arm.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: liuwenyu <liuwenyu7@huawei.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lore.kernel.org/r/20231024222353.3024098-9-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
d47d876d 67a3ebf1

+7 -7
+2 -2
tools/perf/util/branch.c
··· 109 109 return branch_type_name(e->flags.type); 110 110 } 111 111 112 - void branch_type_stat_display(FILE *fp, struct branch_type_stat *st) 112 + void branch_type_stat_display(FILE *fp, const struct branch_type_stat *st) 113 113 { 114 114 u64 total = 0; 115 115 int i; ··· 171 171 return scnprintf(bf, size, "%s%s", (idx) ? " " : " (", str); 172 172 } 173 173 174 - int branch_type_str(struct branch_type_stat *st, char *bf, int size) 174 + int branch_type_str(const struct branch_type_stat *st, char *bf, int size) 175 175 { 176 176 int i, j = 0, printed = 0; 177 177 u64 total = 0;
+2 -2
tools/perf/util/branch.h
··· 86 86 const char *branch_type_name(int type); 87 87 const char *branch_new_type_name(int new_type); 88 88 const char *get_branch_type(struct branch_entry *e); 89 - void branch_type_stat_display(FILE *fp, struct branch_type_stat *st); 90 - int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize); 89 + void branch_type_stat_display(FILE *fp, const struct branch_type_stat *st); 90 + int branch_type_str(const struct branch_type_stat *st, char *bf, int bfsize); 91 91 92 92 const char *branch_spec_desc(int spec); 93 93
+3 -3
tools/perf/util/callchain.c
··· 1339 1339 static int branch_to_str(char *bf, int bfsize, 1340 1340 u64 branch_count, u64 predicted_count, 1341 1341 u64 abort_count, 1342 - struct branch_type_stat *brtype_stat) 1342 + const struct branch_type_stat *brtype_stat) 1343 1343 { 1344 1344 int printed, i = 0; 1345 1345 ··· 1403 1403 u64 abort_count, u64 cycles_count, 1404 1404 u64 iter_count, u64 iter_cycles, 1405 1405 u64 from_count, 1406 - struct branch_type_stat *brtype_stat) 1406 + const struct branch_type_stat *brtype_stat) 1407 1407 { 1408 1408 int printed; 1409 1409 ··· 1430 1430 u64 abort_count, u64 cycles_count, 1431 1431 u64 iter_count, u64 iter_cycles, 1432 1432 u64 from_count, 1433 - struct branch_type_stat *brtype_stat) 1433 + const struct branch_type_stat *brtype_stat) 1434 1434 { 1435 1435 char str[256]; 1436 1436