Re: [PATCH 4/4] perf core: Add backward attribute to perf event

From: Peter Zijlstra
Date: Tue Mar 29 2016 - 10:04:57 EST


On Mon, Mar 28, 2016 at 06:41:32AM +0000, Wang Nan wrote:

Could you maybe write a perf/tests thingy for this so that _some_
userspace exists that exercises this new code?


> int perf_output_begin(struct perf_output_handle *handle,
> struct perf_event *event, unsigned int size)
> {
> + if (unlikely(is_write_backward(event)))
> + return __perf_output_begin(handle, event, size, true);
> return __perf_output_begin(handle, event, size, false);
> }

Would something like:

int perf_output_begin(...)
{
if (unlikely(is_write_backward(event))
return perf_output_begin_backward(...);
return perf_output_begin_forward(...);
}

make sense; I'm not sure how much is still using this, but it seems
somewhat excessive to inline two copies of that thing into a single
function.

Alternatively; something like:

int perf_output_begin(...)
{
return __perf_output_begin(..., unlikely(event->attr.backwards));
}

might make sense too.