selftests: net: tcp_mmap: populate pages in send path
Subsystems (3)
PATCH 1/1 selftests: net: tcp_mmap: populate pages in send path
In commit 72653ae5303c ("selftests: net: tcp_mmap:
Use huge pages in send path") I made a change to use hugepages for the buffer used by the client (tx path)
Today, I understood that the cause for poor zerocopy performance was that after a mmap() for a 512KB memory zone, kernel uses a single zeropage, mapped 128 times.
This was really the reason for poor tx path performance in zero copy mode, because this zero page refcount is under high pressure, especially when TCP ACK packets are processed on another cpu.
We need either to force a COW on all the memory range, or use MAP_POPULATE so that a zero page is not abused.
--- tools/testing/selftests/net/tcp_mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/tcp_mmap.c +2 -1
@@ -137,7 +137,8 @@ static void *mmap_large_buffer(size_t need, size_t *allocated)if (buffer == (void *)-1 ) { sz = need; buffer =mmap (NULL , sz,PROT_READ |PROT_WRITE , -MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 ); +MAP_PRIVATE |MAP_ANONYMOUS |MAP_POPULATE , +-1 ,0 );if (buffer != (void *)-1 )fprintf (stderr,"MAP_HUGETLB attempt failed, look at /sys/kernel/mm/hugepages for optimal performance\n" ); }
Signature · 1 line
2.39.1.405.gd4c25cc71f-goog
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 20 Jan 2023 18:11:36 +0000 you wrote:
In commit
72653ae5303c("selftests: net:tcp_mmap:
Use huge pages in send path") I made a change to use hugepages for the buffer used by the client (tx path)Today, I understood that the cause for poor zerocopy performance was that after a
mmap()for a 512KB memory zone, kernel uses a single zeropage, mapped 128 times.[...]
Here is the summary with links:
- [net-next] selftests: net: tcp_mmap: populate pages in send path
https://git.kernel.org/netdev/net-next/c/057fb03160a8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html