Skip to contentSkip to conversation

powerpc/hugetlb: Add ABI defines for MAP_HUGE_16MB and MAP_HUGE_16GB

PATCH In review Anshuman Khandual 7 participants 15 messages Apr 4, 2017 – Apr 10, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/hugetlb: Add ABI defines for MAP_HUGE_16MB and MAP_HUGE_16GB

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

---
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)

 arch/powerpc/include/uapi/asm/mman.h | 3 +++
 1 file changed, 3 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +3 -0
index 03c06ba..e78980b 100644
@@ -29,4 +29,7 @@
 #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_HUGE_16MB	(24 << MAP_HUGE_SHIFT)	/* 16MB HugeTLB Page */
+#define MAP_HUGE_16GB	(34 << MAP_HUGE_SHIFT)	/* 16GB HugeTLB Page */
+
 #endif /* _UAPI_ASM_POWERPC_MMAN_H */
Signature · 1 line
1.8.5.2
#1 lore raw
Quoted 21 lines · Anshuman Khandual

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

---
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)

 arch/powerpc/include/uapi/asm/mman.h | 3 +++
 1 file changed, 3 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..e78980b 100644

arch/powerpc/include/uapi/asm/mman.h line 35

Quoted 7 lines
arch/powerpc/include/uapi/asm/mman.h +3 -0
@@ -29,4 +29,7 @@
 #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_HUGE_16MB	(24 << MAP_HUGE_SHIFT)	/* 16MB HugeTLB Page */
+#define MAP_HUGE_16GB	(34 << MAP_HUGE_SHIFT)	/* 16GB HugeTLB Page */
+
 #endif /* _UAPI_ASM_POWERPC_MMAN_H */

I am doing a similar patch as part of 1G and hugetlb migration series. Can you add 2M and 1G #defines also so that i can drop the patch from my series and pick this ?

-aneesh

#2 lore raw
Quoted 30 lines · Aneesh Kumar K.V
Quoted 27 lines · Anshuman Khandual

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

---
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)

 arch/powerpc/include/uapi/asm/mman.h | 3 +++
 1 file changed, 3 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..e78980b 100644
@@ -29,4 +29,7 @@
 #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 */

Quoted 11 lines
Quoted 7 lines

+#define MAP_HUGE_16MB (24 << MAP_HUGE_SHIFT) /* 16MB HugeTLB
Page */
+#define MAP_HUGE_16GB (34 << MAP_HUGE_SHIFT) /* 16GB HugeTLB
Page */
+
#endif /* _UAPI_ASM_POWERPC_MMAN_H */

I am doing a similar patch as part of 1G and hugetlb migration series. Can you add 2M and 1G #defines also so that i can drop the patch from my series and pick this ?

Sure, will just have to add the two lines from x86 code :)

#3 lore raw

PATCH v2 1/1 powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

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.

---
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 V2:
- Added definitions for 2MB and 1GB HugeTLB pages per Aneesh

 arch/powerpc/include/uapi/asm/mman.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +5 -0
index 03c06ba..3eb788c 100644
@@ -29,4 +29,9 @@
 #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_HUGE_2MB	(21 << MAP_HUGE_SHIFT)	/* 2MB 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 */
Signature · 1 line
1.8.5.2
Reviewed-by on v2 1/1
#4 lore raw

Re: [PATCH V2] powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

Quoted 9 lines · Anshuman Khandual

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.

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

Quoted 5 lines

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 V2:
- Added definitions for 2MB and 1GB HugeTLB pages per Aneesh

I think it also helps if you mention these are used in bits 26:31 (6 bits) to encode the size.

Quoted 9 lines
 arch/powerpc/include/uapi/asm/mman.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..3eb788c 100644

arch/powerpc/include/uapi/asm/mman.h line 37

Quoted 9 lines
arch/powerpc/include/uapi/asm/mman.h +5 -0
@@ -29,4 +29,9 @@
 #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_HUGE_2MB	(21 << MAP_HUGE_SHIFT)	/* 2MB 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 */

We may want to call out what MMU supports what size, so that an error can be interpreted from the header file comments.

#5 lore raw

Re: [PATCH V2] powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

Quoted 9 lines · Balbir Singh
Quoted 8 lines · Anshuman Khandual
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..3eb788c 100644
@@ -29,4 +29,9 @@
 #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 */
 
Quoted 9 lines

arch/powerpc/include/uapi/asm/mman.h line 37

Quoted 6 lines
arch/powerpc/include/uapi/asm/mman.h +5 -0
+#define MAP_HUGE_2MB	(21 << MAP_HUGE_SHIFT)	/* 2MB 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 */

We may want to call out what MMU supports what size, so that an error can be interpreted from the header file comments.

No don't, it can depend on what's configured in Linux and/or hypervisor config and/or firmware and so on, so any header file comments are most likely just going to be misleading and/or out of date.

cheers

#6 lore raw

PATCH v3 1/1 powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

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.

---
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 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 | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/powerpc/include/uapi/asm/mman.h +10 -0
index 03c06ba..0c84e14 100644
@@ -29,4 +29,14 @@
 #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 defines should be used for creating 'flags' argument
+ * (26:31 bits) for the mmap() system call should the caller
+ * decide to use non default HugeTLB page size.
+ */
+#define MAP_HUGE_2MB	(21 << MAP_HUGE_SHIFT)	/* 2MB 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 */
Signature · 1 line
1.8.5.2
#7 lore raw

Re: [PATCH V3] powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

Hi

Anshuman Khandual <[email protected]> a =C3=A9crit=C2=A0:

Quoted 2 lines

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.

Why not add all possible huge page sizes ?
For instance the 8xx (only) supports 512k and 8M hugepages

Christophe

Quoted 45 lines

---
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 <<=20=20
=20MAP_HUGE_SHIFT)
arch/x86/include/uapi/asm/mman.h:#define MAP_HUGE_1GB (30 <<=20=20
=20MAP_HUGE_SHIFT)

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 | 10 ++++++++++
 1 file changed, 10 insertions(+)
(quoted diff) +0 -0

=20b/arch/powerpc/include/uapi/asm/mman.h
index 03c06ba..0c84e14 100644

arch/powerpc/include/uapi/asm/mman.h +0 -0
@@ -29,4 +29,14 @@
 #define MAP_STACK	0x20000		/* give out an address that is best=20=20

=20suited for process/thread stacks */
#define MAP_HUGETLB 0x40000 /* create a huge page mapping */

arch/powerpc/include/uapi/asm/mman.h +10 -1
+/*
+ * These defines should be used for creating 'flags' argument
+ * (26:31 bits) for the mmap() system call should the caller
+ * decide to use non default HugeTLB page size.
+ */
+#define MAP_HUGE_2MB	(21 << MAP_HUGE_SHIFT)	/* 2MB 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 */
--

1.8.5.2

#8 lore raw

Re: [PATCH V3] powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

Quoted 9 lines · LEROY Christophe

Hi

Quoted 2 lines · Anshuman Khandual

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.

Why not add all possible huge page sizes ?
For instance the 8xx (only) supports 512k and 8M hugepages

Sure, can do that.

#9 lore raw

PATCH v4 1/1 powerpc/hugetlb: Add ABI defines for supported HugeTLB page sizes

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.

---
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(+)
arch/powerpc/include/uapi/asm/mman.h +14 -0
index 03c06ba..ebe99c7 100644
@@ -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 */
Signature · 1 line
1.8.5.2
#10 lore raw

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

Quoted 2 lines · Anshuman Khandual

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.

Quoted 5 lines
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..ebe99c7 100644

arch/powerpc/include/uapi/asm/mman.h line 37

Quoted 9 lines
arch/powerpc/include/uapi/asm/mman.h +6 -0
@@ -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

#11 lore raw

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

Quoted 25 lines · Michael Ellerman
Quoted 2 lines · Anshuman Khandual

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.

Quoted 5 lines
arch/powerpc/include/uapi/asm/mman.h +0 -0
index 03c06ba..ebe99c7 100644

arch/powerpc/include/uapi/asm/mman.h line 37

Quoted 9 lines
arch/powerpc/include/uapi/asm/mman.h +6 -0
@@ -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:

Quoted 7 lines

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

Quoted 6 lines

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.

#12 lore raw

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

In reply to Michael Ellerman

nits... take 'em or leave 'em...

Quoted 6 lines · Michael Ellerman

Anshuman Khandual <[email protected]> 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?

Quoted 5 lines

* 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

#13 lore raw

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

Quoted 11 lines · Paul Clarke

nits... take 'em or leave 'em...

Quoted 6 lines · Michael Ellerman

Anshuman Khandual <[email protected]> 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.

Quoted 1 line

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