[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>, "mhkelley58@xxxxxxxxx" <mhkelley58@xxxxxxxxx>
- From: Michael Kelley <mhklinux@xxxxxxxxxxx>
- Date: Thu, 27 Jun 2024 15:04:35 +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=raNG0jVWFpSJwFielu6FwfYrMP8/HWhkBSOCMgEBgYM=; b=OXeHoEv6nwKM334GfD571hdH3afo5GikHpgA7fN/cC3x7lUyc7eUqkFA3pOvdfqQPDA2v/ZttIht87/7yLndcvaAFIjJc7HexkEa/+lJX0/p41zVvMxruIWK2B37pkIil7v+9MgM2QTJ/TlVeRGcMeun9qp4DPGvRvbVnonVM94+63bn0CGenq61mtDpQbsZFBQm3K64rqPTQVI+K1pjQx2FQK6clIrzSTBkxJ7yQ0BxX5P7WggXkP5/2l9OpcbTqcKr9RekIzS2owv+3QMhkMsfB2nQ/P+OL7JQhf1btqLXycAMvNi7sNdkktGipb4aSyCBFW9VMmZBqkkK095aBA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=junSST0Oet99976p1kU7/GaJlYJroYc6b7SLrTRZt6eolD60vjysh08sFSuJwWJ69EDreIqbdQDbpLYDSgzl7KBLfEBODNxTpXYwFEH/2PTVZV+l1GP3eg5Zb3Fb1nC3z8RdolCN7cMV3NJ/BVyRUz3F2Ff1zwngcNGqRBAjGL0s1GGLtxJVnLewIL2EmCqTui//l5kEl+vhkFNz5m6XCBTr3fnhZsyJgFWGEA/eDGTPjCNJa6LIOt664I30oHLr/mpyH1gxnnBBAyneC0atWng5VIcrLxoheKlzRVshjh/wVy7jM4757zKndit520aMyoeeQA14G2a7e3rvzNMrrg==
- 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: Thu, 27 Jun 2024 15:04:47 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHauIjoJBWSrCyO6UWzcncSceBiMLHbU/+AgACADXA=
- Thread-topic: [RFC 1/1] swiotlb: Reduce calls to swiotlb_find_pool()
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.
Michael
|