[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHS8izMUuS95ksQSKUQgTwFU-i5xh4dyGwHRavNRON_rS=9FrA@mail.gmail.com>
Date: Wed, 21 May 2025 12:08:49 -0700
From: Mina Almasry <almasrymina@...gle.com>
To: Stanislav Fomichev <stfomichev@...il.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, viro@...iv.linux.org.uk, horms@...nel.org,
andrew+netdev@...n.ch, shuah@...nel.org, sagi@...mberg.me, willemb@...gle.com,
asml.silence@...il.com, jdamato@...tly.com, kaiyuanz@...gle.com,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net-next 2/3] selftests: ncdevmem: make chunking optional
On Wed, May 21, 2025 at 10:39 AM Stanislav Fomichev
<stfomichev@...il.com> wrote:
>
> On 05/21, Mina Almasry wrote:
> > On Tue, May 20, 2025 at 1:30 PM Stanislav Fomichev <stfomichev@...il.com> wrote:
> > >
> > > Add new -z argument to specify max IOV size. By default, use
> > > single large IOV.
> > >
> > > Signed-off-by: Stanislav Fomichev <stfomichev@...il.com>
> > > ---
> > > .../selftests/drivers/net/hw/ncdevmem.c | 49 +++++++++++--------
> > > 1 file changed, 29 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> > > index ca723722a810..fc7ba7d71502 100644
> > > --- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> > > +++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> > > @@ -82,6 +82,9 @@
> > > #define MSG_SOCK_DEVMEM 0x2000000
> > > #endif
> > >
> > > +#define MAX_IOV 1024
> > > +
> > > +static size_t max_chunk;
> > > static char *server_ip;
> > > static char *client_ip;
> > > static char *port;
> > > @@ -834,10 +837,10 @@ static int do_client(struct memory_buffer *mem)
> > > struct sockaddr_in6 server_sin;
> > > struct sockaddr_in6 client_sin;
> > > struct ynl_sock *ys = NULL;
> > > + struct iovec iov[MAX_IOV];
> > > struct msghdr msg = {};
> > > ssize_t line_size = 0;
> > > struct cmsghdr *cmsg;
> > > - struct iovec iov[2];
> > > char *line = NULL;
> > > unsigned long mid;
> > > size_t len = 0;
> > > @@ -893,27 +896,29 @@ static int do_client(struct memory_buffer *mem)
> > > if (line_size < 0)
> > > break;
> > >
> > > - mid = (line_size / 2) + 1;
> > > -
> > > - iov[0].iov_base = (void *)1;
> > > - iov[0].iov_len = mid;
> > > - iov[1].iov_base = (void *)(mid + 2);
> > > - iov[1].iov_len = line_size - mid;
> > > + if (max_chunk) {
> > > + msg.msg_iovlen =
> > > + (line_size + max_chunk - 1) / max_chunk;
> > > + if (msg.msg_iovlen > MAX_IOV)
> > > + error(1, 0,
> > > + "can't partition %zd bytes into maximum of %d chunks",
> > > + line_size, MAX_IOV);
> > >
> > > - provider->memcpy_to_device(mem, (size_t)iov[0].iov_base, line,
> > > - iov[0].iov_len);
> > > - provider->memcpy_to_device(mem, (size_t)iov[1].iov_base,
> > > - line + iov[0].iov_len,
> > > - iov[1].iov_len);
> > > + for (int i = 0; i < msg.msg_iovlen; i++) {
> > > + iov[i].iov_base = (void *)(i * max_chunk);
> > > + iov[i].iov_len = max_chunk;
> >
> > Isn't the last iov going to be truncated in the case where line_size
> > is not exactly divisible with max_chunk?
>
> I have this for the last iov entry:
>
> iov[msg.msg_iovlen - 1].iov_len =
> line_size - (msg.msg_iovlen - 1) * max_chunk;
>
> I think that should correctly adjust it to the remaining 1..max_chunk
> len?
>
Thanks, I missed that line.
Reviewed-by: Mina Almasry <almasrymina@...gle.com>
--
Thanks,
Mina
Powered by blists - more mailing lists