On 2015/10/26 20:32, Peter Zijlstra wrote:
On Sun, Oct 25, 2015 at 09:23:36AM -0700, Alexei Starovoitov wrote:In our real usecase we simply treat return value larger than
bpf_perf_event_read() muxes of -EINVAL into return value, but it's nonHow can that be, the (u64)-EINVAL value is a valid counter value..
ambiguous to the program whether it got an error or real counter value.
unlikely maybe, but still quite possible.
as error result. We can make it even larger, for example, to
Resuling values can be pre-processed by a script to filter potential
out so it is not a very big problem for our real usecases.
For a better interface, I suggest
u64 bpf_perf_event_read(bool *perror);
which still returns counter value through its return value but put error
to stack. Then BPF program can pass NULL to the function if BPF problem
doesn't want to deal with error code.