diff mbox

[V4] powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

Message ID 20170407035539.21688-1-khandual@linux.vnet.ibm.com (mailing list archive)
State Accepted
Commit 2c9faa7675fec57f6ac0372688fae2e10fc4c272
Headers show

Commit Message

Anshuman Khandual April 7, 2017, 3:55 a.m. UTC
This just adds user space exported ABI definitions for 2MB, 16MB, 1GB,
16GB non default huge page sizes to be used with mmap() system call.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
These defined values will be used along with MAP_HUGETLB while calling
mmap() system call if the desired HugeTLB page size is not the default
one. Follows similar definitions present in x86.

arch/x86/include/uapi/asm/mman.h:#define MAP_HUGE_2MB    (21 << MAP_HUGE_SHIFT)
arch/x86/include/uapi/asm/mman.h:#define MAP_HUGE_1GB    (30 << MAP_HUGE_SHIFT)

Changes in V4:
- Added defines for 512KB and 8MB HugeTLB page sizes per Christophe

Changes in V3:
- Added comment about how these defines will help create 'flags'
  argument for mmap() system call per Balbir

Changes in V2:
- Added definitions for 2MB and 1GB HugeTLB pages per Aneesh

 arch/powerpc/include/uapi/asm/mman.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Michael Ellerman April 7, 2017, 1:01 p.m. UTC | #1
Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:

> This just adds user space exported ABI definitions for 2MB, 16MB, 1GB,
> 16GB non default huge page sizes to be used with mmap() system call.

I updated this for you to include all the sizes.

> diff --git a/arch/powerpc/include/uapi/asm/mman.h b/arch/powerpc/include/uapi/asm/mman.h
> index 03c06ba..ebe99c7 100644
> --- a/arch/powerpc/include/uapi/asm/mman.h
> +++ b/arch/powerpc/include/uapi/asm/mman.h
> @@ -29,4 +29,18 @@
>  #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 */
>  
> +/*
> + * These constant defines should be used for creating the
> + * 'flags' argument (26:31 bit positions) for mmap() system
> + * call should the caller decide to use non default HugeTLB
> + * page size.
> + */

And I reworded the comment the make it clearer (I think) that most users
shouldn't need to use these, and should just use the default size:

/*
 * When MAP_HUGETLB is set bits [26:31] 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.
 */


Also do you want to send a patch to the man page?

https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man2/mmap.2#n248

cheers
Anshuman Khandual April 7, 2017, 2:58 p.m. UTC | #2
On 04/07/2017 06:31 PM, Michael Ellerman wrote:
> Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:
> 
>> This just adds user space exported ABI definitions for 2MB, 16MB, 1GB,
>> 16GB non default huge page sizes to be used with mmap() system call.
> 
> I updated this for you to include all the sizes.
> 
>> diff --git a/arch/powerpc/include/uapi/asm/mman.h b/arch/powerpc/include/uapi/asm/mman.h
>> index 03c06ba..ebe99c7 100644
>> --- a/arch/powerpc/include/uapi/asm/mman.h
>> +++ b/arch/powerpc/include/uapi/asm/mman.h
>> @@ -29,4 +29,18 @@
>>  #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 */
>>  
>> +/*
>> + * These constant defines should be used for creating the
>> + * 'flags' argument (26:31 bit positions) for mmap() system
>> + * call should the caller decide to use non default HugeTLB
>> + * page size.
>> + */
> 
> And I reworded the comment the make it clearer (I think) that most users
> shouldn't need to use these, and should just use the default size:
> 
> /*
>  * When MAP_HUGETLB is set bits [26:31] 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.
>  */

Yeah its clearer, thanks.

> 
> 
> Also do you want to send a patch to the man page?
> 
> https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man2/mmap.2#n248
> 

Sure, will do it.
Paul A. Clarke April 7, 2017, 3:44 p.m. UTC | #3
nits... take 'em or leave 'em...

On 04/07/2017 08:01 AM, Michael Ellerman wrote:
> Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:
> And I reworded the comment the make it clearer (I think) that most users
> shouldn't need to use these, and should just use the default size:
>
> /*
>  * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.

need a comma after "set".

also, "bits [26:31]" of what?

>  * 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.
>  */

PC
Michael Ellerman April 8, 2017, 9:19 a.m. UTC | #4
Paul Clarke <pc@us.ibm.com> writes:

> nits... take 'em or leave 'em...
>
> On 04/07/2017 08:01 AM, Michael Ellerman wrote:
>> Anshuman Khandual <khandual@linux.vnet.ibm.com> writes:
>> And I reworded the comment the make it clearer (I think) that most users
>> shouldn't need to use these, and should just use the default size:
>>
>> /*
>>  * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
>
> need a comma after "set".

Hmm, 'spose.

> also, "bits [26:31]" of what?

Flags!

But yeah fair cop, as it happened I was rebasing it anyway, so:

/*
 * 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.
 */

Thanks for the review.

cheers
Michael Ellerman April 10, 2017, 10:49 p.m. UTC | #5
On Fri, 2017-04-07 at 03:55:39 UTC, Anshuman Khandual wrote:
> This just adds user space exported ABI definitions for 2MB, 16MB, 1GB,
> 16GB non default huge page sizes to be used with mmap() system call.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2c9faa7675fec57f6ac0372688fae2

cheers
diff mbox

Patch

diff --git a/arch/powerpc/include/uapi/asm/mman.h b/arch/powerpc/include/uapi/asm/mman.h
index 03c06ba..ebe99c7 100644
--- a/arch/powerpc/include/uapi/asm/mman.h
+++ b/arch/powerpc/include/uapi/asm/mman.h
@@ -29,4 +29,18 @@ 
 #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 */
 
+/*
+ * These constant defines should be used for creating the
+ * 'flags' argument (26:31 bit positions) for mmap() system
+ * call should the caller decide to use non default HugeTLB
+ * page size.
+ */
+#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 */
+
 #endif /* _UAPI_ASM_POWERPC_MMAN_H */