summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/mem-info.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:17:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:17:52 +0000
commit3afb00d3f86d3d924f88b56fa8285d4e9db85852 (patch)
tree95a985d3019522cea546b7d8df621369bc44fc6c /tools/perf/util/mem-info.c
parentAdding debian version 6.9.12-1. (diff)
downloadlinux-3afb00d3f86d3d924f88b56fa8285d4e9db85852.tar.xz
linux-3afb00d3f86d3d924f88b56fa8285d4e9db85852.zip
Merging upstream version 6.10.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/perf/util/mem-info.c')
-rw-r--r--tools/perf/util/mem-info.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/perf/util/mem-info.c b/tools/perf/util/mem-info.c
new file mode 100644
index 0000000000..27d67721a6
--- /dev/null
+++ b/tools/perf/util/mem-info.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/zalloc.h>
+#include "mem-info.h"
+
+struct mem_info *mem_info__get(struct mem_info *mi)
+{
+ struct mem_info *result;
+
+ if (RC_CHK_GET(result, mi))
+ refcount_inc(mem_info__refcnt(mi));
+
+ return result;
+}
+
+void mem_info__put(struct mem_info *mi)
+{
+ if (mi && refcount_dec_and_test(mem_info__refcnt(mi))) {
+ addr_map_symbol__exit(mem_info__iaddr(mi));
+ addr_map_symbol__exit(mem_info__daddr(mi));
+ RC_CHK_FREE(mi);
+ } else {
+ RC_CHK_PUT(mi);
+ }
+}
+
+struct mem_info *mem_info__new(void)
+{
+ struct mem_info *result = NULL;
+ RC_STRUCT(mem_info) *mi = zalloc(sizeof(*mi));
+
+ if (ADD_RC_CHK(result, mi))
+ refcount_set(mem_info__refcnt(result), 1);
+
+ return result;
+}