From: Paolo Bonzini <pbonzini@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>,
kvm@vger.kernel.org, Jun Nakajima <jun.nakajima@intel.com>,
Yang Zhang <yang.z.zhang@intel.com>
Subject: Re: [PATCH v5 10/14] nEPT: Add nEPT violation/misconfigration support
Date: Thu, 1 Aug 2013 15:13:02 +0200 [thread overview]
Message-ID: <20130801131302.GH5245@mail.corp.redhat.com> (raw)
In-Reply-To: <20130801121445.GE6042@redhat.com>
> > > > > > Not sure this explicit "inline" is needed... Gcc always inlines the small and
> > > > > > static functions.
> > > > >
> > > > > Paolo asked for it, but now I see that I did in in a wrong patch. I do
> > > > > not care much personally either way, I agree with you though, compiler
> > > > > will inline it anyway.
> > > >
> > > > The point here was that if we use "||" below (or multiple "if"s as I
> > > > suggested in my review), we really want to inline the function to ensure
> > > > that the branches here is merged with the one in the caller's "if()".
> > > >
> > > > With the "|" there is not much effect.
> > >
> > > Even with if() do you really think there is a chance the function will not be
> > > inlined? I see that much much bigger functions are inlined.
> >
> > I don't know, it depends on the compiler flags, how much the function
> > is used... Zeroing the chance is not bad.
>
> AFAIK inline is just a hint anyway and compiler is free to ignore it.
> That is why we have __always_inline, but compiler should know better
> here, do not see the reason for __always_inline.
Yes, but with "inline" the compiler will use more generous thresholds.
The GCC docs say that without "inline", -O2 only inlines "functions into
their callers when their body is smaller than expected function call
code (so overall size of program gets smaller)". I'm not at all sure
this is the case for the new is_rsvd_bits_set, and anyway "making the
program smaller" is not the reason why we want the compiler to inline it.
Did you check that the compiler inlines it? Perhaps you should really
use __always_inline since that's what we really want.
> > Because the function is "bool". I dislike the magic "!= 0"
> > that the compiler adds on conversion to bool. It always seemed
> > like a recipe for trouble since "int" and "bool" are otherwise
> > interchangeable... Without that "!= 0", s/bool/int/ would ignore
> > the upper 32 bits and break.
>
> I actually checked that before proposing.
>
> printf("%d\n", (bool)0x1000000000) prints one, but of course if bool is
> typedefed to int it will not work, but it should be not.
No, it should not be indeed, but not everyone uses bool in the same way;
it is quite common to use "int" for something that is 0/1, and the magic
"!= 0" is dangerous if you cut-and-paste the expression where the compiler
will not do it... It can even be a function argument where you do not
see directly if it is bool, int, u64 or what.
I don't think omitting "!= 0" is common at all in the kernel, so I would
not start doing it here. :)
> > > > On the other hand, it starts to look like useless complication not
> > > > backed by any benchmark (and probably unmeasurable anyway). Neither of
> > > > the conditions are particularly easy to compute, and they are probably
> > > > more expensive than a well-predicted branch. Thus, in this case I
> > > > would prefer to have clearer code and just use two "if"s, the second
> > > > of which can be guarded to be done only for EPT (it doesn't have to
> > > > be an #ifdef, no?).
> > >
> > > return a | b
> > >
> > > is less clear than:
> > >
> > > if (a)
> > > return true;
> > > if (b)
> > > return true;
> >
> > If each of a and b is actually a complicated expression having
> > AND/SHIFT/arrays, then yes. :)
>
> This is not the most complex expression possible :)
> Just having them on different lines is not enough?
No big deal, especially if we plan to merge the present check together.
Paolo
next prev parent reply other threads:[~2013-08-01 13:13 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 14:48 [PATCH v5 00/14] Nested EPT Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 01/14] nEPT: Support LOAD_IA32_EFER entry/exit controls for L1 Gleb Natapov
2013-08-01 11:22 ` Orit Wasserman
2013-07-31 14:48 ` [PATCH v5 02/14] nEPT: Fix cr3 handling in nested exit and entry Gleb Natapov
2013-08-01 11:28 ` Orit Wasserman
2013-07-31 14:48 ` [PATCH v5 03/14] nEPT: Fix wrong test in kvm_set_cr3 Gleb Natapov
2013-08-01 12:07 ` Orit Wasserman
2013-07-31 14:48 ` [PATCH v5 04/14] nEPT: Move common code to paging_tmpl.h Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 05/14] nEPT: make guest's A/D bits depends on guest's paging mode Gleb Natapov
2013-08-01 6:51 ` Xiao Guangrong
2013-07-31 14:48 ` [PATCH v5 06/14] nEPT: Support shadow paging for guest paging without A/D bits Gleb Natapov
2013-08-01 6:54 ` Xiao Guangrong
2013-07-31 14:48 ` [PATCH v5 07/14] nEPT: Add EPT tables support to paging_tmpl.h Gleb Natapov
2013-08-01 7:00 ` Xiao Guangrong
2013-08-01 7:10 ` Gleb Natapov
2013-08-01 7:18 ` Xiao Guangrong
2013-08-01 7:31 ` Xiao Guangrong
2013-08-01 7:42 ` Gleb Natapov
2013-08-01 7:51 ` Xiao Guangrong
2013-08-01 7:56 ` Gleb Natapov
2013-08-01 11:05 ` Paolo Bonzini
2013-08-01 11:07 ` Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 08/14] nEPT: Redefine EPT-specific link_shadow_page() Gleb Natapov
2013-08-01 7:24 ` Xiao Guangrong
2013-08-01 7:27 ` Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 09/14] nEPT: Nested INVEPT Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 10/14] nEPT: Add nEPT violation/misconfigration support Gleb Natapov
2013-08-01 8:31 ` Xiao Guangrong
2013-08-01 8:45 ` Gleb Natapov
2013-08-01 11:19 ` Paolo Bonzini
2013-08-01 11:47 ` Gleb Natapov
2013-08-01 12:03 ` Paolo Bonzini
2013-08-01 12:14 ` Gleb Natapov
2013-08-01 13:13 ` Paolo Bonzini [this message]
2013-08-01 13:20 ` Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 11/14] nEPT: MMU context for nested EPT Gleb Natapov
2013-08-01 9:16 ` Xiao Guangrong
2013-08-01 9:37 ` Gleb Natapov
2013-08-01 9:51 ` Xiao Guangrong
2013-07-31 14:48 ` [PATCH v5 12/14] nEPT: Advertise EPT to L1 Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 13/14] nEPT: Some additional comments Gleb Natapov
2013-07-31 14:48 ` [PATCH v5 14/14] nEPT: Miscelleneous cleanups Gleb Natapov
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=20130801131302.GH5245@mail.corp.redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@redhat.com \
--cc=jun.nakajima@intel.com \
--cc=kvm@vger.kernel.org \
--cc=xiaoguangrong@linux.vnet.ibm.com \
--cc=yang.z.zhang@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