From: Like Xu <like.xu@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, rkrcmar@redhat.com,
sean.j.christopherson@intel.com, vkuznets@redhat.com,
Jim Mattson <jmattson@google.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 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC
Date: Wed, 9 Oct 2019 11:14:56 +0800 [thread overview]
Message-ID: <d492e08e-bf14-0a8b-bc8c-397f8893ddb5@linux.intel.com> (raw)
In-Reply-To: <20191008121140.GN2294@hirez.programming.kicks-ass.net>
On 2019/10/8 20:11, Peter Zijlstra wrote:
> On Tue, Oct 01, 2019 at 08:33:45PM +0800, Like Xu wrote:
>> Hi Peter,
>>
>> On 2019/10/1 16:23, Peter Zijlstra wrote:
>>> On Mon, Sep 30, 2019 at 03:22:57PM +0800, Like Xu wrote:
>>>> + union {
>>>> + u8 event_count :7; /* the total number of created perf_events */
>>>> + bool enable_cleanup :1;
>>>
>>> That's atrocious, don't ever create a bitfield with base _Bool.
>>
>> I saw this kind of usages in the tree such as "struct
>> arm_smmu_master/tipc_mon_state/regmap_irq_chip".
>
> Because other people do tasteless things doesn't make it right.
>
>> I'm not sure is this your personal preference or is there a technical
>> reason such as this usage is not incompatible with union syntax?
>
> Apparently it 'works', so there is no hard technical reason, but
> consider that _Bool is specified as an integer type large enough to
> store the values 0 and 1, then consider it as a base type for a
> bitfield. That's just disguisting.
It's reasonable. Thanks.
>
> Now, I suppose it 'works', but there is no actual benefit over just
> using a single bit of any other base type.
>
>> My design point is to save a little bit space without introducing
>> two variables such as "int event_count & bool enable_cleanup".
>
> Your design is questionable, the structure is _huge_, and your union has
> event_count:0 and enable_cleanup:0 as the same bit, which I don't think
> was intentional.
>
> Did you perhaps want to write:
>
> struct {
> u8 event_count : 7;
> u8 event_cleanup : 1;
> };
>
> which has a total size of 1 byte and uses the low 7 bits as count and the
> msb as cleanup.
Yes, my union here is wrong and let me fix it in the next version.
>
> Also, the structure has plenty holes to stick proper variables in
> without further growing it.
Yes, we could benefit from it.
>
>> By the way, is the lazy release mechanism looks reasonable to you?
>
> I've no idea how it works.. I don't know much about virt.
>
next prev parent reply other threads:[~2019-10-09 3:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 7:22 [PATCH 0/3] KVM: x86/vPMU: Efficiency optimization by reusing last created perf_event Like Xu
2019-09-30 7:22 ` [PATCH 1/3] perf/core: Provide a kernel-internal interface to recalibrate event period Like Xu
2019-10-01 2:27 ` kbuild test robot
2019-10-01 2:46 ` kbuild test robot
2019-10-07 12:01 ` Paolo Bonzini
2019-10-07 13:25 ` Liang, Kan
2019-10-07 15:05 ` Paolo Bonzini
2019-09-30 7:22 ` [PATCH 2/3] KVM: x86/vPMU: Reuse perf_event to avoid unnecessary pmc_reprogram_counter Like Xu
2019-10-01 8:22 ` Peter Zijlstra
2019-10-01 12:18 ` Like Xu
2019-09-30 7:22 ` [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC Like Xu
2019-10-01 8:23 ` Peter Zijlstra
2019-10-01 12:33 ` Like Xu
2019-10-08 12:11 ` Peter Zijlstra
2019-10-09 3:14 ` Like Xu [this message]
2019-10-09 7:15 ` Paolo Bonzini
2019-10-09 8:07 ` Like Xu
2019-10-09 8:16 ` Peter Zijlstra
2019-10-09 9:21 ` Paolo Bonzini
2019-10-09 9:32 ` Peter Zijlstra
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=d492e08e-bf14-0a8b-bc8c-397f8893ddb5@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
Powered by JetHome