From patchwork Sat Aug 26 07:40:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9923221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 70C13608A6 for ; Sat, 26 Aug 2017 07:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F303285C2 for ; Sat, 26 Aug 2017 07:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 528B3285C1; Sat, 26 Aug 2017 07:42:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BBE1285C2 for ; Sat, 26 Aug 2017 07:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752068AbdHZHlm (ORCPT ); Sat, 26 Aug 2017 03:41:42 -0400 Received: from mout.gmx.net ([212.227.15.18]:53487 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbdHZHlk (ORCPT ); Sat, 26 Aug 2017 03:41:40 -0400 Received: from ls3530.fritz.box ([193.159.24.126]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LmKag-1dCzyQ3cfK-00Zu9F; Sat, 26 Aug 2017 09:40:53 +0200 Date: Sat, 26 Aug 2017 09:40:47 +0200 From: Helge Deller To: Dan Williams Cc: Helge Deller , "Kirill A. Shutemov" , Christoph Hellwig , Andrew Morton , Jan Kara , Arnd Bergmann , "linux-nvdimm@lists.01.org" , Linux API , "linux-kernel@vger.kernel.org" , linux-xfs@vger.kernel.org, Linux MM , Andy Lutomirski , linux-fsdevel , "Kirill A. Shutemov" , linux-parisc@vger.kernel.org Subject: Re: [PATCH v6 3/5] mm: introduce mmap3 for safely defining new mmap flags Message-ID: <20170826074047.GA6292@ls3530.fritz.box> References: <150353211413.5039.5228914877418362329.stgit@dwillia2-desk3.amr.corp.intel.com> <150353213097.5039.6729469069608762658.stgit@dwillia2-desk3.amr.corp.intel.com> <20170824165546.GA3121@infradead.org> <20170825130011.GA30072@infradead.org> <20170825155803.4km7wttzadfqw2vb@node.shutemov.name> <20170825160236.GA2561@infradead.org> <20170825161607.6v6beg4zjktllt2z@node.shutemov.name> <4de21e8d-5e10-ec40-c731-0c079953cf48@gmx.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Provags-ID: V03:K0:IxLKGCnk1BXfMZ/85m1KRoIvDJZiXw3VxEvOYfiq5GIzMVAY4QD EkYpcIjfl3iNtlbJ7M85ch0Emv4x/j436NFdxvVRUmXMkZ3/uvIL3rjFXAP78bQbUWOcAsQ b1gJ/bxK0mco3DS5yrNHtc5RgVPg2l3Y3NHzeWdxcrYc3db/6Wnm8AqNahRdKJ8zMU13jeQ vh7iVhto1Scvc4K0+hMvQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:OX1YnDxQcB4=:SUfr/R6Unnrn+YLDoiPUF+ XOPLWzs2/7+j7B2IQLwvBoyd7sTvi8sQ41xby53VkcBwac7xtOR/AEmAKsYYRzgomk2YbUAut WXOxzy/39SdldtcBL6PzV/x8O3uVUMhDHcUR6L5Wq6ODIQlS5WxEEOTawUgKGN1RMaXzKYWS2 lsL2Pz4EIVocH5oJs1byffdgKr6tKlJ24iM4bRyR4VbBtFW/o+fL/etC/uVY8G3oQYt+/aln8 aEQBTJUJOPqBKvKB0dQdk+w2xjn/Ar+KL/VPh9p8WOUPpaKPQcCnzCuIiEOoDgKIWVigqCLcN rb2sSJ4mCGuXL4LianZboHSAvcMr3Azz10lIpfQJoc3xfGc8ukJNO/IsGpaV9YUO033vubc/h KGgF3MR7PuoxS9kKz1gaDs0dFkXuvzQTWNawLbCx5uY6FbOmRL+uVw2QDMFCqsxw+zpqiynki rVL0739Uh8kWvQrl3kx3RSvNMnxui/K9s3YeZjHQyzW1TokTtuBhY7OKRnfYihEh5sSuwz369 Vf3djyz79Qo5gl2CGumOjK7WwpLxZSt4X4kriHymeCSsOdz/UMzoqoaKGsBsJpf5voljP6qmw LpO15vq9N+9phiniXI8WNOJebm+ocn1ShY3HK9T7u8X8YvxYkX0x9+FXihrmTuev+JmqCmori MCzm0ntsKpke0eeV5Z2SKofJOqVdcsGv6Y72aR+NyMen+y7T7lvujjHL8LP1bZGA9k05UJPh4 1tBy2Z/ZAbuaV0jt0/0n3t/cBhZXa9ZHM6rzSQV7OA3rkHgGKwuQrfnPAB/NQIrXWfSLKKmV0 BDSrWh5X4WdgySdTCelfo1bQyWPYw== Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Dan Williams : > On Fri, Aug 25, 2017 at 9:19 AM, Helge Deller wrote: > > On 25.08.2017 18:16, Kirill A. Shutemov wrote: > >> On Fri, Aug 25, 2017 at 09:02:36AM -0700, Christoph Hellwig wrote: > >>> On Fri, Aug 25, 2017 at 06:58:03PM +0300, Kirill A. Shutemov wrote: > >>>> Not all archs are ready for this: > >>>> > >>>> arch/parisc/include/uapi/asm/mman.h:#define MAP_TYPE 0x03 /* Mask for type of mapping */ > >>>> arch/parisc/include/uapi/asm/mman.h:#define MAP_FIXED 0x04 /* Interpret addr exactly */ > >>> > >>> I'd be happy to say that we should not care about parisc for > >>> persistent memory. We'll just have to find a way to exclude > >>> parisc without making life too ugly. > >> > >> I don't think creapling mmap() interface for one arch is the right way to > >> go. I think the interface should be universal. > >> > >> I may imagine MAP_DIRECT can be useful not only for persistent memory. > >> For tmpfs instead of mlock()? > > > > On parisc we have > > #define MAP_SHARED 0x01 /* Share changes */ > > #define MAP_PRIVATE 0x02 /* Changes are private */ > > #define MAP_TYPE 0x03 /* Mask for type of mapping */ > > #define MAP_FIXED 0x04 /* Interpret addr exactly */ > > #define MAP_ANONYMOUS 0x10 /* don't use a file */ > > > > So, if you need a MAP_DIRECT, wouldn't e.g. > > #define MAP_DIRECT 0x08 > > be possible (for parisc, and others 0x04). > > And if MAP_TYPE needs to include this flag on parisc: > > #define MAP_TYPE (0x03 | 0x08) /* Mask for type of mapping */ > > The problem here is that to support new the mmap flags the arch needs > to find a flag that is guaranteed to fail on older kernels. Defining > MAP_DIRECT to 0x8 on parisc doesn't work because it will simply be > ignored on older parisc kernels. > > However, it's already the case that several archs have their own > sys_mmap entry points. Those archs that can't follow the common scheme > (only parsic it seems) will need to add a new mmap syscall. I think > that's a reasonable tradeoff to allow every other architecture to add > this support with their existing mmap syscall paths. I don't want other architectures to suffer just because of parisc. But adding a new syscall just for usage on parisc won't work either, because nobody will add code to call it then. > That means MAP_DIRECT should be defined to MAP_TYPE on parisc until it > later defines an opt-in mechanism to a new syscall that honors > MAP_DIRECT as a valid flag. I'd instead propose to to introduce an ABI breakage for parisc users (which aren't many). Most parisc users update their kernel regularily anyway, because we fixed so many bugs in the latest kernel. With the following patch pushed down to the stable kernel series, MAP_DIRECT will fail as expected on those kernels, while we can keep parisc up with current developments regarding MAP_DIRECT. Helge --- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h index 9a9c2fe..43b9a1e 100644 --- a/arch/parisc/include/uapi/asm/mman.h +++ b/arch/parisc/include/uapi/asm/mman.h @@ -13,6 +13,7 @@ #define MAP_PRIVATE 0x02 /* Changes are private */ #define MAP_TYPE 0x03 /* Mask for type of mapping */ #define MAP_FIXED 0x04 /* Interpret addr exactly */ +#define MAP_DIRECT 0x08 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x10 /* don't use a file */ #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 378a754..0499f87 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c @@ -270,6 +270,10 @@ asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, { /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE we have. */ +#if !defined(CONFIG_HAVE_MAP_DIRECT_SUPPORT) + if (flags & MAP_DIRECT) + return -EINVAL; +#endif return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12)); } @@ -278,6 +282,10 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset) { +#if !defined(CONFIG_HAVE_MAP_DIRECT_SUPPORT) + if (flags & MAP_DIRECT) + return -EINVAL; +#endif if (!(offset & ~PAGE_MASK)) { return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);