From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94CF7C433E3 for ; Sun, 16 Aug 2020 08:12:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 639D92065C for ; Sun, 16 Aug 2020 08:12:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 639D92065C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ubuntu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E684C6B0002; Sun, 16 Aug 2020 04:12:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF2416B0003; Sun, 16 Aug 2020 04:12:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE0D26B0005; Sun, 16 Aug 2020 04:12:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id B13226B0002 for ; Sun, 16 Aug 2020 04:12:42 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 62557181AEF1F for ; Sun, 16 Aug 2020 08:12:42 +0000 (UTC) X-FDA: 77155715364.28.edge17_1113b272700c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 38C206C3A for ; Sun, 16 Aug 2020 08:12:42 +0000 (UTC) X-HE-Tag: edge17_1113b272700c X-Filterd-Recvd-Size: 4439 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Sun, 16 Aug 2020 08:12:41 +0000 (UTC) Received: from ip5f5af70b.dynamic.kabel-deutschland.de ([95.90.247.11] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k7DmG-0000GN-Eh; Sun, 16 Aug 2020 08:12:28 +0000 Date: Sun, 16 Aug 2020 10:12:27 +0200 From: Christian Brauner To: minchan@kernel.org 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 Subject: Re: [patch 17/39] mm/madvise: introduce process_madvise() syscall: an external memory hinting API Message-ID: <20200816081227.ngw3l45c5uncesmr@wittgenstein> References: <20200814172939.55d6d80b6e21e4241f1ee1f3@linux-foundation.org> <20200815003058.6OQJpEXTM%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200815003058.6OQJpEXTM%akpm@linux-foundation.org> X-Rspamd-Queue-Id: 38C206C3A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Aug 14, 2020 at 05:30:58PM -0700, Andrew Morton wrote: > From: Minchan Kim > Subject: mm/madvise: introduce process_madvise() syscall: an external memory hinting API > > +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? Christian