[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [RFC 1/1] swiotlb: Reduce calls to swiotlb_find_pool()
- To: Petr Tesařík <petr@xxxxxxxxxxx>
- From: Michael Kelley <mhklinux@xxxxxxxxxxx>
- Date: Sat, 29 Jun 2024 15:53:07 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=RWj2FbwXeSXYv/TiJrBTuayy9dMETUpl6Go1ASRp+Gc=; b=XU4fXCrPp5hKk+In0UYiE3AtwybPErgROaERlQ6KLT+srlNap7Md7LjL8D6RxKZDqDlOubtWBNzCSzdY8MI663lEwMZS9KayN4zHdSE8XVSVbbnCXYVZSVQAGkoe1dO9giKu1Sf8GwU9S/0BIt0QKRbDgkD3tr+8T+eU7DfJRYET9tbsjajafFo+fd1iYi3IToyWb9TFMxjO/ZDMtwxhARofzakrL+p1xsm2dovPNxf6LRIf8ky4/466ggqlPo2JpvnAYeppYMyxXxIg/xWXxYR/lLcFIDBNRt+ms9QCMawyx1ODvjCxch78ZrJ5f6zzm0spqHeLRmbkpNuUgsSVXg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EivFZ62BSRqlLbc2KPBullcZi8bTa41ryg9LTf03kOW0jLTWrXPdO6tDqooqQUqRv7BOidJdfm1ZoAEQiFBZZIW3JF/EgmGyAiwJjgLjw8BnvzCIKrY47sU+H0hjTDoZL8seNAGXClDWNoVMHnDzJPR7i2UIz2nbrb6OhXKyTGdlGRZ6ciZpHTU+SImAn3k+YSysUPIAqAya2OMX5vW5PhCrZD7Q4Rr3yUCxJtCxrtvRWJsFUW8YkK+LM4+tkqHec+35KeI34NBBWef1y+m/xleU+dxH/Z99HXncKS+6XQr2IyAoE9/NHhZWRt9Pxolxz8BpyoBsFNaGBv6JYYeP1g==
- Cc: "robin.murphy@xxxxxxx" <robin.murphy@xxxxxxx>, "joro@xxxxxxxxxx" <joro@xxxxxxxxxx>, "will@xxxxxxxxxx" <will@xxxxxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "oleksandr_tyshchenko@xxxxxxxx" <oleksandr_tyshchenko@xxxxxxxx>, "hch@xxxxxx" <hch@xxxxxx>, "m.szyprowski@xxxxxxxxxxx" <m.szyprowski@xxxxxxxxxxx>, "iommu@xxxxxxxxxxxxxxx" <iommu@xxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Sat, 29 Jun 2024 15:53:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHauIjoJBWSrCyO6UWzcncSceBiMLHbU/+AgACADXCAAzLqkA==
- Thread-topic: [RFC 1/1] swiotlb: Reduce calls to swiotlb_find_pool()
From: Michael Kelley <mhklinux@xxxxxxxxxxx> Sent: Thursday, June 27, 2024 8:05
AM
>
> From: Petr Tesařík <petr@xxxxxxxxxxx> Sent: Thursday, June 27, 2024 12:21 AM
>
> [...]
>
> > > @@ -187,10 +169,13 @@ static inline bool is_swiotlb_buffer(struct device
> > > *dev, phys_addr_t paddr)
> > > * This barrier pairs with smp_mb() in swiotlb_find_slots().
> > > */
> > > smp_rmb();
> > > - return READ_ONCE(dev->dma_uses_io_tlb) &&
> > > - swiotlb_find_pool(dev, paddr);
> > > + if (READ_ONCE(dev->dma_uses_io_tlb))
> > > + return swiotlb_find_pool(dev, paddr);
> > > + return NULL;
> > > #else
> > > - return paddr >= mem->defpool.start && paddr < mem->defpool.end;
> > > + if (paddr >= mem->defpool.start && paddr < mem->defpool.end)
> > > + return &mem->defpool;
> >
> > Why are we open-coding swiotlb_find_pool() here? It does not make a
> > difference now, but if swiotlb_find_pool() were to change, both places
> > would have to be updated.
> >
> > Does it save a reload from dev->dma_io_tlb_mem? IOW is the compiler
> > unable to optimize it away?
> >
> > What about this (functionally identical) variant:
> >
> > #ifdef CONFIG_SWIOTLB_DYNAMIC
> > smp_rmb();
> > if (!READ_ONCE(dev->dma_uses_io_tlb))
> > return NULL;
> > #else
> > if (paddr < mem->defpool.start || paddr >= mem->defpool.end);
> > return NULL;
> > #endif
> >
> > return swiotlb_find_pool(dev, paddr);
> >
>
> Yeah, I see your point. I'll try this and see what the generated code
> looks like. It might take me a couple of days to get to it.
>
With and without CONFIG_SWIOTLB_DYNAMIC, there's no meaningful
difference in the generated code for x86 or for arm64.
I'll incorporate this change into v2.
Michael
|