Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633AbdGQWaR (ORCPT ); Mon, 17 Jul 2017 18:30:17 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:25707 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbdGQWaC (ORCPT ); Mon, 17 Jul 2017 18:30:02 -0400 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , akpm@linux-foundation.org, mhocko@suse.com, ak@linux.intel.com, mtk.manpages@gmail.com, Davidlohr Bueso , khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, aarcange@redhat.com, Mike Kravetz Subject: [RFC PATCH 2/3] mm: arch: Use new hugetlb size encoding definitions Date: Mon, 17 Jul 2017 15:28:00 -0700 Message-Id: <1500330481-28476-3-git-send-email-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1500330481-28476-1-git-send-email-mike.kravetz@oracle.com> References: <20170328175408.GD7838@bombadil.infradead.org> <1500330481-28476-1-git-send-email-mike.kravetz@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8770 Lines: 236 Use the common definitions from hugetlb_encode.h header file for encoding hugetlb size definitions in mmap system call flags. Signed-off-by: Mike Kravetz --- arch/alpha/include/uapi/asm/mman.h | 14 ++++++-------- arch/mips/include/uapi/asm/mman.h | 14 ++++++-------- arch/parisc/include/uapi/asm/mman.h | 14 ++++++-------- arch/powerpc/include/uapi/asm/mman.h | 23 ++++++++++------------- arch/x86/include/uapi/asm/mman.h | 10 ++++++++-- arch/xtensa/include/uapi/asm/mman.h | 14 ++++++-------- include/uapi/asm-generic/mman-common.h | 6 ++++-- 7 files changed, 46 insertions(+), 49 deletions(-) diff --git a/arch/alpha/include/uapi/asm/mman.h b/arch/alpha/include/uapi/asm/mman.h index 02760f6..bfa5828 100644 --- a/arch/alpha/include/uapi/asm/mman.h +++ b/arch/alpha/include/uapi/asm/mman.h @@ -1,6 +1,8 @@ #ifndef __ALPHA_MMAN_H__ #define __ALPHA_MMAN_H__ +#include + #define PROT_READ 0x1 /* page can be read */ #define PROT_WRITE 0x2 /* page can be written */ #define PROT_EXEC 0x4 /* page can be executed */ @@ -68,15 +70,11 @@ #define MAP_FILE 0 /* - * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. - * This gives us 6 bits, which is enough until someone invents 128 bit address - * spaces. - * - * Assume these are all power of twos. - * When 0 use the default page size. + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h */ -#define MAP_HUGE_SHIFT 26 -#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 diff --git a/arch/mips/include/uapi/asm/mman.h b/arch/mips/include/uapi/asm/mman.h index 655e2fb..9e55284 100644 --- a/arch/mips/include/uapi/asm/mman.h +++ b/arch/mips/include/uapi/asm/mman.h @@ -8,6 +8,8 @@ #ifndef _ASM_MMAN_H #define _ASM_MMAN_H +#include + /* * Protections are chosen from these bits, OR'd together. The * implementation does not necessarily support PROT_EXEC or PROT_WRITE @@ -95,15 +97,11 @@ #define MAP_FILE 0 /* - * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. - * This gives us 6 bits, which is enough until someone invents 128 bit address - * spaces. - * - * Assume these are all power of twos. - * When 0 use the default page size. + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h */ -#define MAP_HUGE_SHIFT 26 -#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h index 5979745..11c6d86 100644 --- a/arch/parisc/include/uapi/asm/mman.h +++ b/arch/parisc/include/uapi/asm/mman.h @@ -1,6 +1,8 @@ #ifndef __PARISC_MMAN_H__ #define __PARISC_MMAN_H__ +#include + #define PROT_READ 0x1 /* page can be read */ #define PROT_WRITE 0x2 /* page can be written */ #define PROT_EXEC 0x4 /* page can be executed */ @@ -65,15 +67,11 @@ #define MAP_VARIABLE 0 /* - * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. - * This gives us 6 bits, which is enough until someone invents 128 bit address - * spaces. - * - * Assume these are all power of twos. - * When 0 use the default page size. + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h */ -#define MAP_HUGE_SHIFT 26 -#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 diff --git a/arch/powerpc/include/uapi/asm/mman.h b/arch/powerpc/include/uapi/asm/mman.h index ab45cc2..80fd56c 100644 --- a/arch/powerpc/include/uapi/asm/mman.h +++ b/arch/powerpc/include/uapi/asm/mman.h @@ -8,6 +8,7 @@ #define _UAPI_ASM_POWERPC_MMAN_H #include +#include #define PROT_SAO 0x10 /* Strong Access Ordering */ @@ -30,19 +31,15 @@ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ /* - * When MAP_HUGETLB is set, bits [26:31] of the flags argument to mmap(2), - * encode the log2 of the huge page size. A value of zero indicates that the - * default huge page size should be used. To use a non-default huge page size, - * one of these defines can be used, or the size can be encoded by hand. Note - * that on most systems only a subset, or possibly none, of these sizes will be - * available. + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h */ -#define MAP_HUGE_512KB (19 << MAP_HUGE_SHIFT) /* 512KB HugeTLB Page */ -#define MAP_HUGE_1MB (20 << MAP_HUGE_SHIFT) /* 1MB HugeTLB Page */ -#define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT) /* 2MB HugeTLB Page */ -#define MAP_HUGE_8MB (23 << MAP_HUGE_SHIFT) /* 8MB HugeTLB Page */ -#define MAP_HUGE_16MB (24 << MAP_HUGE_SHIFT) /* 16MB HugeTLB Page */ -#define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT) /* 1GB HugeTLB Page */ -#define MAP_HUGE_16GB (34 << MAP_HUGE_SHIFT) /* 16GB HugeTLB Page */ +#define MAP_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB /* 512KB HugeTLB Page */ +#define MAP_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB /* 1MB HugeTLB Page */ +#define MAP_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB /* 2MB HugeTLB Page */ +#define MAP_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB /* 8MB HugeTLB Page */ +#define MAP_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB /* 16MB HugeTLB Page */ +#define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB /* 1GB HugeTLB Page */ +#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE__16GB /* 16GB HugeTLB Page */ #endif /* _UAPI_ASM_POWERPC_MMAN_H */ diff --git a/arch/x86/include/uapi/asm/mman.h b/arch/x86/include/uapi/asm/mman.h index 39bca7f..5a67293 100644 --- a/arch/x86/include/uapi/asm/mman.h +++ b/arch/x86/include/uapi/asm/mman.h @@ -1,10 +1,16 @@ #ifndef _ASM_X86_MMAN_H #define _ASM_X86_MMAN_H +#include + #define MAP_32BIT 0x40 /* only give out 32bit addresses */ -#define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT) -#define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT) +/* + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h + */ +#define MAP_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB +#define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS /* diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h index 24365b3..5deb5e4 100644 --- a/arch/xtensa/include/uapi/asm/mman.h +++ b/arch/xtensa/include/uapi/asm/mman.h @@ -14,6 +14,8 @@ #ifndef _XTENSA_MMAN_H #define _XTENSA_MMAN_H +#include + /* * Protections are chosen from these bits, OR'd together. The * implementation does not necessarily support PROT_EXEC or PROT_WRITE @@ -107,15 +109,11 @@ #define MAP_FILE 0 /* - * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. - * This gives us 6 bits, which is enough until someone invents 128 bit address - * spaces. - * - * Assume these are all power of twos. - * When 0 use the default page size. + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h */ -#define MAP_HUGE_SHIFT 26 -#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 8c27db0..00d56b8 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -1,6 +1,8 @@ #ifndef __ASM_GENERIC_MMAN_COMMON_H #define __ASM_GENERIC_MMAN_COMMON_H +#include + /* Author: Michael S. Tsirkin , Mellanox Technologies Ltd. Based on: asm-xxx/mman.h @@ -69,8 +71,8 @@ * Assume these are all power of twos. * When 0 use the default page size. */ -#define MAP_HUGE_SHIFT 26 -#define MAP_HUGE_MASK 0x3f +#define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT +#define MAP_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 -- 2.7.5