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 |
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
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; }
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.
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 --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]);
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(-)