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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 3 Dec 2021 10:40:14 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=eAPjWv0K3HkQmcfj9Fy2c3NWQar6a91TvCjAvL+3p5Q=; b=bPjp9U4DCHKCF8aL4Yc20S6haKIQfRg6w07louhZSTbXPFDN7LEKBzUjbqRiS9irZ97BvqVAVgsp+1J2hAAMIcgGbsJ1/dOciek9wPtdqnsQ2j28V40TEvlIdnSYDxnA0j6+bH7lqWMZ5QEUifh3TvitaDt1bvqOWPXcik4ICtUZ2yK63K8uSmak5wXqNnNZXaPCUj5lmk7Phl15qdlOWqFPYV5+rCLqWd1XsVCufAoKoq1jDl5vX51IU8aFEkfZULWzslNS3USJu3urWBWcOsOZo4hrt6nuna18aClEMpJlAFhF+ApDgOf9DKQ7zNdVxhbGSPs5P0qFWC+JetZwiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DABokXJOuvl825rr1k2H69stl5v/u76z3IPx+hqMAjVvaNYa6jRpXXu7LpIogQVh129v3f7EvL1L3hNevElqaoJssYFBq6vclhZqh2/jifg1B6pyw/hhDy2LsngCl3O/JWDQC78j9kAGA4oDhBbc3iNpj3gtnuYvsr97Vs0MlnpLDYlxFUp+yuY2Ub+h/Kf9bHDOvDJLCIPbN5qrtlzwK4EwCQZ6SIQKRDPF+aLjVzlsjEPT41ZsN+i8Ye8XHbePLDN0yp8BlPaLpFZRp600x4FWuW4wXj3uNcJTQ3cUgW9kupY+yL8k92o0AE9yKpJwjx50YuNXz07wp3PGuFPP/w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.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 09:40:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.12.2021 09:30, Roger Pau Monné wrote:
> 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.

"interleaved" is perhaps the wrong word. But can you easily exclude e.g.
a put_page() in the middle of some other operation? That could in turn
invoke one of the legacy map/unmap functions (see cleanup_page_mappings()
for an example), where the flushing happens immediately after the
map/unmap.

> 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.

Only if the flush is a full-address-space one.

Jan




 


Rackspace

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