[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zy5QmNT5XqZUJ3f8@LQ3V64L9R2>
Date: Fri, 8 Nov 2024 09:55:36 -0800
From: Joe Damato <jdamato@...tly.com>
To: Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc: netdev@...r.kernel.org, corbet@....net, hdanton@...a.com,
bagasdotme@...il.com, pabeni@...hat.com, namangulati@...gle.com,
edumazet@...gle.com, amritha.nambiar@...el.com,
sridhar.samudrala@...el.com, sdf@...ichev.me, peter@...eblog.net,
m2shafiei@...terloo.ca, bjorn@...osinc.com, hch@...radead.org,
willy@...radead.org, skhawaja@...gle.com, kuba@...nel.org,
Martin Karsten <mkarsten@...terloo.ca>,
"David S. Miller" <davem@...emloft.net>,
Simon Horman <horms@...nel.org>, Shuah Khan <shuah@...nel.org>,
open list <linux-kernel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH net-next v8 5/6] selftests: net: Add busy_poll_test
On Fri, Nov 08, 2024 at 09:57:48AM -0500, Willem de Bruijn wrote:
> Joe Damato wrote:
[...]
> > diff --git a/tools/testing/selftests/net/busy_poller.c b/tools/testing/selftests/net/busy_poller.c
> > new file mode 100644
> > index 000000000000..8d8aa9e5939a
> > --- /dev/null
> > +++ b/tools/testing/selftests/net/busy_poller.c
> > @@ -0,0 +1,328 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +#include <assert.h>
> > +#include <errno.h>
> > +#include <error.h>
> > +#include <fcntl.h>
> > +#include <inttypes.h>
> > +#include <limits.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <unistd.h>
> > +
> > +#include <arpa/inet.h>
> > +#include <netinet/in.h>
> > +
> > +#include <sys/ioctl.h>
> > +#include <sys/epoll.h>
> > +#include <sys/socket.h>
> > +#include <sys/types.h>
> > +
> > +#include <linux/netlink.h>
> > +#include <linux/genetlink.h>
> > +#include "netdev-user.h"
> > +#include <ynl.h>
> > +
> > +/* if the headers haven't been updated, we need to define some things */
>
> This should not be needed, as headers are taken from $KERNELSRC/usr after
> make headers_install.
>
> Generally discouraged for tests (else every new feature test for a new
> features is forced to adds such checks).
I get that, but the reason this is required is complex:
- sys/epoll.h defines epoll_data, which is needed by the program to
access stuff like epoll_event.data.fd and linux/eventpoll.h does
not. At the same time, older glibcs do not have the ioctl yet
(I've sent a change to glibc to add it; I don't know which release
it'll be in or when CI will be updated to a distro with that
glibc).
- linux/eventpoll.h does not define epoll_event's data field, it's
simply an opaque "__u64 data", but does include the ioctl
definitions.
So, it'd seem I'd need parts of both headers... but of course you
can't include both, because they redefine types found in the other.
Maybe there's a solution I'm missing (please let me know), but it
seems that the only workable solution is to include the #ifdef blob
below, but perhaps with a comment explaining the above.
> > +#if !defined(EPOLL_IOC_TYPE)
> > +struct epoll_params {
> > + uint32_t busy_poll_usecs;
> > + uint16_t busy_poll_budget;
> > + uint8_t prefer_busy_poll;
> > +
> > + /* pad the struct to a multiple of 64bits */
> > + uint8_t __pad;
> > +};
> > +
> > +#define EPOLL_IOC_TYPE 0x8A
> > +#define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params)
> > +#define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params)
> > +#endif
Powered by blists - more mailing lists