Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-09 Thread Peter Zijlstra
On Wed, Oct 09, 2019 at 11:21:30AM +0200, Paolo Bonzini wrote: > On 09/10/19 10:16, Peter Zijlstra wrote: > >> bool bitfields preserve the magic behavior where something like this: > >> > >> foo->x = y; > >> > >> (x is a bool bitfield) would be compiled as > >> > >> foo->x = (y != 0); > > >

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-09 Thread Paolo Bonzini
On 09/10/19 10:16, Peter Zijlstra wrote: > On Wed, Oct 09, 2019 at 09:15:03AM +0200, Paolo Bonzini wrote: >> For stuff like hardware registers, bitfields are probably a bad idea >> anyway, so let's only consider the case of space optimization. > > Except for hardware registers? I actually like

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-09 Thread Peter Zijlstra
On Wed, Oct 09, 2019 at 09:15:03AM +0200, Paolo Bonzini wrote: > For stuff like hardware registers, bitfields are probably a bad idea > anyway, so let's only consider the case of space optimization. Except for hardware registers? I actually like bitfields to describe hardware registers. > bool:2

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-09 Thread Like Xu
Hi Paolo, On 2019/10/9 15:15, Paolo Bonzini wrote: On 09/10/19 05:14, Like Xu wrote: 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

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-09 Thread Paolo Bonzini
On 09/10/19 05:14, Like Xu wrote: >> >> >>> 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

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-08 Thread Like Xu
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

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-08 Thread Peter Zijlstra
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

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-01 Thread Like Xu
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

Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-10-01 Thread Peter Zijlstra
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. > + } state;

[PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC

2019-09-30 Thread Like Xu
Currently, a host perf_event is created for a vPMC functionality emulation. It’s unpredictable to determine if a disabled perf_event will be reused. If they are disabled and are not reused for a considerable period of time, those obsolete perf_events would increase host context switch overhead