From: Like Xu <like.xu@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
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: Tue, 15 Oct 2019 09:47:41 +0800 [thread overview]
Message-ID: <1aa1fa7e-6d06-3ab0-f9f9-9e90c9c0921c@linux.intel.com> (raw)
In-Reply-To: <20191014115158.GC2328@hirez.programming.kicks-ass.net>
On 2019/10/14 19:51, Peter Zijlstra wrote:
> 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);
>
Thanks. It looks good to me and I will apply this.
>
>> + perf_event_ctx_unlock(event, ctx);
>> +
>> + return count;
>> +}
>> +EXPORT_SYMBOL_GPL(perf_event_pause);
>
next prev parent reply other threads:[~2019-10-15 1:47 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
2019-10-15 1:47 ` Like Xu [this message]
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=1aa1fa7e-6d06-3ab0-f9f9-9e90c9c0921c@linux.intel.com \
--to=like.xu@linux.intel.com \
--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=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--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
all inboxes | Powered by JetHome®