2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 11:44:01 +08:00
linux-next/tools/perf/tests/mem.c
Arnaldo Carvalho de Melo d3300a3c4e perf symbols: Move mem_info and branch_info out of symbol.h
The mem_info struct goes to mem-events.h and branch_info goes to
branch.h, where they belong, this way we can remove several headers from
symbols.h and trim the include dependency tree more.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-aupw71xnravcsu2xoabfmhpc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-08-31 22:27:48 -03:00

59 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0
#include "util/map_symbol.h"
#include "util/mem-events.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 = { .data_src = data_src };
int n;
n = perf_mem__snp_scnprintf(out, sizeof out, &mi);
n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi);
scnprintf(failure, sizeof failure, "unexpected %s", out);
TEST_ASSERT_VAL(failure, !strcmp(string, out));
return 0;
}
int test__mem(struct test *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;
}