From: Peter Zijlstra <peterz@infradead.org>
To: Like Xu <like.xu@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Jim Mattson <jmattson@google.com>,
rkrcmar@redhat.com, sean.j.christopherson@intel.com,
vkuznets@redhat.com, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
ak@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com,
like.xu@intel.com, ehankland@google.com, arbel.moshe@oracle.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/4] perf/core: Provide a kernel-internal interface to pause perf_event
Date: Mon, 14 Oct 2019 13:51:58 +0200 [thread overview]
Message-ID: <20191014115158.GC2328@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191013091533.12971-3-like.xu@linux.intel.com>
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);
next prev parent reply other threads:[~2019-10-14 11:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-13 9:15 [PATCH v2 0/4] KVM: x86/vPMU: Efficiency optimization by reusing last created perf_event Like Xu
2019-10-13 9:15 ` [PATCH v2 1/4] perf/core: Provide a kernel-internal interface to recalibrate event period Like Xu
2019-10-13 9:15 ` [PATCH v2 2/4] perf/core: Provide a kernel-internal interface to pause perf_event Like Xu
2019-10-14 11:51 ` Peter Zijlstra [this message]
2019-10-15 1:47 ` Like Xu
2019-10-13 9:15 ` [PATCH v2 3/4] KVM: x86/vPMU: Reuse perf_event to avoid unnecessary pmc_reprogram_counter Like Xu
2019-10-21 8:12 ` Paolo Bonzini
2019-10-21 8:16 ` Like Xu
2019-10-13 9:15 ` [PATCH v2 4/4] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC Like Xu
2019-10-21 8:45 ` Paolo Bonzini
2019-10-21 14:04 ` Like Xu
2019-10-21 15:28 ` Paolo Bonzini
2019-10-21 10:55 ` [PATCH] KVM: x86/vPMU: Declare kvm_pmu->reprogram_pmi field using DECLARE_BITMAP Like Xu
2019-10-22 11:40 ` Paolo Bonzini
2019-10-21 2:26 ` [PATCH v2 0/4] KVM: x86/vPMU: Efficiency optimization by reusing last created perf_event Like Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191014115158.GC2328@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=arbel.moshe@oracle.com \
--cc=ehankland@google.com \
--cc=jmattson@google.com \
--cc=kan.liang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu@intel.com \
--cc=like.xu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=vkuznets@redhat.com \
--cc=wei.w.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox