perf callchain: Make display use of branch_type_stat const
authorIan Rogers <irogers@google.com>
Tue, 24 Oct 2023 22:23:11 +0000 (15:23 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 25 Oct 2023 20:38:50 +0000 (13:38 -0700)
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>
tools/perf/util/branch.c
tools/perf/util/branch.h
tools/perf/util/callchain.c

index 378f16a247511820ea93d0c13a6c5c14ced0e73e..ab760e267d41039f1a615d3f7e88917533db7905 100644 (file)
@@ -109,7 +109,7 @@ const char *get_branch_type(struct branch_entry *e)
        return branch_type_name(e->flags.type);
 }
 
-void branch_type_stat_display(FILE *fp, struct branch_type_stat *st)
+void branch_type_stat_display(FILE *fp, const struct branch_type_stat *st)
 {
        u64 total = 0;
        int i;
@@ -171,7 +171,7 @@ static int count_str_scnprintf(int idx, const char *str, char *bf, int size)
        return scnprintf(bf, size, "%s%s", (idx) ? " " : " (", str);
 }
 
-int branch_type_str(struct branch_type_stat *st, char *bf, int size)
+int branch_type_str(const struct branch_type_stat *st, char *bf, int size)
 {
        int i, j = 0, printed = 0;
        u64 total = 0;
index e41bfffe22170b076b9f52096bc9b1ff27d463b4..87704d713ff64454efcda339862a3b165b037b9d 100644 (file)
@@ -86,8 +86,8 @@ void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
 const char *branch_type_name(int type);
 const char *branch_new_type_name(int new_type);
 const char *get_branch_type(struct branch_entry *e);
-void branch_type_stat_display(FILE *fp, struct branch_type_stat *st);
-int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize);
+void branch_type_stat_display(FILE *fp, const struct branch_type_stat *st);
+int branch_type_str(const struct branch_type_stat *st, char *bf, int bfsize);
 
 const char *branch_spec_desc(int spec);
 
index 18d545c0629ec6a1a08bcbed37d8758396f423c1..cde4860e6f2817a0294ef8095e9e82356d19e40a 100644 (file)
@@ -1339,7 +1339,7 @@ static int count_float_printf(int idx, const char *str, float value,
 static int branch_to_str(char *bf, int bfsize,
                         u64 branch_count, u64 predicted_count,
                         u64 abort_count,
-                        struct branch_type_stat *brtype_stat)
+                        const struct branch_type_stat *brtype_stat)
 {
        int printed, i = 0;
 
@@ -1403,7 +1403,7 @@ static int counts_str_build(char *bf, int bfsize,
                             u64 abort_count, u64 cycles_count,
                             u64 iter_count, u64 iter_cycles,
                             u64 from_count,
-                            struct branch_type_stat *brtype_stat)
+                            const struct branch_type_stat *brtype_stat)
 {
        int printed;
 
@@ -1430,7 +1430,7 @@ static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
                                   u64 abort_count, u64 cycles_count,
                                   u64 iter_count, u64 iter_cycles,
                                   u64 from_count,
-                                  struct branch_type_stat *brtype_stat)
+                                  const struct branch_type_stat *brtype_stat)
 {
        char str[256];