[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH] x86/ept: fix shattering of special pages


  • To: Pau Monné, Roger <roger.pau@xxxxxxxxxx>, "Beulich, Jan" <JBeulich@xxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Thu, 30 Jun 2022 02:04:21 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M5U6Uo0IVW3vHmxN8E2RMKF6mrAdlDY0/XN+ZTiqiTw=; b=RxI6ZKYsJNEgDcZtCeKcxq2qg/aQibH1NiOaaSJuRjYxNGR2262nsQmnWlJQYTuZAQep5ZrdoSXJUzahvPtWDPj2+9Mj44/F2oBb9i1SacPjua07F+ZSeAdxiHD1lbis82g+ia2ysjT9Xl1ZRAM0ub/Ie+kBC0ecWV9MfO+NbhMrhWury92KhwjcK3pl08JXBocHgZjP17gTLpNH6z4JA4F0PjwaMYXJ6Vzx6q8nuvFzngLj6L0mA3nGgZFvqoZSkqSWDVTarm2S0fxpQJ9aXUNNH7gzddxqsRpd3e0h7lfM8UZKFzFlK2tRMyduVxBil4a/7R79nm8xQFKwiow7Ow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DwPRf4OF9OuP5uxHU+KGP7cPycOdkt2kp2x6H/AS2NUhjGq4aG2h1QZ5cBSRvHDNoUE7eJ7YJB8xcJfA7xO7gPimUsQ6kE8k4E+OYW1Go7PfLw866hAjMz95MnVAcJUAwjF4DOmMJJ3uTM6vItsHf0GuohX1hPvNCpES5lWTyVvNimbwQbTLC7dw+oSnEKnf6wzM2boH+rV2DgiBsSVDc+Oa4q+Ilh9huQfjyTWj3HYjM8asQnx7OBusmCoMAP8nDo7wWRw/ypqmabMdvv6JKvcYkIHMgTeLaLHdRCBnHSdV3CyFBg3IHEgQw4+abs2GK/j66LYPwJcVyjGr8QyiMA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Nakajima, Jun" <jun.nakajima@xxxxxxxxx>, "Cooper, Andrew" <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Wei Liu" <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 30 Jun 2022 02:04:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYig0A8+iuyC//Bk2PKQQEd7+3W61mDnbAgAANmACAARrLMA==
  • Thread-topic: [PATCH] x86/ept: fix shattering of special pages

> From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Sent: Wednesday, June 29, 2022 5:11 PM
> 
> On Wed, Jun 29, 2022 at 08:41:43AM +0000, Tian, Kevin wrote:
> > > From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
> > > Sent: Monday, June 27, 2022 6:01 PM
> > >
> > > The current logic in epte_get_entry_emt() will split any page marked
> > > as special with order greater than zero, without checking whether the
> > > super page is all special.
> > >
> > > Fix this by only splitting the page only if it's not all marked as
> > > special, in order to prevent unneeded super page shuttering.
> > >
> > > Fixes: ca24b2ffdb ('x86/hvm: set 'ipat' in EPT for special pages')
> > > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > > ---
> > > Cc: Paul Durrant <paul@xxxxxxx>
> > > ---
> > > It would seem weird to me to have a super page entry in EPT with
> > > ranges marked as special and not the full page.  I guess it's better
> > > to be safe, but I don't see an scenario where we could end up in that
> > > situation.
> > >
> > > I've been trying to find a clarification in the original patch
> > > submission about how it's possible to have such super page EPT entry,
> > > but haven't been able to find any justification.
> > >
> > > Might be nice to expand the commit message as to why it's possible to
> > > have such mixed super page entries that would need splitting.
> >
> > Here is what I dig out.
> >
> > When reviewing v1 of adding special page check, Jan suggested
> > that APIC access page was also covered hence the old logic for APIC
> > access page can be removed. [1]
> 
> But the APIC access page is always added using set_mmio_p2m_entry(),
> which will unconditionally create an entry for it in the EPT, hence
> there's no explicit need to check for it's presence inside of higher
> order pages.
> 
> > Then when reviewing v2 he found that the order check in removed
> > logic was not carried to the new check on special page. [2]
> >
> > The original order check in old APIC access logic came from:
> >
> > commit 126018f2acd5416434747423e61a4690108b9dc9
> > Author: Jan Beulich <jbeulich@xxxxxxxx>
> > Date:   Fri May 2 10:48:48 2014 +0200
> >
> >     x86/EPT: consider page order when checking for APIC MFN
> >
> >     This was overlooked in 3d90d6e6 ("x86/EPT: split super pages upon
> >     mismatching memory types").
> >
> >     Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> >     Acked-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> >     Reviewed-by: Tim Deegan <tim@xxxxxxx>
> >
> > I suppose Jan may actually find such mixed super page entry case
> > to bring this fix in.
> 
> Hm, I guess theoretically it could be possible for contiguous entries
> to be coalesced (if we ever implement that for p2m page tables), and
> hence result in super pages being created from smaller entries.
> 
> It that case it would be less clear to assert that special pages
> cannot be coalesced with other contiguous entries.

With Jan's confirmation I'm fine with this change too. Just below...

> >
> > Did you actually observe an impact w/o this fix?
> 
> Yes, the original change has caused a performance regression in some
> GPU pass through workloads for XenServer.  I think it's reasonable to
> avoid super page shattering if the resulting pages would all end up
> using ipat and WRBACK cache attribute, as there's no reason for the
> split in the first case.
> 

... I'd appreciate mentioning the regression case in the commit msg.

With that,

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.