Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: tcp_mmap: Use huge pages in receive path

One down side of using TCP rx zerocopy is one extra TLB miss
per page after the mapping operation.

While if the application is using hugepages, the non zerocopy
recvmsg() will not have to pay these TLB costs.

This patch allows server side to use huge pages for
the non zero copy case, to allow fair comparisons when
both solutions use optimal conditions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Arjun Roy <arjunroy@google.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
59c0d319 72653ae5

+5 -4
+5 -4
tools/testing/selftests/net/tcp_mmap.c
··· 157 157 void *addr = NULL; 158 158 double throughput; 159 159 struct rusage ru; 160 + size_t buffer_sz; 160 161 int lu, fd; 161 162 162 163 fd = (int)(unsigned long)arg; ··· 165 164 gettimeofday(&t0, NULL); 166 165 167 166 fcntl(fd, F_SETFL, O_NDELAY); 168 - buffer = malloc(chunk_size); 169 - if (!buffer) { 170 - perror("malloc"); 167 + buffer = mmap_large_buffer(chunk_size, &buffer_sz); 168 + if (buffer == (void *)-1) { 169 + perror("mmap"); 171 170 goto error; 172 171 } 173 172 if (zflg) { ··· 257 256 ru.ru_nvcsw); 258 257 } 259 258 error: 260 - free(buffer); 259 + munmap(buffer, buffer_sz); 261 260 close(fd); 262 261 if (zflg) 263 262 munmap(raddr, chunk_size + map_align);