Re: [PATCH v2] epoll: add nsec timeout support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 16, 2020 at 7:37 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, 16 Nov 2020 18:51:16 -0500 Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx> wrote:
>
> > On Mon, Nov 16, 2020 at 6:36 PM Willem de Bruijn
> > <willemdebruijn.kernel@xxxxxxxxx> wrote:
> > >
> > > On Mon, Nov 16, 2020 at 3:04 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> > > >
> > > > On Mon, 16 Nov 2020 11:10:01 -0500 Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx> wrote:
> > > >
> > > > > From: Willem de Bruijn <willemb@xxxxxxxxxx>
> > > > >
> > > > > Add epoll_create1 flag EPOLL_NSTIMEO. When passed, this changes the
> > > > > interpretation of argument timeout in epoll_wait from msec to nsec.
> > > > >
> > > > > Use cases such as datacenter networking operate on timescales well
> > > > > below milliseconds. Shorter timeouts bounds their tail latency.
> > > > > The underlying hrtimer is already programmed with nsec resolution.
> > > >
> > > > hm, maybe.  It's not very nice to be using one syscall to alter the
> > > > interpretation of another syscall's argument in this fashion.  For
> > > > example, one wonders how strace(1) is to properly interpret & display
> > > > this argument?
> > > >
> > > > Did you consider adding epoll_wait2()/epoll_pwait2() syscalls which
> > > > take a nsec timeout?  Seems simpler.
> > >
> > > I took a first stab. The patch does become quite a bit more complex.
> >
> > Not complex in terms of timeout logic. Just a bigger patch, taking as
> > example the recent commit ecb8ac8b1f14 that added process_madvise.
>
> That's OK - it's mainly syscall table patchery.  The fs/ changes are
> what matters.  And the interface.
>
> > > I was not aware of how uncommon syscall argument interpretation
> > > contingent on internal object state really is. Yes, that can
> > > complicate inspection with strace, seccomp, ... This particular case
> > > seems benign to me. But perhaps it sets a precedent.
> > >
> > > A new nsec resolution epoll syscall would be analogous to pselect and
> > > ppoll, both of which switched to nsec resolution timespec.
> > >
> > > Since creating new syscalls is rare, add a flags argument at the same time?
>
> Adding a syscall is pretty cheap - it's just a table entry.

Okay. Then I won't add a flags argument now.

> > >
> > > Then I would split the change in two: (1) add the new syscall with
> > > extra flags argument, (2) define flag EPOLL_WAIT_NSTIMEO to explicitly
> > > change the time scale of the timeout argument. To avoid easy mistakes
> > > by callers in absence of stronger typing.
>
> I don't understand this.  You're proposing that the new epoll_pwait2() be
> able to take either msec or nsec, based on the flags argument?

It wasn't elegant. Superseded by the below alternative to add a timespec.

> With a
> longer-term plan to deprecate the old epoll_pwait()?

> If so, that's not likely to be viable - how can we ever know that the
> whole world stopped using the old syscall?

I don't mean to deprecate it. I noticed that epoll_wait was removed
from asm-generic/unistd.h in favor of epoll_pwait on the argument that
this should list the minimally needed syscall set. Removed in commit
a0673fdbcd42 ("asm-generic: clean up asm/unistd.h"), a descriptive
comment was earlier added in commit e64a1617eca3 ("asm-generic: add a
generic unistd.h"). If the same argument still holds, when adding
epoll_pwait2 there, I should remove epoll_pwait. But I'm admittedly
not very familiar with the implications of touching this uapi file.
Will read up.

> > Come to think of it, better to convert to timespec to both have actual
> > typing and consistency with ppoll/pselect.
>
> Sure.
>
> > > epoll_wait is missing from include/uapi/asm-generic/unistd.h as it is
> > > superseded by epoll_pwait. Following the same rationale, add
> > > epoll_pwait2 (only).
>
> Sure.
>
> > A separate RFC patch against manpages/master sent at the same time?
>
> That's the common approach - a followup saying "here's what I'll send
> to the manpages people if this gets merged".
>
> And something under tools/testing/sefltests/ would be nice, if only so
> that the various arch maintainers can verify that their new syscall is
> working correctly.  Perhaps by adding a please-use-epoll_pwait2 arg to
> the existing
> tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c, if that
> looks like a suitable testcase.

Will do both. Thanks!



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux