lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 Oct 2019 13:51:58 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Like Xu <like.xu@...ux.intel.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
        Jim Mattson <jmattson@...gle.com>, rkrcmar@...hat.com,
        sean.j.christopherson@...el.com, vkuznets@...hat.com,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        ak@...ux.intel.com, wei.w.wang@...el.com, kan.liang@...el.com,
        like.xu@...el.com, ehankland@...gle.com, arbel.moshe@...cle.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/4] perf/core: Provide a kernel-internal interface to
 pause perf_event

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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ