diff mbox series

[net-next,11/13] selftests: ncdevmem: Remove hard-coded queue numbers

Message ID 20240912171251.937743-12-sdf@fomichev.me (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series selftests: ncdevmem: Add ncdevmem to ksft | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch warning WARNING: line length of 96 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-09-13--00-00 (tests: 536)

Commit Message

Stanislav Fomichev Sept. 12, 2024, 5:12 p.m. UTC
Use single last queue of the device and probe it dynamically.

Cc: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
 tools/testing/selftests/net/ncdevmem.c | 40 ++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

Comments

Mina Almasry Sept. 12, 2024, 8:34 p.m. UTC | #1
On Thu, Sep 12, 2024 at 10:13 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
>
> Use single last queue of the device and probe it dynamically.
>

Can we use the last N queues, instead of 1? Or the last half of the queues?

Test coverage that we can bind multiple queues at once is important, I think.

--
Thanks,
Mina
Stanislav Fomichev Sept. 12, 2024, 9:47 p.m. UTC | #2
On 09/12, Mina Almasry wrote:
> On Thu, Sep 12, 2024 at 10:13 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > Use single last queue of the device and probe it dynamically.
> >
> 
> Can we use the last N queues, instead of 1? Or the last half of the queues?
> 
> Test coverage that we can bind multiple queues at once is important, I think.

Anything against doing this in the selftest/probe part?

if (probe) {
	if (start_queue > 1) {
		/* make sure can bind to multiple queues */
		start_queue -= 1;
		num_queues +=1;
	}
	run_devmem_tests();
	return 0;
}
Mina Almasry Sept. 26, 2024, 4:26 p.m. UTC | #3
On Thu, Sep 12, 2024 at 2:47 PM Stanislav Fomichev <stfomichev@gmail.com> wrote:
>
> On 09/12, Mina Almasry wrote:
> > On Thu, Sep 12, 2024 at 10:13 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> > >
> > > Use single last queue of the device and probe it dynamically.
> > >
> >
> > Can we use the last N queues, instead of 1? Or the last half of the queues?
> >
> > Test coverage that we can bind multiple queues at once is important, I think.
>
> Anything against doing this in the selftest/probe part?
>
> if (probe) {
>         if (start_queue > 1) {
>                 /* make sure can bind to multiple queues */
>                 start_queue -= 1;
>                 num_queues +=1;

Sorry for the late reply, this particular thread slipped my inbox.

Overriding user-provided configs here doesn't seem great. It's nice to
be able to launch ncdevmem requesting 1 queue to be bound or multiple,
and I had the idea that in the future the tests can be improved to
verify that multiple concurrent connections on multiple queues can be
handled correctly, in case we run into any bugs that can only be
reproduced in this setup.
Stanislav Fomichev Sept. 27, 2024, 1:20 a.m. UTC | #4
On 09/26, Mina Almasry wrote:
> On Thu, Sep 12, 2024 at 2:47 PM Stanislav Fomichev <stfomichev@gmail.com> wrote:
> >
> > On 09/12, Mina Almasry wrote:
> > > On Thu, Sep 12, 2024 at 10:13 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> > > >
> > > > Use single last queue of the device and probe it dynamically.
> > > >
> > >
> > > Can we use the last N queues, instead of 1? Or the last half of the queues?
> > >
> > > Test coverage that we can bind multiple queues at once is important, I think.
> >
> > Anything against doing this in the selftest/probe part?
> >
> > if (probe) {
> >         if (start_queue > 1) {
> >                 /* make sure can bind to multiple queues */
> >                 start_queue -= 1;
> >                 num_queues +=1;
> 
> Sorry for the late reply, this particular thread slipped my inbox.

So what's better? Hard-coding start_queue and num_queues to 8?
This is only for the purpose of self testing, not sure we really care.
 
> Overriding user-provided configs here doesn't seem great. It's nice to
> be able to launch ncdevmem requesting 1 queue to be bound or multiple,
> and I had the idea that in the future the tests can be improved to
> verify that multiple concurrent connections on multiple queues can be
> handled correctly, in case we run into any bugs that can only be
> reproduced in this setup.

Currently, having multiple queues doesn't make any sense because there
is only a single receiver. I have some patches to have a thread per
receiver, can post them if you're interested (after we sort out this
series).
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
index f5cfaafb6509..3883a67d387f 100644
--- a/tools/testing/selftests/net/ncdevmem.c
+++ b/tools/testing/selftests/net/ncdevmem.c
@@ -45,8 +45,8 @@ 
 
 static char *server_ip;
 static char *port;
-static int start_queue = 8;
-static int num_queues = 8;
+static int start_queue = -1;
+static int num_queues = 1;
 static char *ifname;
 static unsigned int ifindex;
 static unsigned int dmabuf_id;
@@ -171,6 +171,33 @@  static void print_nonzero_bytes(void *ptr, size_t size)
 		putchar(p[i]);
 }
 
+static int rxq_num(int ifindex)
+{
+	struct ethtool_channels_get_req *req;
+	struct ethtool_channels_get_rsp *rsp;
+	struct ynl_error yerr;
+	struct ynl_sock *ys;
+	int num = -1;
+
+	ys = ynl_sock_create(&ynl_ethtool_family, &yerr);
+	if (!ys) {
+		fprintf(stderr, "YNL: %s\n", yerr.msg);
+		return -1;
+	}
+
+	req = ethtool_channels_get_req_alloc();
+	ethtool_channels_get_req_set_header_dev_index(req, ifindex);
+	rsp = ethtool_channels_get(ys, req);
+	if (rsp)
+		num = rsp->rx_count + rsp->combined_count;
+	ethtool_channels_get_req_free(req);
+	ethtool_channels_get_rsp_free(rsp);
+
+	ynl_sock_destroy(ys);
+
+	return num;
+}
+
 #define run_command(cmd, ...)                                           \
 	({                                                              \
 		char command[256];                                      \
@@ -630,6 +657,15 @@  int main(int argc, char *argv[])
 
 	ifindex = if_nametoindex(ifname);
 
+	if (start_queue < 0) {
+		start_queue = rxq_num(ifindex) - 1;
+
+		if (start_queue < 0)
+			error(1, 0, "couldn't detect number of queues\n");
+
+		fprintf(stderr, "using queues %d..%d\n", start_queue, start_queue + num_queues);
+	}
+
 	for (; optind < argc; optind++)
 		fprintf(stderr, "extra arguments: %s\n", argv[optind]);