Commit 789e2419 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf tools: Add support for PERF_RECORD_KSYMBOL_TYPE_OOL

PERF_RECORD_KSYMBOL_TYPE_OOL marks an executable page. Create a map
backed only by memory, which will be populated as necessary by text poke
events.

Committer notes:

From the patch:

OOL stands for "Out of line" code such as kprobe-replaced instructions
or optimized kprobes or ftrace trampolines.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: x86@kernel.org
Link: http://lore.kernel.org/lkml/20200512121922.8997-13-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 246eba8e
...@@ -1049,6 +1049,11 @@ enum perf_event_type { ...@@ -1049,6 +1049,11 @@ enum perf_event_type {
enum perf_record_ksymbol_type { enum perf_record_ksymbol_type {
PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0, PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0,
PERF_RECORD_KSYMBOL_TYPE_BPF = 1, PERF_RECORD_KSYMBOL_TYPE_BPF = 1,
/*
* Out of line code such as kprobe-replaced instructions or optimized
* kprobes or ftrace trampolines.
*/
PERF_RECORD_KSYMBOL_TYPE_OOL = 2,
PERF_RECORD_KSYMBOL_TYPE_MAX /* non-ABI */ PERF_RECORD_KSYMBOL_TYPE_MAX /* non-ABI */
}; };
......
...@@ -208,6 +208,7 @@ int dso__read_binary_type_filename(const struct dso *dso, ...@@ -208,6 +208,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
case DSO_BINARY_TYPE__JAVA_JIT: case DSO_BINARY_TYPE__JAVA_JIT:
case DSO_BINARY_TYPE__BPF_PROG_INFO: case DSO_BINARY_TYPE__BPF_PROG_INFO:
case DSO_BINARY_TYPE__BPF_IMAGE: case DSO_BINARY_TYPE__BPF_IMAGE:
case DSO_BINARY_TYPE__OOL:
case DSO_BINARY_TYPE__NOT_FOUND: case DSO_BINARY_TYPE__NOT_FOUND:
ret = -1; ret = -1;
break; break;
...@@ -898,6 +899,8 @@ static struct dso_cache *dso_cache__populate(struct dso *dso, ...@@ -898,6 +899,8 @@ static struct dso_cache *dso_cache__populate(struct dso *dso,
if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO) if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
*ret = bpf_read(dso, cache_offset, cache->data); *ret = bpf_read(dso, cache_offset, cache->data);
else if (dso->binary_type == DSO_BINARY_TYPE__OOL)
*ret = DSO__DATA_CACHE_SIZE;
else else
*ret = file_read(dso, machine, cache_offset, cache->data); *ret = file_read(dso, machine, cache_offset, cache->data);
......
...@@ -42,6 +42,7 @@ enum dso_binary_type { ...@@ -42,6 +42,7 @@ enum dso_binary_type {
DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO, DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
DSO_BINARY_TYPE__BPF_PROG_INFO, DSO_BINARY_TYPE__BPF_PROG_INFO,
DSO_BINARY_TYPE__BPF_IMAGE, DSO_BINARY_TYPE__BPF_IMAGE,
DSO_BINARY_TYPE__OOL,
DSO_BINARY_TYPE__NOT_FOUND, DSO_BINARY_TYPE__NOT_FOUND,
}; };
......
...@@ -762,6 +762,12 @@ static int machine__process_ksymbol_register(struct machine *machine, ...@@ -762,6 +762,12 @@ static int machine__process_ksymbol_register(struct machine *machine,
return -ENOMEM; return -ENOMEM;
} }
if (event->ksymbol.ksym_type == PERF_RECORD_KSYMBOL_TYPE_OOL) {
map->dso->binary_type = DSO_BINARY_TYPE__OOL;
map->dso->data.file_size = event->ksymbol.len;
dso__set_loaded(map->dso);
}
map->start = event->ksymbol.addr; map->start = event->ksymbol.addr;
map->end = map->start + event->ksymbol.len; map->end = map->start + event->ksymbol.len;
maps__insert(&machine->kmaps, map); maps__insert(&machine->kmaps, map);
......
...@@ -267,6 +267,11 @@ bool __map__is_bpf_prog(const struct map *map) ...@@ -267,6 +267,11 @@ bool __map__is_bpf_prog(const struct map *map)
return name && (strstr(name, "bpf_prog_") == name); return name && (strstr(name, "bpf_prog_") == name);
} }
bool __map__is_ool(const struct map *map)
{
return map->dso && map->dso->binary_type == DSO_BINARY_TYPE__OOL;
}
bool map__has_symbols(const struct map *map) bool map__has_symbols(const struct map *map)
{ {
return dso__has_symbols(map->dso); return dso__has_symbols(map->dso);
......
...@@ -147,11 +147,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, ...@@ -147,11 +147,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
bool __map__is_kernel(const struct map *map); bool __map__is_kernel(const struct map *map);
bool __map__is_extra_kernel_map(const struct map *map); bool __map__is_extra_kernel_map(const struct map *map);
bool __map__is_bpf_prog(const struct map *map); bool __map__is_bpf_prog(const struct map *map);
bool __map__is_ool(const struct map *map);
static inline bool __map__is_kmodule(const struct map *map) static inline bool __map__is_kmodule(const struct map *map)
{ {
return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) && return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
!__map__is_bpf_prog(map); !__map__is_bpf_prog(map) && !__map__is_ool(map);
} }
bool map__has_symbols(const struct map *map); bool map__has_symbols(const struct map *map);
......
...@@ -1565,6 +1565,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod, ...@@ -1565,6 +1565,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
case DSO_BINARY_TYPE__BPF_PROG_INFO: case DSO_BINARY_TYPE__BPF_PROG_INFO:
case DSO_BINARY_TYPE__BPF_IMAGE: case DSO_BINARY_TYPE__BPF_IMAGE:
case DSO_BINARY_TYPE__OOL:
case DSO_BINARY_TYPE__NOT_FOUND: case DSO_BINARY_TYPE__NOT_FOUND:
default: default:
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment