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

perf block-info: Remove unused refcount

block_info__get() has no callers so the refcount is only ever one. As
such remove the reference counting logic and turn puts to deletes.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ben Gainey <ben.gainey@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Li Dong <lidong@vivo.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Paran Lee <p4ranlee@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sun Haiyong <sunhaiyong@loongson.cn>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20240507183545.1236093-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
557b32c3 a3f7768b

+9 -34
+6 -18
tools/perf/util/block-info.c
··· 43 43 } 44 44 }; 45 45 46 - struct block_info *block_info__get(struct block_info *bi) 47 - { 48 - if (bi) 49 - refcount_inc(&bi->refcnt); 50 - return bi; 51 - } 52 - 53 - void block_info__put(struct block_info *bi) 54 - { 55 - if (bi && refcount_dec_and_test(&bi->refcnt)) 56 - free(bi); 57 - } 58 - 59 46 struct block_info *block_info__new(void) 60 47 { 61 - struct block_info *bi = zalloc(sizeof(*bi)); 48 + return zalloc(sizeof(struct block_info)); 49 + } 62 50 63 - if (bi) 64 - refcount_set(&bi->refcnt, 1); 65 - return bi; 51 + void block_info__delete(struct block_info *bi) 52 + { 53 + free(bi); 66 54 } 67 55 68 56 int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right) ··· 136 148 he_block = hists__add_entry_block(&bh->block_hists, 137 149 &al, bi); 138 150 if (!he_block) { 139 - block_info__put(bi); 151 + block_info__delete(bi); 140 152 return -1; 141 153 } 142 154 }
+1 -14
tools/perf/util/block-info.h
··· 3 3 #define __PERF_BLOCK_H 4 4 5 5 #include <linux/types.h> 6 - #include <linux/refcount.h> 7 6 #include "hist.h" 8 7 #include "symbol.h" 9 8 #include "sort.h" ··· 18 19 u64 total_cycles; 19 20 int num; 20 21 int num_aggr; 21 - refcount_t refcnt; 22 22 }; 23 23 24 24 struct block_fmt { ··· 46 48 int nr_fmts; 47 49 }; 48 50 49 - struct block_hist; 50 - 51 51 struct block_info *block_info__new(void); 52 - struct block_info *block_info__get(struct block_info *bi); 53 - void block_info__put(struct block_info *bi); 54 - 55 - static inline void __block_info__zput(struct block_info **bi) 56 - { 57 - block_info__put(*bi); 58 - *bi = NULL; 59 - } 60 - 61 - #define block_info__zput(bi) __block_info__zput(&bi) 52 + void block_info__delete(struct block_info *bi); 62 53 63 54 int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right); 64 55
+2 -2
tools/perf/util/hist.c
··· 631 631 */ 632 632 mem_info__zput(entry->mem_info); 633 633 634 - block_info__zput(entry->block_info); 634 + block_info__delete(entry->block_info); 635 635 636 636 kvm_info__zput(entry->kvm_info); 637 637 ··· 1341 1341 } 1342 1342 1343 1343 if (he->block_info) 1344 - block_info__zput(he->block_info); 1344 + block_info__delete(he->block_info); 1345 1345 1346 1346 if (he->kvm_info) 1347 1347 kvm_info__zput(he->kvm_info);