mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-12-24 20:18:56 +00:00
Move mem-info to its own header rather than having it split between mem-events and symbol. 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-7-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
29 lines
514 B
C
29 lines
514 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/zalloc.h>
|
|
#include "mem-info.h"
|
|
|
|
struct mem_info *mem_info__get(struct mem_info *mi)
|
|
{
|
|
if (mi)
|
|
refcount_inc(&mi->refcnt);
|
|
return mi;
|
|
}
|
|
|
|
void mem_info__put(struct mem_info *mi)
|
|
{
|
|
if (mi && refcount_dec_and_test(&mi->refcnt)) {
|
|
addr_map_symbol__exit(&mi->iaddr);
|
|
addr_map_symbol__exit(&mi->daddr);
|
|
free(mi);
|
|
}
|
|
}
|
|
|
|
struct mem_info *mem_info__new(void)
|
|
{
|
|
struct mem_info *mi = zalloc(sizeof(*mi));
|
|
|
|
if (mi)
|
|
refcount_set(&mi->refcnt, 1);
|
|
return mi;
|
|
}
|