Re: [PATCH V3 2/4] perf tools: Add new PERF_RECORD_SWITCH event

From: Arnaldo Carvalho de Melo
Date: Tue Jul 07 2015 - 09:50:49 EST


Em Tue, Jul 07, 2015 at 11:36:40AM +0300, Adrian Hunter escreveu:
> +size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
> +{
> + bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
> + const char *in_out = out ? "OUT" : "IN ";
> +
> + if (event->context_switch.next_prev_pid == (u32)-1)

I.e. we would have the test:

if (!(event->header.misc & PERF_RECORD_MISC_SWITCH_NEXT_PREV_PID))
return fprintf(fp, " %s\n", in_out);

> + return fprintf(fp, " %s %s pid/tid: %5u/%-5u\n",
> + in_out, out ? "next" : "prev",
> + event->context_switch.next_prev_pid,
> + event->context_switch.next_prev_tid);


<SNIP>

> +static void perf_event__switch_swap(union perf_event *event, bool sample_id_all)
> +{

Here too:

if (event->header.misc & PERF_RECORD_MISC_SWITCH_NEXT_PREV_PID) {
event->context_switch.next_prev_pid = bswap_32(event->context_switch.next_prev_pid);
event->context_switch.next_prev_tid = bswap_32(event->context_switch.next_prev_tid);
if (sample_id_all)
swap_sample_id_all(event, &event->context_switch + 1);
} else if (sample_id_all)
swap_sample_id_all(event, &event->header + 1);
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/