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

Re: [PATCH v2 08/18] IOMMU/x86: support freeing of pagetables


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 3 Dec 2021 09:30:00 +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=gg5PdOez0qlAzTY/Sk1COVEe1ZdvJYcu+JsmreuD4lA=; b=jKVuFu5/+0tlDHu4DtHWHJKiJN4NlIKW9ewCRcsuQMVjP+Hts+4WuSX845uDbTcuAAnJiofBP/hEgcYXgf9wZx3cLXuHjetu3xNfmSGZ24Jz1sGxCfeA1wIeFVtlNbgUxVXPanBNtnkGSpW0VjgW1l3rij0feBdpIEZql7Xj7XdOTqFSgtbykMytVuGbSBNL+lcSaMAvlA6czaDuokJf8s5oL7EyAXgxrFg6NlVeDP5RcQCQpq6UMGuyyUrnJrkw3ojwZD1I/LJOdKNhSLneJzZEm8v8oyV5x2HOqmwWWHQSnqh6PBwItldi6+JxpjBrey8rcHitut16cyBFQuq+5Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esnWvM3lzlAJ3ulfW3jx7j308nDG2JF8vTCQjXTB9yuY+EJLjReSJ7j5cjdXwwmChto0mEfC/Z2KWQ449zdxie8AujgMG2B+z6Bg5bnqvrJOZ5ummV4kzpdr0JV45Q/9SofeoV9iD17pHjIkOfeYekSj+8qjqhTcHsCXgENPzcM8VAmEeaoIyf+PHt2OLHVvKEX91V3HZrlacLP83ZUionE3VrQz9coTB1NtU0ESqOYTOvn7zAvEOyF7snI76x18PnXrjWWHFMyFGxSihaSE7Zl5QeElG/vj7KDB0r5Bg5TXf50BBVLQlnb8Y8gsdTXEX0+iRaz411NFmTDQu/PQ2g==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 03 Dec 2021 08:30:39 +0000
  • Ironport-data: A9a23:UciwZ6B3YP4HuBVW/8Tkw5YqxClBgxIJ4kV8jS/XYbTApGwi0DJRx zdOXGCEPPvbN2akLdsgOt/lpBsEuJXcmINmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLGs1hxZH1c+EX570Ug7wIbVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/hQSptNNXy 8l0nKepRCkYZYTMnOofakwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHvSQvYMCg2xYasZmGKbnQ ck+SDZUPRn4ZUJdKHkeGosPpbL97pX4W2IB8w/EzUYt2EDLxRF1+KjgNpzSYNPibdpRtlaVo CTB5WuRKhMQOcGbyDGF2mmxneKJliT+MKoCGbv9+vN0jVm7wm0IFAZQRVa9ueO+iEO1R5RYM UN8x8Y1hfFsrgrxFIC7BkDm5i7f1vIBZzZOO+MLyCqO7KnI2i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eaHN5DtB/LfHCWuDYq8dKbC8mcjC74eurAYccegpUdAZ0+4QMHfkLqQcfnghOXNWLu v52iIRzADQBkj/I/7LTEUtbqzmnZnmhZjmaRkJC1oO7xSPtyqh7PrfHwKD1hkTfjtTyfN6mF K13zDR1+GGibWW2xXc32jc49B/n8bg8MJKAIiphtIOIjvhpw60bMBKWqGEvhoyvOazgWxa3e XkklMFBYBe+nnRdma6rV/E3BTh6i8n7zvYxVqRkRLY0IXEbQN/L/AEqZNScxPf5UZllsp7yr h302WQsIcSJQ/cnQzmjuK4Fi1Cpw6Rmz4PgOQTh3tQXc81c7lKt7ES+0tTDdMpAD/60oY6C+ NjZfusqsq+SWnqLEwxg1MfguBFBh8Ib1K7qwk5y4OoOgFt7TBEJxBy/r1aop8CnKhNPaWsqd 60dZiAr4s+PPP+W5gNc9vpcfHHeVAlfii8RV56AW6XXJ3vaEi94KIe3t0OlZWXkdozvd0PpK g=
  • Ironport-sdr: bFpl2axIIu1/eTEsOhM3Exb3q75MdhaxvuKV9H1DvK99Z9uLGmsoZ2TUb7O8W3dKNyhaGIh4Ik 6h7MGUY0ORq9gM9VjrVoLCb9MDxS9IyiymxovqXVKGlpwfPLprHOcTp0r5IqqeUwyP8zwkUTGw 5nvbottfDw0Ep3ZepSleXFZTbl67B52nOmfVlMAAylaqFfzJErKoHsOxigzc4hQyOtvkT4pYMn T3v1QCzHZZiKL4+/mBQpyiUQ6OxaM7yGxuJVqMny9ephnSqnB+5VrsEzc0gogS6j5K99EVzf9+ mYpoSaggPS8w9VSJBqPiqbWD
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Dec 02, 2021 at 05:10:38PM +0100, Jan Beulich wrote:
> On 02.12.2021 17:03, Roger Pau Monné wrote:
> > On Fri, Sep 24, 2021 at 11:48:21AM +0200, Jan Beulich wrote:
> >> For vendor specific code to support superpages we need to be able to
> >> deal with a superpage mapping replacing an intermediate page table (or
> >> hierarchy thereof). Consequently an iommu_alloc_pgtable() counterpart is
> >> needed to free individual page tables while a domain is still alive.
> >> Since the freeing needs to be deferred until after a suitable IOTLB
> >> flush was performed, released page tables get queued for processing by a
> >> tasklet.
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> >> ---
> >> I was considering whether to use a softirq-taklet instead. This would
> >> have the benefit of avoiding extra scheduling operations, but come with
> >> the risk of the freeing happening prematurely because of a
> >> process_pending_softirqs() somewhere.
> > 
> > Another approach that comes to mind (maybe you already thought of it
> > and discarded) would be to perform the freeing after the flush in
> > iommu_iotlb_flush{_all} while keeping the per pPCU lists.
> 
> This was my initial plan, but I couldn't convince myself that the first
> flush to happen would be _the_ one associated with the to-be-freed
> page tables. ISTR (vaguely though) actually having found an example to
> the contrary.

I see. If we keep the list per pCPU I'm not sure we could have an
IOMMU  flush not related to the to-be-freed pages, as we cannot have
interleaved IOMMU operations on the same pCPU.

Also, if we strictly add the pages to the freeing list once unhooked
from the IOMMU page tables it should be safe to flush and then free
them, as they would be no references remaining anymore.

Thanks, Roger.



 


Rackspace

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