Skip to content

Commit 557b32c

Browse files
captain5050acmel
authored andcommitted
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Ben Gainey <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Li Dong <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Paran Lee <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sun Haiyong <[email protected]> Cc: Tim Chen <[email protected]> Cc: Yanteng Si <[email protected]> Cc: Yicong Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a3f7768 commit 557b32c

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

tools/perf/util/block-info.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,14 @@ static struct block_header_column {
4343
}
4444
};
4545

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)
46+
struct block_info *block_info__new(void)
5447
{
55-
if (bi && refcount_dec_and_test(&bi->refcnt))
56-
free(bi);
48+
return zalloc(sizeof(struct block_info));
5749
}
5850

59-
struct block_info *block_info__new(void)
51+
void block_info__delete(struct block_info *bi)
6052
{
61-
struct block_info *bi = zalloc(sizeof(*bi));
62-
63-
if (bi)
64-
refcount_set(&bi->refcnt, 1);
65-
return bi;
53+
free(bi);
6654
}
6755

6856
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right)
@@ -148,7 +136,7 @@ int block_info__process_sym(struct hist_entry *he, struct block_hist *bh,
148136
he_block = hists__add_entry_block(&bh->block_hists,
149137
&al, bi);
150138
if (!he_block) {
151-
block_info__put(bi);
139+
block_info__delete(bi);
152140
return -1;
153141
}
154142
}

tools/perf/util/block-info.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define __PERF_BLOCK_H
44

55
#include <linux/types.h>
6-
#include <linux/refcount.h>
76
#include "hist.h"
87
#include "symbol.h"
98
#include "sort.h"
@@ -19,7 +18,6 @@ struct block_info {
1918
u64 total_cycles;
2019
int num;
2120
int num_aggr;
22-
refcount_t refcnt;
2321
};
2422

2523
struct block_fmt {
@@ -48,19 +46,8 @@ struct block_report {
4846
int nr_fmts;
4947
};
5048

51-
struct block_hist;
52-
5349
struct block_info *block_info__new(void);
54-
struct block_info *block_info__get(struct block_info *bi);
55-
void block_info__put(struct block_info *bi);
56-
57-
static inline void __block_info__zput(struct block_info **bi)
58-
{
59-
block_info__put(*bi);
60-
*bi = NULL;
61-
}
62-
63-
#define block_info__zput(bi) __block_info__zput(&bi)
50+
void block_info__delete(struct block_info *bi);
6451

6552
int64_t __block_info__cmp(struct hist_entry *left, struct hist_entry *right);
6653

tools/perf/util/hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
631631
*/
632632
mem_info__zput(entry->mem_info);
633633

634-
block_info__zput(entry->block_info);
634+
block_info__delete(entry->block_info);
635635

636636
kvm_info__zput(entry->kvm_info);
637637

@@ -1341,7 +1341,7 @@ void hist_entry__delete(struct hist_entry *he)
13411341
}
13421342

13431343
if (he->block_info)
1344-
block_info__zput(he->block_info);
1344+
block_info__delete(he->block_info);
13451345

13461346
if (he->kvm_info)
13471347
kvm_info__zput(he->kvm_info);

0 commit comments

Comments
 (0)