From patchwork Mon Oct 16 15:37:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10009005 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 D6252601E7 for ; Mon, 16 Oct 2017 15:38:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C541328614 for ; Mon, 16 Oct 2017 15:38:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9A3528619; Mon, 16 Oct 2017 15:38:06 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 EEBEA28614 for ; Mon, 16 Oct 2017 15:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754489AbdJPPiB (ORCPT ); Mon, 16 Oct 2017 11:38:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:53396 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754107AbdJPPiA (ORCPT ); Mon, 16 Oct 2017 11:38:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E3BDBACF0; Mon, 16 Oct 2017 15:37:57 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 3754E1E35A5; Mon, 16 Oct 2017 17:37:56 +0200 (CEST) Date: Mon, 16 Oct 2017 17:37:56 +0200 From: Jan Kara To: Ross Zwisler Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, Christoph Hellwig , Dan Williams , Ted Tso , "Darrick J. Wong" Subject: Re: [PATCH 12/19] mm: Define MAP_SYNC and VM_SYNC flags Message-ID: <20171016153756.GJ9762@quack2.suse.cz> References: <20171011200603.27442-1-jack@suse.cz> <20171011200603.27442-13-jack@suse.cz> <20171013194444.GB29081@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171013194444.GB29081@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri 13-10-17 13:44:44, Ross Zwisler wrote: > On Wed, Oct 11, 2017 at 10:05:56PM +0200, Jan Kara wrote: > > Define new MAP_SYNC flag and corresponding VMA VM_SYNC flag. As the > > MAP_SYNC flag is not part of LEGACY_MAP_MASK, currently it will be > > refused by all MAP_SHARED_VALIDATE map attempts and silently ignored for > > everything else. > > > > Signed-off-by: Jan Kara > > --- > > arch/xtensa/include/uapi/asm/mman.h | 1 + > > fs/proc/task_mmu.c | 1 + > > include/linux/mm.h | 1 + > > include/linux/mman.h | 3 ++- > > include/uapi/asm-generic/mman.h | 1 + > > 5 files changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h > > index ec597900eec7..b62a7ce166fb 100644 > > --- a/arch/xtensa/include/uapi/asm/mman.h > > +++ b/arch/xtensa/include/uapi/asm/mman.h > > @@ -56,6 +56,7 @@ > > #define MAP_NONBLOCK 0x20000 /* do not block on IO */ > > #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ > > #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ > > +#define MAP_SYNC 0x100000 /* perform synchronous page faults for the mapping */ > > Why define MAP_SYNC for this one architecture, but not for the rest that have > their own arch/*/include/uapi/asm/mman.h? AFAIK xtensa doesn't support DAX, > so has no need for MAP_SYNC? Yeah, good point. I guess I'll just define it in asm-generic (which covers x86 as well) and just define MAP_SYNC to 0 if not defined in linux/mman.h. That should make the code compile and make sure userspace gets error if he tries to use MAP_SYNC somehow on arch without its definition. Attached is a new version of the patch. > Other than this one question, this patch looks fine: > > Reviewed-by: Ross Zwisler Thanks. Honza From e15030463a8be760e10843fc9cf08c082a783c22 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 17 Aug 2017 11:55:26 +0200 Subject: [PATCH] mm: Define MAP_SYNC and VM_SYNC flags Define new MAP_SYNC flag and corresponding VMA VM_SYNC flag. As the MAP_SYNC flag is not part of LEGACY_MAP_MASK, currently it will be refused by all MAP_SHARED_VALIDATE map attempts and silently ignored for everything else. Reviewed-by: Ross Zwisler Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/proc/task_mmu.c | 1 + include/linux/mm.h | 1 + include/linux/mman.h | 8 ++++++-- include/uapi/asm-generic/mman.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5589b4bd4b85..ea78b37deeaa 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -664,6 +664,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_ACCOUNT)] = "ac", [ilog2(VM_NORESERVE)] = "nr", [ilog2(VM_HUGETLB)] = "ht", + [ilog2(VM_SYNC)] = "sf", [ilog2(VM_ARCH_1)] = "ar", [ilog2(VM_WIPEONFORK)] = "wf", [ilog2(VM_DONTDUMP)] = "dd", diff --git a/include/linux/mm.h b/include/linux/mm.h index 55a9d2d109d9..cb62f2127314 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -189,6 +189,7 @@ extern unsigned int kobjsize(const void *objp); #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */ #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */ #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */ +#define VM_SYNC 0x00800000 /* Synchronous page faults */ #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */ #define VM_WIPEONFORK 0x02000000 /* Wipe VMA contents in child. */ #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */ diff --git a/include/linux/mman.h b/include/linux/mman.h index 94b63b4d71ff..8f7cc87828e6 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -9,7 +9,7 @@ /* * Arrange for legacy / undefined architecture specific flags to be - * ignored by default in LEGACY_MAP_MASK. + * ignored by mmap handling code. */ #ifndef MAP_32BIT #define MAP_32BIT 0 @@ -23,6 +23,9 @@ #ifndef MAP_UNINITIALIZED #define MAP_UNINITIALIZED 0 #endif +#ifndef MAP_SYNC +#define MAP_SYNC 0 +#endif /* * The historical set of flags that all mmap implementations implicitly @@ -125,7 +128,8 @@ calc_vm_flag_bits(unsigned long flags) { return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) | _calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) | - _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ); + _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) | + _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ); } unsigned long vm_commit_limit(void); diff --git a/include/uapi/asm-generic/mman.h b/include/uapi/asm-generic/mman.h index 7162cd4cca73..00e55627d2df 100644 --- a/include/uapi/asm-generic/mman.h +++ b/include/uapi/asm-generic/mman.h @@ -12,6 +12,7 @@ #define MAP_NONBLOCK 0x10000 /* do not block on IO */ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ +#define MAP_SYNC 0x80000 /* perform synchronous page faults for the mapping */ /* Bits [26:31] are reserved, see mman-common.h for MAP_HUGETLB usage */ -- 2.12.3