On Sun, Oct 13, 2019 at 05:15:31PM +0800, Like Xu wrote:
> Exporting perf_event_pause() as an external accessor for kernel users (such
> as KVM) who may do both disable perf_event and read count with just one
> time to hold perf_event_ctx_lock. Also the value could be reset optionally.

> +u64 perf_event_pause(struct perf_event *event, bool reset)
> +{
> +     struct perf_event_context *ctx;
> +     u64 count, enabled, running;
> +
> +     ctx = perf_event_ctx_lock(event);

> +     _perf_event_disable(event);
> +     count = __perf_event_read_value(event, &enabled, &running);
> +     if (reset)
> +             local64_set(&event->count, 0);

This local64_set() already assumes there are no child events, so maybe
write the thing like:

        WARN_ON_ONCE(event->attr.inherit);
        _perf_event_disable(event);
        count = local64_read(&event->count);
        local64_set(&event->count, 0);


> +     perf_event_ctx_unlock(event, ctx);
> +
> +     return count;
> +}
> +EXPORT_SYMBOL_GPL(perf_event_pause);

Reply via email to