summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/mem-info.h
blob: 0f68e29f311b94ee404f3b3bd65c8306c10ac29c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __PERF_MEM_INFO_H
#define __PERF_MEM_INFO_H

#include <linux/refcount.h>
#include <linux/perf_event.h>
#include <internal/rc_check.h>
#include "map_symbol.h"

DECLARE_RC_STRUCT(mem_info) {
	struct addr_map_symbol	iaddr;
	struct addr_map_symbol	daddr;
	union perf_mem_data_src	data_src;
	refcount_t		refcnt;
};

struct mem_info *mem_info__new(void);
struct mem_info *mem_info__get(struct mem_info *mi);
void   mem_info__put(struct mem_info *mi);

static inline void __mem_info__zput(struct mem_info **mi)
{
	mem_info__put(*mi);
	*mi = NULL;
}

#define mem_info__zput(mi) __mem_info__zput(&mi)

static inline struct addr_map_symbol *mem_info__iaddr(struct mem_info *mi)
{
	return &RC_CHK_ACCESS(mi)->iaddr;
}

static inline struct addr_map_symbol *mem_info__daddr(struct mem_info *mi)
{
	return &RC_CHK_ACCESS(mi)->daddr;
}

static inline union perf_mem_data_src *mem_info__data_src(struct mem_info *mi)
{
	return &RC_CHK_ACCESS(mi)->data_src;
}

static inline const union perf_mem_data_src *mem_info__const_data_src(const struct mem_info *mi)
{
	return &RC_CHK_ACCESS(mi)->data_src;
}

static inline refcount_t *mem_info__refcnt(struct mem_info *mi)
{
	return &RC_CHK_ACCESS(mi)->refcnt;
}

#endif /* __PERF_MEM_INFO_H */