perf tools: Add support for PERF_RECORD_TEXT_POKE
Add processing for PERF_RECORD_TEXT_POKE events. When a text poke event is processed, then the kernel dso data cache is updated with the poked bytes. 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-12-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
b39730a663
commit
246eba8e90
@@ -31,6 +31,7 @@
|
||||
#include "stat.h"
|
||||
#include "session.h"
|
||||
#include "bpf-event.h"
|
||||
#include "print_binary.h"
|
||||
#include "tool.h"
|
||||
#include "../perf.h"
|
||||
|
||||
@@ -55,6 +56,7 @@ static const char *perf_event__names[] = {
|
||||
[PERF_RECORD_KSYMBOL] = "KSYMBOL",
|
||||
[PERF_RECORD_BPF_EVENT] = "BPF_EVENT",
|
||||
[PERF_RECORD_CGROUP] = "CGROUP",
|
||||
[PERF_RECORD_TEXT_POKE] = "TEXT_POKE",
|
||||
[PERF_RECORD_HEADER_ATTR] = "ATTR",
|
||||
[PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
|
||||
[PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
|
||||
@@ -267,6 +269,14 @@ int perf_event__process_bpf(struct perf_tool *tool __maybe_unused,
|
||||
return machine__process_bpf(machine, event, sample);
|
||||
}
|
||||
|
||||
int perf_event__process_text_poke(struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct machine *machine)
|
||||
{
|
||||
return machine__process_text_poke(machine, event, sample);
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
|
||||
{
|
||||
return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 "]: %c %s\n",
|
||||
@@ -413,6 +423,40 @@ size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp)
|
||||
event->bpf.type, event->bpf.flags, event->bpf.id);
|
||||
}
|
||||
|
||||
static int text_poke_printer(enum binary_printer_ops op, unsigned int val,
|
||||
void *extra, FILE *fp)
|
||||
{
|
||||
bool old = *(bool *)extra;
|
||||
|
||||
switch ((int)op) {
|
||||
case BINARY_PRINT_LINE_BEGIN:
|
||||
return fprintf(fp, " %s bytes:", old ? "Old" : "New");
|
||||
case BINARY_PRINT_NUM_DATA:
|
||||
return fprintf(fp, " %02x", val);
|
||||
case BINARY_PRINT_LINE_END:
|
||||
return fprintf(fp, "\n");
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf_text_poke(union perf_event *event, FILE *fp)
|
||||
{
|
||||
struct perf_record_text_poke_event *tp = &event->text_poke;
|
||||
size_t ret;
|
||||
bool old;
|
||||
|
||||
ret = fprintf(fp, " %" PRI_lx64 " old len %u new len %u\n",
|
||||
tp->addr, tp->old_len, tp->new_len);
|
||||
old = true;
|
||||
ret += binary__fprintf(tp->bytes, tp->old_len, 16, text_poke_printer,
|
||||
&old, fp);
|
||||
old = false;
|
||||
ret += binary__fprintf(tp->bytes + tp->old_len, tp->new_len, 16,
|
||||
text_poke_printer, &old, fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf(union perf_event *event, FILE *fp)
|
||||
{
|
||||
size_t ret = fprintf(fp, "PERF_RECORD_%s",
|
||||
@@ -457,6 +501,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
|
||||
case PERF_RECORD_BPF_EVENT:
|
||||
ret += perf_event__fprintf_bpf(event, fp);
|
||||
break;
|
||||
case PERF_RECORD_TEXT_POKE:
|
||||
ret += perf_event__fprintf_text_poke(event, fp);
|
||||
break;
|
||||
default:
|
||||
ret += fprintf(fp, "\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user