Re: [PATCH] perf sched: parse task state from tracepoint print format

From: Steven Rostedt
Date: Fri Aug 11 2023 - 13:28:24 EST


On Thu, 10 Aug 2023 01:50:24 -0400
Ze Gao <zegao2021@xxxxxxxxx> wrote:

> Hi Steven,
>
> I managed to build task state char map dynamically by parsing
> the tracepoint print format from data recorded by perf. And
> likewise for libtraceevent.
>
> FYI, I tried TEP_PRINT_INFO but no shot. It turns out TEP_PRINT_INFO
> stills relies on libtraceevent (i.e., sched_switch_handler() in
> plugin_sched_switch.c) and we need to parse the print format on our own.

There is a way to unload plugins:

tep_unload_plugins(t->plugin_list, tep);

Hmm, I should add:

tep_unload_plugin(tep, t->plugin_list, "plugin-name");

To unload a single plugin.

I it can also just override what the plugin does by calling:

static int sched_switch_handler(struct trace_seq *s,
struct tep_record *record,
struct tep_event *event, void *context)
{
// do whatever you want.
}

tep_register_event_handler(tep, -1, "sched", "sched_switch",
sched_switch_handler, NULL);

>
> Anyway, it works now and I've tested on some perf.data in old formats
> but not cover all the kernel releases.
>
> Thoughts?

I don't maintain the perf code. You'll have to talk with the perf
maintainers.

-- Steve