Re: [PATCH] swiotlb: avoid double copy with swiotlb on tx socket
From: Pedro Falcato <pfalcato@suse.de>
Date: 2026-06-16 09:20:30
Also in:
driver-core, linux-iommu, lkml
(+cc page pool maintainers) On Mon, Jun 15, 2026 at 11:42:20PM +0000, Luigi Rizzo wrote:
The use of swiotlb causes an extra data copy on I/O. For tx sockets, especially with greedy senders, this has a high chance of happening in the softirq handler for tx network interrupts, creating a significant performance bottleneck. Allow tx sockets to allocate socket buffers directly from the bounce buffers. This avoids the second copy and removes the above bottleneck. The fraction of swiotlb buffers allowed for this feature is set with /sys/module/swiotlb/parameters/zerocopy_tx_percent (0 means disabled, 90 is the maximum, to avoid persistent I/O failures). Implementation: - define a new page type to unambiguously identify bounce buffers used as backing storage for socket buffers - modify skb_page_frag_refill to perform the modified allocation - modify the destructors __free_frozen_pages(), free_unref_folio() to handle those pages and return them to the pool. The savings are especially visible with fewer queues. In synthetic benchmarks, senders with 1-2 queues would cap around 50Gbps with conventional swiotlb, and reach over 170Gbps with the feature enabled.
I could be wrong, but I genuinely think that the way to go about this is using page_pool for regular TX as well. page_pool pages are all dma-mapped (so whatever swiotlb optimization you want can be done there), and the net stack already has awareness of these special pages and special skbs, so it won't Just Return Them back to the page allocator. Otherwise you can easily go all over the place, and that's just not great. Also this could possibly benefit setups that use IOMMU as well. -- Pedro