Re: [RFC PATCH 2/3] mm/mempolicy: Implement set_mempolicy2 and get_mempolicy2 syscalls

Gregory Price
2023-10-02T15:31:06Z

On Mon, Oct 02, 2023 at 02:30:08PM +0100, Jonathan Cameron wrote:
> On Thu, 14 Sep 2023 19:54:56 -0400
> Gregory Price <gourry.memverge@gmail.com> wrote:
>
> > diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
> > index abe087c53b4b..397dcf804941 100644
> > --- a/include/uapi/asm-generic/unistd.h
> > +++ b/include/uapi/asm-generic/unistd.h
> > ...
> > #undef __NR_syscalls
> > -#define __NR_syscalls 453
> > +#define __NR_syscalls 456
> +3 for 2 additions?
>

When i'd originally written this, there was a partially merged syscall
colliding with 453, and this hadn't been incremented yet. Did a quick
grep and it seems like that might have been reverted, so yeah this would
drop down to 453/454 & __NR=455.

> > + /* Legacy modes are routed through the legacy interface */
> > + if (kargs->mode <= MPOL_LEGACY)
> > + return false;
> > +
> > + if (kargs->mode >= MPOL_MAX)
> > + return false;
> > +
> > + return true;
>
> This is a range check, so I think equally clear (and shorter) as..
> /* Legacy modes are routed through the legacy interface */
> return kargs->mode > MPOL_LEGACY && kargs->mode < MPOL_MAX;
>

I'll combine the range, but i left the two true/false conditions
separate because it's intended that follow on patches will add logic
before true is returned.

> > + kargs->get.allowed.err = err ? err : 0;
> > + kargs->err |= err ? err : 1;
> if (err) {
> kargs->get.allowed.err = err;
> kargs->err |= err;
> } else {
> kargs->get.allowed.err = 0;
> kargs->err = 1;
> Not particularly obvious why 1 and if you get an error later it's going to be messy
> as will 1 |= err_code

My original intent was to just allow each section to error separately,
but honestly this seems overly complicated and somewhat against the
design of almost every other syscall, so i'm going to rip all these
error code spaces out and instead just have everything return on error.

Thanks!
Gregory