Skip to content

Commit 789e241

Browse files
ahunter6acmel
authored andcommitted
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: Adrian 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.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 246eba8 commit 789e241

7 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎tools/include/uapi/linux/perf_event.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,11 @@ enum perf_event_type {
10491049
enum perf_record_ksymbol_type {
10501050
PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0,
10511051
PERF_RECORD_KSYMBOL_TYPE_BPF = 1,
1052+
/*
1053+
* Out of line code such as kprobe-replaced instructions or optimized
1054+
* kprobes or ftrace trampolines.
1055+
*/
1056+
PERF_RECORD_KSYMBOL_TYPE_OOL = 2,
10521057
PERF_RECORD_KSYMBOL_TYPE_MAX /* non-ABI */
10531058
};
10541059

‎tools/perf/util/dso.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
208208
case DSO_BINARY_TYPE__JAVA_JIT:
209209
case DSO_BINARY_TYPE__BPF_PROG_INFO:
210210
case DSO_BINARY_TYPE__BPF_IMAGE:
211+
case DSO_BINARY_TYPE__OOL:
211212
case DSO_BINARY_TYPE__NOT_FOUND:
212213
ret = -1;
213214
break;
@@ -898,6 +899,8 @@ static struct dso_cache *dso_cache__populate(struct dso *dso,
898899

899900
if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
900901
*ret = bpf_read(dso, cache_offset, cache->data);
902+
else if (dso->binary_type == DSO_BINARY_TYPE__OOL)
903+
*ret = DSO__DATA_CACHE_SIZE;
901904
else
902905
*ret = file_read(dso, machine, cache_offset, cache->data);
903906

‎tools/perf/util/dso.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum dso_binary_type {
4242
DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
4343
DSO_BINARY_TYPE__BPF_PROG_INFO,
4444
DSO_BINARY_TYPE__BPF_IMAGE,
45+
DSO_BINARY_TYPE__OOL,
4546
DSO_BINARY_TYPE__NOT_FOUND,
4647
};
4748

‎tools/perf/util/machine.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,12 @@ static int machine__process_ksymbol_register(struct machine *machine,
762762
return -ENOMEM;
763763
}
764764

765+
if (event->ksymbol.ksym_type == PERF_RECORD_KSYMBOL_TYPE_OOL) {
766+
map->dso->binary_type = DSO_BINARY_TYPE__OOL;
767+
map->dso->data.file_size = event->ksymbol.len;
768+
dso__set_loaded(map->dso);
769+
}
770+
765771
map->start = event->ksymbol.addr;
766772
map->end = map->start + event->ksymbol.len;
767773
maps__insert(&machine->kmaps, map);

‎tools/perf/util/map.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ bool __map__is_bpf_prog(const struct map *map)
267267
return name && (strstr(name, "bpf_prog_") == name);
268268
}
269269

270+
bool __map__is_ool(const struct map *map)
271+
{
272+
return map->dso && map->dso->binary_type == DSO_BINARY_TYPE__OOL;
273+
}
274+
270275
bool map__has_symbols(const struct map *map)
271276
{
272277
return dso__has_symbols(map->dso);

‎tools/perf/util/map.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
147147
bool __map__is_kernel(const struct map *map);
148148
bool __map__is_extra_kernel_map(const struct map *map);
149149
bool __map__is_bpf_prog(const struct map *map);
150+
bool __map__is_ool(const struct map *map);
150151

151152
static inline bool __map__is_kmodule(const struct map *map)
152153
{
153154
return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
154-
!__map__is_bpf_prog(map);
155+
!__map__is_bpf_prog(map) && !__map__is_ool(map);
155156
}
156157

157158
bool map__has_symbols(const struct map *map);

‎tools/perf/util/symbol.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
15651565

15661566
case DSO_BINARY_TYPE__BPF_PROG_INFO:
15671567
case DSO_BINARY_TYPE__BPF_IMAGE:
1568+
case DSO_BINARY_TYPE__OOL:
15681569
case DSO_BINARY_TYPE__NOT_FOUND:
15691570
default:
15701571
return false;

0 commit comments

Comments
 (0)