From: Minchan Kim <minchan@kernel.org>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: alexander.h.duyck@linux.intel.com, axboe@kernel.dk,
bgeffon@google.com, christian@brauner.io, dancol@google.com,
hannes@cmpxchg.org, jannh@google.com, joaodias@google.com,
joel@joelfernandes.org, ktkhai@virtuozzo.com,
linux-man@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com,
mm-commits@vger.kernel.org, oleksandr@redhat.com,
rientjes@google.com, shakeelb@google.com, sj38.park@gmail.com,
sjpark@amazon.de, sonnyrao@google.com, sspatil@google.com,
surenb@google.com, timmurray@google.com,
torvalds@linux-foundation.org, vbabka@suse.cz,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch 17/39] mm/madvise: introduce process_madvise() syscall: an external memory hinting API
Date: Mon, 17 Aug 2020 08:10:24 -0700 [thread overview]
Message-ID: <20200817151024.GA3852332@google.com> (raw)
In-Reply-To: <20200816081227.ngw3l45c5uncesmr@wittgenstein>
On Sun, Aug 16, 2020 at 10:12:27AM +0200, Christian Brauner wrote:
> On Fri, Aug 14, 2020 at 05:30:58PM -0700, Andrew Morton wrote:
> > From: Minchan Kim <minchan@kernel.org>
> > Subject: mm/madvise: introduce process_madvise() syscall: an external memory hinting API
> >
>
> <snip>
>
> > +SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
> > + unsigned long, vlen, int, behavior, unsigned int, flags)
> > +{
> > + ssize_t ret;
> > + struct iovec iovstack[UIO_FASTIOV];
> > + struct iovec *iov = iovstack;
> > + struct iov_iter iter;
> > +
> > + ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
> > + if (ret >= 0) {
> > + ret = do_process_madvise(pidfd, &iter, behavior, flags);
> > + kfree(iov);
> > + }
> > + return ret;
> > +}
> > +
> > +#ifdef CONFIG_COMPAT
> > +COMPAT_SYSCALL_DEFINE5(process_madvise, compat_int_t, pidfd,
> > + const struct compat_iovec __user *, vec,
> > + compat_ulong_t, vlen,
> > + compat_int_t, behavior,
> > + compat_uint_t, flags)
> > +
> > +{
> > + ssize_t ret;
> > + struct iovec iovstack[UIO_FASTIOV];
> > + struct iovec *iov = iovstack;
> > + struct iov_iter iter;
> > +
> > + ret = compat_import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack),
> > + &iov, &iter);
> > + if (ret >= 0) {
> > + ret = do_process_madvise(pidfd, &iter, behavior, flags);
> > + kfree(iov);
> > + }
> > + return ret;
> > +}
> > +#endif
>
> Note, I'm only commenting on this patch because it has already been
> dropped for this merge window. Otherwise I wouldn't interfer with stuff
> that has already been sent for inclusion.
>
> I haven't noticed this before but why do you need this
> COMPAT_SYSCALL_DEFINE5()? New code we add today tries pretty hard to
> avoid the compat syscall definitions. (See what we did for
> pidfd_send_signal(), seccomp, and in io_uring and in various other places.)
>
> Afaict, this could just be sm like (__completely untested__):
>
> static inline int madv_import_iovec(int type, const struct iovec __user *uvec, unsigned nr_segs,
> unsigned fast_segs, struct iovec **iov, struct iov_iter *i)
> {
> #ifdef CONFIG_COMPAT
> if (in_compat_syscall())
> return compat_import_iovec(type, (struct compat_iovec __user *)uvec, nr_segs,
> fast_segs, iov, i);
> #endif
>
> return import_iovec(type, uvec, nr_segs, fast_segs, iov, i);
> }
>
> SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
> unsigned long, vlen, int, behavior, unsigned int, flags)
> {
> ssize_t ret;
> struct iovec iovstack[UIO_FASTIOV];
> struct iovec *iov = iovstack;
> struct iov_iter iter;
>
> ret = madv_import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
> if (ret < 0)
> return ret;
>
> ret = do_process_madvise(pidfd, &iter, behavior, flags);
> kfree(iov);
> return ret;
> }
>
> or is there are specific reason this wouldn't work here?
No, I just didn't know such trend to avoid compact syscall definitions.
Thanks for the information.
I think your suggestion will work. Let me have it at respin.
Thanks!
next prev parent reply other threads:[~2020-08-17 15:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200814172939.55d6d80b6e21e4241f1ee1f3@linux-foundation.org>
2020-08-15 0:30 ` [patch 15/39] mm/madvise: pass task and mm to do_madvise Andrew Morton
2020-08-15 0:30 ` [patch 16/39] pid: move pidfd_get_pid() to pid.c Andrew Morton
2020-08-15 0:30 ` [patch 17/39] mm/madvise: introduce process_madvise() syscall: an external memory hinting API Andrew Morton
2020-08-16 8:12 ` Christian Brauner
2020-08-17 15:10 ` Minchan Kim [this message]
2020-08-15 0:31 ` [patch 18/39] mm/madvise: check fatal signal pending of target process Andrew Morton
2020-08-15 2:53 ` Linus Torvalds
2020-08-15 4:59 ` Minchan Kim
2020-08-15 14:57 ` Linus Torvalds
2020-08-15 18:34 ` Minchan Kim
2020-08-16 1:43 ` Linus Torvalds
2020-08-16 5:58 ` Minchan Kim
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=20200817151024.GA3852332@google.com \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=bgeffon@google.com \
--cc=christian.brauner@ubuntu.com \
--cc=christian@brauner.io \
--cc=dancol@google.com \
--cc=hannes@cmpxchg.org \
--cc=jannh@google.com \
--cc=joaodias@google.com \
--cc=joel@joelfernandes.org \
--cc=ktkhai@virtuozzo.com \
--cc=linux-man@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mm-commits@vger.kernel.org \
--cc=oleksandr@redhat.com \
--cc=rientjes@google.com \
--cc=shakeelb@google.com \
--cc=sj38.park@gmail.com \
--cc=sjpark@amazon.de \
--cc=sonnyrao@google.com \
--cc=sspatil@google.com \
--cc=surenb@google.com \
--cc=timmurray@google.com \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/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).