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

Re: [PATCH v2 12/18] AMD/IOMMU: allow use of superpage mappings


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 13 Dec 2021 11:33:21 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=Ixro4LAtVI4mPqxdr09iV3FNukiLsVmxf+1HBr/u6/o=; b=Fk7dBc/xnn5GJSrX0qnIl8s8E4IZ6tCjY007+57/AYLAs9zvFJsNKlqxqEJOCJ5KRR5lm2xoEY1QBuSwsKRrrBXK8tW8SLC81OF5EZcHurBWA0aa3DuYAsWhERpegkjPJ473ISm3Z0csJdNTdM6y04mUFKSvkBuMrQejcJtOo9jagecqC+NZFFUsPDiRBMdvLV8zWiBnnnRX1a9KAuJzPWAOm2AX7DziJvcQwIyjDKorDp2rxGRq9oco8uM2obmI0HKesIif7QvXpVlakq4djrTzIgyYGI4MC2gZ9IV43YP60uPnDbTjW2piFPhx4G1bB+QyEKXoq/ktdrMvYCcf5g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elIA1hsKJdTAQCkLNe0sJNVsgcHDfAHaTiLZ4WkQWj+x03GPlr2x5NZGCFL2lgjvruuBgAW0GTtfhktdXjNqNOxqit7Dnyhp4kavHyi00xLOI7X1DjRsKBI7aTHapcIPijcBzVaU53jgu/pAKGiuRWol9rNvTqPf7AJni8KLMiryJIYORvKcARAiBW4QnRAHtnnKv5wR4va93qO6wpOwoz2/DPqjlckFBjESfFhvdAC55NmohTnT4OWCWBEl4strpAOR9CN6CoVpQTgrfMzfDaT+vd8CGYsbMM9MQRM2xSTSnhEkIwaDkBzmaFuaeURFmMK5afLXJcb8WSRVYgQZlg==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 13 Dec 2021 10:34:56 +0000
  • Ironport-data: A9a23:xaBb+qIN2t2hjWGMFE+RTJIlxSXFcZb7ZxGr2PjKsXjdYENShjUAn zRODT3QPvaLMzCmKIona46z8B5Q78fcnNNkGVdlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUakideSc+EH140Eg6wLZj6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB2qnfRp8 soV5KfvQCgGJarvl+EibFpHRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsF2gcsuNo/zNZ43sXB81zDJS/0hRPgvRo2UvYUGhWdp26iiG97OY NIfbhhRZy/8elpLH05PVp0/t/iB0yyXnzpw9wvO+PtfD3Lo5A5s1LngNvLFd9rMQt9a9m6Dv X7P9Wn9BhAcNfScxCCD/3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afnc+fZQXMTGxWXjaVMh28WI/
  • Ironport-hdrordr: A9a23:EEwFKq8WTeNutZ4lhTxuk+FAdb1zdoMgy1knxilNoENuHfBwxv rDoB1E73LJYVYqOU3Jmbi7Sc69qFfnhORICO4qTMqftWjdyRCVxeRZg7cKrAeQeREWmtQtsJ uINpIOdOEYbmIK/PoSgjPIaurIqePvmMvD5Za8854ud3ATV0gJ1XYGNu/xKDwReOApP+tcKH LKjfA32AZINE5nJfiTNz0gZazuttfLnJXpbVovAAMm0hCHiXeN5KThGxaV8x8CW3cXqI1SvF Ttokjc3OGOovu7whjT2yv66IlXosLozp9mCNaXgsYYBz3wgkKDZZhnWZeFoDcpydvfomoCoZ 3pmVMNLs5z43TeciWcpgbs4RDp1HIU53rr2Taj8A3eiP28YAh/J9tKhIpffBecwVEnpstA3K VC2H/cn4ZLDDvb9R6NqeTgZlVPrA6ZsHAimekcgzh0So0FcoJcqoQZ4Qd8DIoAJiTn84oqed MeQ/003MwmMW9yUkqp/VWGmLeXLzYO91a9MwQ/U/WuonlrdCsT9Tpc+CQd9k1wg67VBaM0o9 gsCZ4Y542mePVmGZ6VNN1xMfdfNVa9My4kEFjiaGgPR5t3c04klfbMkcAIDaeRCds18Kc=
  • Ironport-sdr: JTLLZwU4gf0vg6/25RwIaHSvNVFv3M0q3ylJyAf2koJO/l5lHylTGPntU8FbA6uIVs86aN0c0p RzqENwYc6PtWnH4X5xVP0DDzSCs0NO8l0YWkA8T/PjRsVBmbNftyue2+5lzLpq8tTKWADUUq25 ZdrxwzG+8RGwTIDhaU6y2iBFcNvZVsIc16vpAIDu+PQ4hC0UH0WA1VwED2NVAh/o1KpnC4+Tfk 9mqPzzQ4zZTNizGEtjKUeZQbyz6Bk+RqcuLKEjBobS8LzEMnxCnm93zfUX9bOyFw1pMIsclYsH ldMsIsmGyTEEZiZRb4XXbp/z
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Dec 13, 2021 at 11:00:23AM +0100, Jan Beulich wrote:
> On 13.12.2021 10:45, Roger Pau Monné wrote:
> > On Mon, Dec 13, 2021 at 09:49:50AM +0100, Jan Beulich wrote:
> >> On 10.12.2021 16:06, Roger Pau Monné wrote:
> >>> On Fri, Sep 24, 2021 at 11:52:14AM +0200, Jan Beulich wrote:
> >>>> ---
> >>>> I'm not fully sure about allowing 512G mappings: The scheduling-for-
> >>>> freeing of intermediate page tables can take quite a while when
> >>>> replacing a tree of 4k mappings by a single 512G one. Plus (or otoh)
> >>>> there's no present code path via which 512G chunks of memory could be
> >>>> allocated (and hence mapped) anyway.
> >>>
> >>> I would limit to 1G, which is what we support for CPU page tables
> >>> also.
> >>
> >> I'm not sure I buy comparing with CPU side support when not sharing
> >> page tables. Not the least with PV in mind.
> > 
> > Hm, my thinking was that similar reasons that don't allow us to do
> > 512G mappings for the CPU side would also apply to IOMMU. Regardless
> > of that, given the current way in which replaced page table entries
> > are freed, I'm not sure it's fine to allow 512G mappings as the
> > freeing of the possible huge amount of 4K entries could allow guests
> > to hog a CPU for a long time.
> 
> This huge amount can occur only when replacing a hierarchy with
> sufficiently many 4k leaves by a single 512G page. Yet there's no
> way - afaics - that such an operation can be initiated right now.
> That's, as said in the remark, because there's no way to allocate
> a 512G chunk of memory in one go. When re-coalescing, the worst
> that can happen is one L1 table worth of 4k mappings, one L2
> table worth of 2M mappings, and one L3 table worth of 1G mappings.
> All other mappings already need to have been superpage ones at the
> time of the checking. Hence the total upper bound (for the
> enclosing map / unmap) is again primarily determined by there not
> being any way to establish 512G mappings.
> 
> Actually, thinking about it, there's one path where 512G mappings
> could be established, but that's Dom0-reachable only
> (XEN_DOMCTL_memory_mapping) and would assume gigantic BARs in a
> PCI device. Even if such a device existed, I think we're fine to
> assume that Dom0 won't establish such mappings to replace
> existing ones, but only ever put them in place when nothing was
> mapped in that range yet.
> 
> > It would be better if we could somehow account this in a per-vCPU way,
> > kind of similar to what we do with vPCI BAR mappings.
> 
> But recording them per-vCPU wouldn't make any difference to the
> number of pages that could accumulate in a single run. Maybe I'm
> missing something in what you're thinking about here ...

If Xen somehow did the free in guest vCPU context before resuming
guest execution then you could yield when events are pending and thus
allow other guests to run without hogging the pCPU, and the freeing
would be accounted to vCPU sched slice time.

Thanks, Roger.



 


Rackspace

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