From: Razvan Cojocaru <rcojocaru@bitdefender.com>
To: "Lengyel, Tamas" <tlengyel@novetta.com>
Cc: kevin.tian@intel.com, wei.liu2@citrix.com,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
tim@xen.org, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
Jan Beulich <jbeulich@suse.com>,
eddie.dong@intel.com, Jun Nakajima <jun.nakajima@intel.com>,
andrew.cooper3@citrix.com, keir@xen.org
Subject: Re: [PATCH V9] xen/vm_event: Clean up control-register-write vm_events and add XCR0 event
Date: Wed, 03 Jun 2015 17:37:57 +0300 [thread overview]
Message-ID: <556F1145.1090807@bitdefender.com> (raw)
In-Reply-To: <CAD33N+4eBYPzg+x-gAwRYHCqS8c=aJqGGin1ZhxX8haSkXj36g@mail.gmail.com>
On 06/03/2015 05:19 PM, Lengyel, Tamas wrote:
>
>
> On Wed, Jun 3, 2015 at 3:48 PM, Razvan Cojocaru
> <rcojocaru@bitdefender.com <mailto:rcojocaru@bitdefender.com>> wrote:
>
> On 06/03/2015 04:29 PM, Lengyel, Tamas wrote:
> >
> >
> >
> > diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
> > index 45b5283..a3c117f 100644
> > --- a/xen/include/asm-x86/domain.h
> > +++ b/xen/include/asm-x86/domain.h
> > @@ -341,15 +341,9 @@ struct arch_domain
> >
> > /* Monitor options */
> > struct {
> > - uint16_t mov_to_cr0_enabled : 1;
> > - uint16_t mov_to_cr0_sync : 1;
> > - uint16_t mov_to_cr0_onchangeonly : 1;
> > - uint16_t mov_to_cr3_enabled : 1;
> > - uint16_t mov_to_cr3_sync : 1;
> > - uint16_t mov_to_cr3_onchangeonly : 1;
> > - uint16_t mov_to_cr4_enabled : 1;
> > - uint16_t mov_to_cr4_sync : 1;
> > - uint16_t mov_to_cr4_onchangeonly : 1;
> > + uint16_t write_ctrlreg_enabled : 4;
> > + uint16_t write_ctrlreg_sync : 4;
> > + uint16_t write_ctrlreg_onchangeonly : 4;
> >
> >
> > Just looking at this here again, we will now have a bitmap within a
> > bitmap, which doesn't seem to be very efficient. IMHO it would be better
> > to just take the ctrlreg bitmap out as a separate uint8_t within struct
> > {} monitor.
>
> How is it inefficient? I don't see that at all. And I'm not sure what
> you mean about the uint8_t: there are 3 fields there, each 4-bits wide
> (write_ctrlreg_enabled, write_ctrlreg_sync, write_ctrlreg_onchangeonly)
> and only (at most) two of them would fit into a uint8_t. To put them all
> into a new struct would mean wasting an uint16_t for 12-bits.
>
>
> Right now if you want to access a bit using the index on the ctrlreg
> fields, you would for example do (monitor.write_ctrlreg_enabled &
> index). This is actually going to perform two bitmask operations. First,
> monitor.write_ctrlreg_enabled does a masking operating to get you only
> the 4 bits corresponding to this field, then you do another mask with
> the index. In general bitmasks are pretty slow operations, thus IMHO
> minimizing them would be ideal. What I meant by doing a uint8_t
> separately would be like "uint8_t write_ctrlreg_enabled;" which would
> eliminate the first bitmask operation. You would have to do that for the
> other two bitfields as well, write_ctrlreg_sync and
> write_ctrlreg_onchangeonly. The trade-off with this is that now we will
> have 12 bits that are not used for anything (yet). On the other hand
> this way we could also reduce the size of the remaining bitfield from
> uint16_t to uint8_t, so IMHO it's not that big of an issue.
Right, I've assumed that you weren't talking about that, since the
initial patch used more bits than strictly necessary for storing the
current number of events, and you preferred the patch to use the least
possible ammount of bits to store the info, but using dedicated uint8_ts
is indeed a slightly different approach.
> Sorry for the last minute addition here, I know you want to close this
> patch now that you have the acks on it. If the maintainers don't share
> my concern here then feel free to ignore it ;)
No problem, I'd rather have it done right than quick, so if extra
shifting to get to those fields trumps the space economy bitfields
provide, I'll send a new version of the patch. It it after all not that
great of a modification.
Waiting for maintainers' / other input.
Thanks,
Razvan
next prev parent reply other threads:[~2015-06-03 14:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 11:35 [PATCH V9] xen/vm_event: Clean up control-register-write vm_events and add XCR0 event Razvan Cojocaru
2015-06-03 11:45 ` Ian Campbell
2015-06-03 13:29 ` Lengyel, Tamas
2015-06-03 13:48 ` Razvan Cojocaru
2015-06-03 14:19 ` Lengyel, Tamas
2015-06-03 14:37 ` Razvan Cojocaru [this message]
2015-06-04 13:53 ` Tim Deegan
2015-06-04 18:49 ` Lengyel, Tamas
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=556F1145.1090807@bitdefender.com \
--to=rcojocaru@bitdefender.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=kevin.tian@intel.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=tlengyel@novetta.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.