mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
1a8c2e0177
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>
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include "util/map_symbol.h"
|
|
#include "util/mem-events.h"
|
|
#include "util/mem-info.h"
|
|
#include "util/symbol.h"
|
|
#include "linux/perf_event.h"
|
|
#include "util/debug.h"
|
|
#include "tests.h"
|
|
#include <string.h>
|
|
|
|
static int check(union perf_mem_data_src data_src,
|
|
const char *string)
|
|
{
|
|
char out[100];
|
|
char failure[100];
|
|
struct mem_info *mi = mem_info__new();
|
|
int n;
|
|
|
|
TEST_ASSERT_VAL("Memory allocation failed", mi);
|
|
*mem_info__data_src(mi) = data_src;
|
|
n = perf_mem__snp_scnprintf(out, sizeof out, mi);
|
|
n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, mi);
|
|
mem_info__put(mi);
|
|
scnprintf(failure, sizeof failure, "unexpected %s", out);
|
|
TEST_ASSERT_VAL(failure, !strcmp(string, out));
|
|
return 0;
|
|
}
|
|
|
|
static int test__mem(struct test_suite *text __maybe_unused, int subtest __maybe_unused)
|
|
{
|
|
int ret = 0;
|
|
union perf_mem_data_src src;
|
|
|
|
memset(&src, 0, sizeof(src));
|
|
|
|
src.mem_lvl = PERF_MEM_LVL_HIT;
|
|
src.mem_lvl_num = 4;
|
|
|
|
ret |= check(src, "N/AL4 hit");
|
|
|
|
src.mem_remote = 1;
|
|
|
|
ret |= check(src, "N/ARemote L4 hit");
|
|
|
|
src.mem_lvl = PERF_MEM_LVL_MISS;
|
|
src.mem_lvl_num = PERF_MEM_LVLNUM_PMEM;
|
|
src.mem_remote = 0;
|
|
|
|
ret |= check(src, "N/APMEM miss");
|
|
|
|
src.mem_remote = 1;
|
|
|
|
ret |= check(src, "N/ARemote PMEM miss");
|
|
|
|
src.mem_snoopx = PERF_MEM_SNOOPX_FWD;
|
|
src.mem_lvl_num = PERF_MEM_LVLNUM_RAM;
|
|
|
|
ret |= check(src , "FwdRemote RAM miss");
|
|
|
|
return ret;
|
|
}
|
|
|
|
DEFINE_SUITE("Test data source output", mem);
|