1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/tools/perf/util/mem-info.h
Ian Rogers 1a8c2e0177 perf mem-info: Add reference count checking
Add reference count checking and switch 'struct mem_info' usage to use
accessor functions.

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-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-05-07 18:06:44 -03:00

54 lines
1.2 KiB
C

/* 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 */