* [PATCH net-next] selftests: net: tcp_mmap should create detached threads
@ 2019-11-14 16:43 Eric Dumazet
2019-11-15 20:46 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2019-11-14 16:43 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet
Since we do not plan using pthread_join() in the server do_accept()
loop, we better create detached threads, or risk increasing memory
footprint over time.
Fixes: 192dc405f308 ("selftests: net: add tcp_mmap program")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
tools/testing/selftests/net/tcp_mmap.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index 31ced79f4f25de89afe95a7214600b2eae42f057..0e73a30f0c2262e62a5ed1e2db6c7c8977bf44fa 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -270,6 +270,11 @@ static void setup_sockaddr(int domain, const char *str_addr,
static void do_accept(int fdlisten)
{
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
if (setsockopt(fdlisten, SOL_SOCKET, SO_RCVLOWAT,
&chunk_size, sizeof(chunk_size)) == -1) {
perror("setsockopt SO_RCVLOWAT");
@@ -288,7 +293,7 @@ static void do_accept(int fdlisten)
perror("accept");
continue;
}
- res = pthread_create(&th, NULL, child_thread,
+ res = pthread_create(&th, &attr, child_thread,
(void *)(unsigned long)fd);
if (res) {
errno = res;
--
2.24.0.432.g9d3f5f5b63-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] selftests: net: tcp_mmap should create detached threads
2019-11-14 16:43 [PATCH net-next] selftests: net: tcp_mmap should create detached threads Eric Dumazet
@ 2019-11-15 20:46 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-11-15 20:46 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet
From: Eric Dumazet <edumazet@google.com>
Date: Thu, 14 Nov 2019 08:43:27 -0800
> Since we do not plan using pthread_join() in the server do_accept()
> loop, we better create detached threads, or risk increasing memory
> footprint over time.
>
> Fixes: 192dc405f308 ("selftests: net: add tcp_mmap program")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-15 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 16:43 [PATCH net-next] selftests: net: tcp_mmap should create detached threads Eric Dumazet
2019-11-15 20:46 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).