Netdev List
 help / color / mirror / Atom feed
From: David Wei <dw@davidwei.uk>
To: Juanlu Herrero <juanlu@fastmail.com>, netdev@vger.kernel.org
Cc: io-uring@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, kuba@kernel.org,
	asml.silence@gmail.com, pabeni@redhat.com, shuah@kernel.org
Subject: Re: [PATCH net-next v5 4/6] selftests: net: add multithread client support to iou-zcrx
Date: Fri, 14 Aug 2026 09:04:35 -0700	[thread overview]
Message-ID: <7e1a7fab-ea77-4373-ba7d-a3ce5aa73ba1@davidwei.uk> (raw)
In-Reply-To: <20260814012348.46958-5-juanlu@fastmail.com>

On 2026-08-13 18:23, Juanlu Herrero wrote:
> Add pthreads to the iou-zcrx client so that multiple connections can be
> established simultaneously. Each client thread connects to the server
> and sends its payload independently.
> 
> Introduce the -t option to control the number of threads (default 1),
> preserving backwards compatibility with existing tests.
> 
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Juanlu Herrero <juanlu@fastmail.com>
> ---
>   .../testing/selftests/drivers/net/hw/Makefile |  2 +-
>   .../selftests/drivers/net/hw/iou-zcrx.c       | 35 +++++++++++++++++--
>   2 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
> index 78bb0169350b2..37023ba580de7 100644
> --- a/tools/testing/selftests/drivers/net/hw/Makefile
> +++ b/tools/testing/selftests/drivers/net/hw/Makefile
> @@ -91,5 +91,5 @@ include ../../../net/ynl.mk
>   include ../../../net/bpf.mk
>   
>   ifeq ($(HAS_IOURING_ZCRX),y)
> -$(OUTPUT)/iou-zcrx: LDLIBS += -luring
> +$(OUTPUT)/iou-zcrx: LDLIBS += -luring -lpthread
>   endif
> diff --git a/tools/testing/selftests/drivers/net/hw/iou-zcrx.c b/tools/testing/selftests/drivers/net/hw/iou-zcrx.c
> index 9b62fd0703e61..f793a6c04e412 100644
> --- a/tools/testing/selftests/drivers/net/hw/iou-zcrx.c
> +++ b/tools/testing/selftests/drivers/net/hw/iou-zcrx.c
> @@ -4,6 +4,7 @@
>   #include <error.h>
>   #include <fcntl.h>
>   #include <limits.h>
> +#include <pthread.h>
>   #include <stdbool.h>
>   #include <stdint.h>
>   #include <stdio.h>
> @@ -85,6 +86,7 @@ static int cfg_send_size = SEND_SIZE;
>   static struct sockaddr_in6 cfg_addr;
>   static unsigned int cfg_rx_buf_len;
>   static bool cfg_dry_run;
> +static int cfg_num_threads = 1;
>   
>   static char *payload;
>   
> @@ -379,7 +381,7 @@ static void run_server(void)
>   		error(1, 0, "test failed\n");
>   }
>   
> -static void run_client(void)
> +static void *client_worker(void *arg)
>   {
>   	ssize_t to_send = cfg_send_size;
>   	ssize_t sent = 0;
> @@ -405,12 +407,36 @@ static void run_client(void)
>   	}
>   
>   	close(fd);
> +	return NULL;
> +}
> +
> +static void run_client(void)
> +{
> +	int total_conns = cfg_num_threads * cfg_num_threads;
> +	pthread_t *threads;
> +	int i, ret;
> +
> +	threads = calloc(total_conns, sizeof(*threads));
> +	if (!threads)
> +		error(1, 0, "calloc()");
> +
> +	for (i = 0; i < total_conns; i++) {
> +		ret = pthread_create(&threads[i], NULL, client_worker, NULL);
> +		if (ret)
> +			error(1, ret, "pthread_create()");
> +	}
> +
> +	for (i = 0; i < total_conns; i++)
> +		pthread_join(threads[i], NULL);
> +
> +	free(threads);
>   }
>   
>   static void usage(const char *filepath)
>   {
>   	error(1, 0, "Usage: %s (-4|-6) (-s|-c) -h<server_ip> -p<port> "
> -		    "-l<payload_size> -i<ifname> -q<rxq_id>", filepath);
> +		    "-l<payload_size> -i<ifname> -q<rxq_id> -t<num_threads>",
> +		    filepath);
>   }
>   
>   static void parse_opts(int argc, char **argv)
> @@ -428,7 +454,7 @@ static void parse_opts(int argc, char **argv)
>   		usage(argv[0]);
>   	cfg_payload_len = max_payload_len;
>   
> -	while ((c = getopt(argc, argv, "sch:p:l:i:q:o:z:x:d")) != -1) {
> +	while ((c = getopt(argc, argv, "sch:p:l:i:q:o:z:x:dt:")) != -1) {
>   		switch (c) {
>   		case 's':
>   			if (cfg_client)
> @@ -469,6 +495,9 @@ static void parse_opts(int argc, char **argv)
>   		case 'd':
>   			cfg_dry_run = true;
>   			break;
> +		case 't':
> +			cfg_num_threads = strtoul(optarg, NULL, 0);
> +			break;
>   		}
>   	}
>   

Reviewed-by: David Wei <dw@davidwei.uk>

  reply	other threads:[~2026-08-14 16:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  1:23 [PATCH net-next v5 0/6] selftests: net: multithreaded multiqueue iou-zcrx Juanlu Herrero
2026-08-14  1:23 ` [PATCH net-next v5 1/6] selftests: net: fix get_refill_ring_size() to use its local variable Juanlu Herrero
2026-08-14  1:23 ` [PATCH net-next v5 2/6] selftests: net: remove unused variable in process_recvzc() Juanlu Herrero
2026-08-14  1:23 ` [PATCH net-next v5 3/6] selftests: net: refactor server state into struct thread_ctx Juanlu Herrero
2026-08-14 16:06   ` David Wei
2026-08-14  1:23 ` [PATCH net-next v5 4/6] selftests: net: add multithread client support to iou-zcrx Juanlu Herrero
2026-08-14 16:04   ` David Wei [this message]
2026-08-14  1:23 ` [PATCH net-next v5 5/6] selftests: net: add multithread server " Juanlu Herrero
2026-08-14 15:50   ` David Wei
2026-08-14  1:23 ` [PATCH net-next v5 6/6] selftests: net: add rss_multiqueue test variant " Juanlu Herrero
2026-08-14 16:01   ` David Wei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e1a7fab-ea77-4373-ba7d-a3ce5aa73ba1@davidwei.uk \
    --to=dw@davidwei.uk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=juanlu@fastmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox