linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>,
	David Laight <David.Laight@aculab.com>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Soheil Hassas Yeganeh <soheil.kdev@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>, Shuo Chen <shuochen@google.com>,
	linux-man <linux-man@vger.kernel.org>
Subject: Re: [PATCH v3 1/2] epoll: add nsec timeout support with epoll_pwait2
Date: Mon, 11 Jan 2021 15:06:15 -0500	[thread overview]
Message-ID: <CAF=yD-JskHu0oBBTaRT_v7MZNEdgtYN3BmiexqjAgJV1hBKkEw@mail.gmail.com> (raw)
In-Reply-To: <CAF=yD-LAzjyNRy0vqToWqx5LxeQMYY3fVzV0vr0X7Q70ZAR-AQ@mail.gmail.com>

On Thu, Dec 10, 2020 at 5:59 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Thu, Dec 10, 2020 at 3:34 PM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > On Thu, Dec 10, 2020 at 6:33 PM Willem de Bruijn
> > <willemdebruijn.kernel@gmail.com> wrote:
> > > On Sat, Nov 21, 2020 at 4:27 AM Arnd Bergmann <arnd@kernel.org> wrote:
> > > > On Fri, Nov 20, 2020 at 11:28 PM Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
> > > > I would imagine this can be done like the way I proposed
> > > > for get_bitmap() in sys_migrate_pages:
> > > >
> > > > https://lore.kernel.org/lkml/20201102123151.2860165-4-arnd@kernel.org/
> > >
> > > Coming back to this. Current patchset includes new select and poll
> > > selftests to verify the changes. I need to send a small kselftest
> > > patch for that first.
> > >
> > > Assuming there's no time pressure, I will finish up and send the main
> > > changes after the merge window, for the next release then.
> > >
> > > Current state against linux-next at
> > > https://github.com/wdebruij/linux-next-mirror/tree/select-compat-1
> >
> > Ok, sounds good to me. I've had a (very brief) look and have one
> > suggestion: instead of open-coding the compat vs native mode
> > in multiple places like
> >
> > if (!in_compat_syscall())
> >      return copy_from_user(fdset, ufdset, FDS_BYTES(nr)) ? -EFAULT : 0;
> > else
> >      return compat_get_bitmap(fdset, ufdset, nr);
> >
> > maybe move this into a separate function and call that where needed.
> >
> > I've done this for the get_bitmap() function in my series at
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/commit/?h=compat-alloc-user-space-7&id=b1b23ebb12b635654a2060df49455167a142c5d2
> >
> > The definition is slightly differrent for cpumask, nodemask and fd_set,
> > so we'd need to try out the best way to structure the code to end
> > up with the most readable version, but it should be possible when
> > there are only three callers (and duplicating the function would
> > be the end of the world either)
>
> For fd_set there is only a single caller for each direction. Do you
> prefer helpers even so?
>
> For sigmask, with three callers, something along the lines of this?
>
>   @@ -1138,10 +1135,7 @@ static int do_ppoll(struct pollfd __user
> *ufds, unsigned int nfds,
>                           return -EINVAL;
>           }
>
>   -       if (!in_compat_syscall())
>   -               ret = set_user_sigmask(sigmask, sigsetsize);
>   -       else
>   -               ret = set_compat_user_sigmask(sigmask, sigsetsize);
>   +       ret = set_maybe_compat_user_sigmask(sigmask, sigsetsize);
>           if (ret)
>                   return ret;
>
>   --- a/include/linux/compat.h
>   +++ b/include/linux/compat.h
>   @@ -942,6 +942,17 @@ static inline bool in_compat_syscall(void) {
> return false; }
>
>   +static inline int set_maybe_compat_user_sigmask(const void __user *sigmask,
>   +                                               size_t sigsetsize)
>   +{
>   +#if defined CONFIG_COMPAT
>   +       if (unlikely(in_compat_syscall()))
>   +               return set_compat_user_sigmask(sigmask, sigsetsize);
>   +#endif
>   +
>   +       return set_user_sigmask(sigmask, sigsetsize);
>   +}

set_user_sigmask is the only open-coded variant that is used more than once.

Because it is used in both select.c and eventpoll.c, a helper would
have to live in compat.h. This then needs a new dependency on
sched_signal.h.

So given that this is a simple branch, it might just make logic more
complex, instead of less. I can add this change in a separate patch on
top of the original three, to judge whether it is worthwhile.

  reply	other threads:[~2021-01-11 20:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 14:46 [PATCH v3 0/2] add epoll_pwait2 syscall Willem de Bruijn
2020-11-18 14:46 ` [PATCH v3 1/2] epoll: add nsec timeout support with epoll_pwait2 Willem de Bruijn
2020-11-18 15:00   ` Matthew Wilcox
2020-11-18 15:10     ` Willem de Bruijn
2020-11-18 15:37       ` Arnd Bergmann
2020-11-18 15:59         ` David Laight
2020-11-19 14:19           ` Willem de Bruijn
2020-11-19 14:31             ` Matthew Wilcox
2020-11-19 15:37               ` Willem de Bruijn
2020-11-19 15:45               ` Arnd Bergmann
2020-11-19 20:13                 ` Willem de Bruijn
2020-11-20  8:13                   ` Arnd Bergmann
2020-11-20 16:01                     ` Willem de Bruijn
2020-11-20 19:23                       ` Arnd Bergmann
2020-11-20 22:28                         ` Willem de Bruijn
2020-11-21  9:27                           ` Arnd Bergmann
2020-12-10 17:33                             ` Willem de Bruijn
2020-12-10 20:34                               ` Arnd Bergmann
2020-12-10 22:59                                 ` Willem de Bruijn
2021-01-11 20:06                                   ` Willem de Bruijn [this message]
2020-11-18 16:21   ` Willem de Bruijn
2020-11-18 16:50     ` Arnd Bergmann
2020-11-19  3:22       ` Willem de Bruijn
2020-11-18 14:46 ` [PATCH manpages RFC] epoll_wait.2: add epoll_pwait2 Willem de Bruijn
2020-11-18 14:46 ` [PATCH v3 2/2] selftests/filesystems: expand epoll with epoll_pwait2 Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF=yD-JskHu0oBBTaRT_v7MZNEdgtYN3BmiexqjAgJV1hBKkEw@mail.gmail.com' \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=shuochen@google.com \
    --cc=soheil.kdev@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).