Re: [PATCH net-next v6 6/7] selftests: net: Add busy_poll_test
From: Joe Damato
Date: Tue Nov 05 2024 - 12:49:50 EST
On Mon, Nov 04, 2024 at 07:50:21PM -0800, Stanislav Fomichev wrote:
> On 11/04, Joe Damato wrote:
> > Add an epoll busy poll test using netdevsim.
> >
> > This test is comprised of:
> > - busy_poller (via busy_poller.c)
> > - busy_poll_test.sh which loads netdevsim, sets up network namespaces,
> > and runs busy_poller to receive data and socat to send data.
> >
> > The selftest tests two different scenarios:
> > - busy poll (the pre-existing version in the kernel)
> > - busy poll with suspend enabled (what this series adds)
> >
> > The data transmit is a 1MiB temporary file generated from /dev/urandom
> > and the test is considered passing if the md5sum of the input file to
> > socat matches the md5sum of the output file from busy_poller.
> >
> > netdevsim was chosen instead of veth due to netdevsim's support for
> > netdev-genl.
> >
> > For now, this test uses the functionality that netdevsim provides. In the
> > future, perhaps netdevsim can be extended to emulate device IRQs to more
> > thoroughly test all pre-existing kernel options (like defer_hard_irqs)
> > and suspend.
> >
> > Signed-off-by: Joe Damato <jdamato@xxxxxxxxxx>
> > Co-developed-by: Martin Karsten <mkarsten@xxxxxxxxxxxx>
> > Signed-off-by: Martin Karsten <mkarsten@xxxxxxxxxxxx>
> > ---
[...]
> > +
> > +static void run_poller(void)
> > +{
> > + struct epoll_event events[cfg_max_events];
> > + struct epoll_params epoll_params = {0};
> > + struct sockaddr_in server_addr;
> > + int i, epfd, nfds;
> > + ssize_t readlen;
> > + int outfile_fd;
> > + char buf[1024];
> > + int sockfd;
> > + int conn;
> > + int val;
>
> [..]
>
> > + outfile_fd = open(cfg_outfile, O_WRONLY | O_CREAT, 0644);
> > + if (outfile_fd == -1)
> > + error(1, errno, "unable to open outfile: %s", cfg_outfile);
>
> Any reason you're not printing to stdout? And then redirect it to a file
> in the shell script if needed. Lets you save some code on open/close
> and flag parsing :-p But I guess can keep it since you already have it
> all working.
No reason in particular; I thought about this while writing it, but
ended up adding it as a flag in case others come along to extend
this test in some capacity.
> Acked-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
Thanks for the ack!