* [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:27 ` William Lee Irwin III
2007-04-12 2:20 ` [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
` (11 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in powerpc's arch_get_unmapped_area() in all 3
implementations of it.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/mm/hugetlbpage.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
Index: linux-cell/arch/powerpc/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/powerpc/mm/hugetlbpage.c 2007-03-22 14:52:07.000000000 +1100
+++ linux-cell/arch/powerpc/mm/hugetlbpage.c 2007-03-22 14:57:40.000000000 +1100
@@ -572,6 +572,13 @@ unsigned long arch_get_unmapped_area(str
if (len > TASK_SIZE)
return -ENOMEM;
+ /* handle fixed mapping: prevent overlap with huge pages */
+ if (flags & MAP_FIXED) {
+ if (is_hugepage_only_range(mm, addr, len))
+ return -EINVAL;
+ return addr;
+ }
+
if (addr) {
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
@@ -647,6 +654,13 @@ arch_get_unmapped_area_topdown(struct fi
if (len > TASK_SIZE)
return -ENOMEM;
+ /* handle fixed mapping: prevent overlap with huge pages */
+ if (flags & MAP_FIXED) {
+ if (is_hugepage_only_range(mm, addr, len))
+ return -EINVAL;
+ return addr;
+ }
+
/* dont allow allocations above current base */
if (mm->free_area_cache > base)
mm->free_area_cache = base;
@@ -829,6 +843,13 @@ unsigned long hugetlb_get_unmapped_area(
/* Paranoia, caller should have dealt with this */
BUG_ON((addr + len) < addr);
+ /* Handle MAP_FIXED */
+ if (flags & MAP_FIXED) {
+ if (prepare_hugepage_range(addr, len, pgoff))
+ return -EINVAL;
+ return addr;
+ }
+
if (test_thread_flag(TIF_32BIT)) {
curareas = current->mm->context.low_htlb_areas;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc
2007-04-12 2:20 ` [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
@ 2007-04-12 22:27 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:27 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:27PM +1000, Benjamin Herrenschmidt wrote:
> Handle MAP_FIXED in powerpc's arch_get_unmapped_area() in all 3
> implementations of it.
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> arch/powerpc/mm/hugetlbpage.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
` (10 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in alpha's arch_get_unmapped_area(), simple case, just
return the address as passed in
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/alpha/kernel/osf_sys.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-cell/arch/alpha/kernel/osf_sys.c
===================================================================
--- linux-cell.orig/arch/alpha/kernel/osf_sys.c 2007-03-22 14:58:33.000000000 +1100
+++ linux-cell/arch/alpha/kernel/osf_sys.c 2007-03-22 14:58:44.000000000 +1100
@@ -1267,6 +1267,9 @@ arch_get_unmapped_area(struct file *filp
if (len > limit)
return -ENOMEM;
+ if (flags & MAP_FIXED)
+ return addr;
+
/* First, see if the given suggestion fits.
The OSF/1 loader (/sbin/loader) relies on us returning an
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
` (9 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
ARM already had a case for MAP_FIXED in arch_get_unmapped_area() though
it was not called before. Fix the comment to reflect that it will now
be called.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/arm/mm/mmap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Index: linux-cell/arch/arm/mm/mmap.c
===================================================================
--- linux-cell.orig/arch/arm/mm/mmap.c 2007-03-22 14:59:51.000000000 +1100
+++ linux-cell/arch/arm/mm/mmap.c 2007-03-22 15:00:01.000000000 +1100
@@ -49,8 +49,7 @@ arch_get_unmapped_area(struct file *filp
#endif
/*
- * We should enforce the MAP_FIXED case. However, currently
- * the generic kernel code doesn't allow us to handle this.
+ * We enforce the MAP_FIXED case.
*/
if (flags & MAP_FIXED) {
if (aliasing && flags & MAP_SHARED && addr & (SHMLBA - 1))
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (2 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
` (8 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in arch_get_unmapped_area on frv. Trivial case, just
return the address.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/frv/mm/elf-fdpic.c | 4 ++++
1 file changed, 4 insertions(+)
Index: linux-cell/arch/frv/mm/elf-fdpic.c
===================================================================
--- linux-cell.orig/arch/frv/mm/elf-fdpic.c 2007-03-22 15:00:50.000000000 +1100
+++ linux-cell/arch/frv/mm/elf-fdpic.c 2007-03-22 15:01:06.000000000 +1100
@@ -64,6 +64,10 @@ unsigned long arch_get_unmapped_area(str
if (len > TASK_SIZE)
return -ENOMEM;
+ /* handle MAP_FIXED */
+ if (flags & MAP_FIXED)
+ return addr;
+
/* only honour a hint if we're not going to clobber something doing so */
if (addr) {
addr = PAGE_ALIGN(addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (3 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:28 ` William Lee Irwin III
2007-04-12 2:20 ` [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
` (7 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in i386 hugetlb_get_unmapped_area(), just call
prepare_hugepage_range.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/i386/mm/hugetlbpage.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-cell/arch/i386/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/i386/mm/hugetlbpage.c 2007-03-22 16:08:12.000000000 +1100
+++ linux-cell/arch/i386/mm/hugetlbpage.c 2007-03-22 16:14:19.000000000 +1100
@@ -367,6 +367,12 @@ hugetlb_get_unmapped_area(struct file *f
if (len > TASK_SIZE)
return -ENOMEM;
+ if (flags & MAP_FIXED) {
+ if (prepare_hugepage_range(addr, len, pgoff))
+ return -EINVAL;
+ return addr;
+ }
+
if (addr) {
addr = ALIGN(addr, HPAGE_SIZE);
vma = find_vma(mm, addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386
2007-04-12 2:20 ` [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
@ 2007-04-12 22:28 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:28 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:29PM +1000, Benjamin Herrenschmidt wrote:
> Handle MAP_FIXED in i386 hugetlb_get_unmapped_area(), just call
> prepare_hugepage_range.
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> arch/i386/mm/hugetlbpage.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (4 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:29 ` William Lee Irwin III
2007-04-12 2:20 ` [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
` (6 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in ia64 arch_get_unmapped_area and
hugetlb_get_unmapped_area(), just call prepare_hugepage_range
in the later and is_hugepage_only_range() in the former.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/ia64/kernel/sys_ia64.c | 7 +++++++
arch/ia64/mm/hugetlbpage.c | 8 ++++++++
2 files changed, 15 insertions(+)
Index: linux-cell/arch/ia64/kernel/sys_ia64.c
===================================================================
--- linux-cell.orig/arch/ia64/kernel/sys_ia64.c 2007-03-22 15:10:45.000000000 +1100
+++ linux-cell/arch/ia64/kernel/sys_ia64.c 2007-03-22 15:10:47.000000000 +1100
@@ -33,6 +33,13 @@ arch_get_unmapped_area (struct file *fil
if (len > RGN_MAP_LIMIT)
return -ENOMEM;
+ /* handle fixed mapping: prevent overlap with huge pages */
+ if (flags & MAP_FIXED) {
+ if (is_hugepage_only_range(mm, addr, len))
+ return -EINVAL;
+ return addr;
+ }
+
#ifdef CONFIG_HUGETLB_PAGE
if (REGION_NUMBER(addr) == RGN_HPAGE)
addr = 0;
Index: linux-cell/arch/ia64/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/ia64/mm/hugetlbpage.c 2007-03-22 15:12:32.000000000 +1100
+++ linux-cell/arch/ia64/mm/hugetlbpage.c 2007-03-22 15:12:39.000000000 +1100
@@ -148,6 +148,14 @@ unsigned long hugetlb_get_unmapped_area(
return -ENOMEM;
if (len & ~HPAGE_MASK)
return -EINVAL;
+
+ /* Handle MAP_FIXED */
+ if (flags & MAP_FIXED) {
+ if (prepare_hugepage_range(addr, len, pgoff))
+ return -EINVAL;
+ return addr;
+ }
+
/* This code assumes that RGN_HPAGE != 0. */
if ((REGION_NUMBER(addr) != RGN_HPAGE) || (addr & (HPAGE_SIZE - 1)))
addr = HPAGE_REGION_BASE;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64
2007-04-12 2:20 ` [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
@ 2007-04-12 22:29 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:29 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:30PM +1000, Benjamin Herrenschmidt wrote:
> Handle MAP_FIXED in ia64 arch_get_unmapped_area and
> hugetlb_get_unmapped_area(), just call prepare_hugepage_range
> in the later and is_hugepage_only_range() in the former.
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> arch/ia64/kernel/sys_ia64.c | 7 +++++++
> arch/ia64/mm/hugetlbpage.c | 8 ++++++++
> 2 files changed, 15 insertions(+)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (5 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
` (5 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in parisc arch_get_unmapped_area(), just return the
address. We might want to also check for possible cache aliasing
issues now that we get called in that case (like ARM or MIPS),
leave a comment for the maintainers to pick up.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/parisc/kernel/sys_parisc.c | 5 +++++
1 file changed, 5 insertions(+)
Index: linux-cell/arch/parisc/kernel/sys_parisc.c
===================================================================
--- linux-cell.orig/arch/parisc/kernel/sys_parisc.c 2007-03-22 15:28:05.000000000 +1100
+++ linux-cell/arch/parisc/kernel/sys_parisc.c 2007-03-22 15:29:08.000000000 +1100
@@ -106,6 +106,11 @@ unsigned long arch_get_unmapped_area(str
{
if (len > TASK_SIZE)
return -ENOMEM;
+ /* Might want to check for cache aliasing issues for MAP_FIXED case
+ * like ARM or MIPS ??? --BenH.
+ */
+ if (flags & MAP_FIXED)
+ return addr;
if (!addr)
addr = TASK_UNMAPPED_BASE;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (6 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:30 ` William Lee Irwin III
2007-04-12 2:20 ` [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
` (4 subsequent siblings)
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in hugetlb_get_unmapped_area on sparc64
by just using prepare_hugepage_range()
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/sparc64/mm/hugetlbpage.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-cell/arch/sparc64/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/sparc64/mm/hugetlbpage.c 2007-03-22 16:12:57.000000000 +1100
+++ linux-cell/arch/sparc64/mm/hugetlbpage.c 2007-03-22 16:15:33.000000000 +1100
@@ -175,6 +175,12 @@ hugetlb_get_unmapped_area(struct file *f
if (len > task_size)
return -ENOMEM;
+ if (flags & MAP_FIXED) {
+ if (prepare_hugepage_range(addr, len, pgoff))
+ return -EINVAL;
+ return addr;
+ }
+
if (addr) {
addr = ALIGN(addr, HPAGE_SIZE);
vma = find_vma(mm, addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64
2007-04-12 2:20 ` [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
@ 2007-04-12 22:30 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:30 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:31PM +1000, Benjamin Herrenschmidt wrote:
> Handle MAP_FIXED in hugetlb_get_unmapped_area on sparc64
> by just using prepare_hugepage_range()
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> arch/sparc64/mm/hugetlbpage.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (7 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
` (3 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Handle MAP_FIXED in x86_64 arch_get_unmapped_area(), simple case, just
return the address as passed in
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/x86_64/kernel/sys_x86_64.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-cell/arch/x86_64/kernel/sys_x86_64.c
===================================================================
--- linux-cell.orig/arch/x86_64/kernel/sys_x86_64.c 2007-03-22 16:10:10.000000000 +1100
+++ linux-cell/arch/x86_64/kernel/sys_x86_64.c 2007-03-22 16:11:06.000000000 +1100
@@ -93,6 +93,9 @@ arch_get_unmapped_area(struct file *filp
unsigned long start_addr;
unsigned long begin, end;
+ if (flags & MAP_FIXED)
+ return addr;
+
find_start_end(flags, &begin, &end);
if (len > end)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (8 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 2:20 ` [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
` (2 subsequent siblings)
12 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
generic arch_get_unmapped_area() now handles MAP_FIXED. Now that
all implementations have been fixed, change the toplevel
get_unmapped_area() to call into arch or drivers for the MAP_FIXED
case.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
mm/mmap.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
Index: linux-cell/mm/mmap.c
===================================================================
--- linux-cell.orig/mm/mmap.c 2007-03-22 16:29:22.000000000 +1100
+++ linux-cell/mm/mmap.c 2007-03-22 16:30:06.000000000 +1100
@@ -1199,6 +1199,9 @@ arch_get_unmapped_area(struct file *filp
if (len > TASK_SIZE)
return -ENOMEM;
+ if (flags & MAP_FIXED)
+ return addr;
+
if (addr) {
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
@@ -1272,6 +1275,9 @@ arch_get_unmapped_area_topdown(struct fi
if (len > TASK_SIZE)
return -ENOMEM;
+ if (flags & MAP_FIXED)
+ return addr;
+
/* requesting a specific address */
if (addr) {
addr = PAGE_ALIGN(addr);
@@ -1360,22 +1366,21 @@ get_unmapped_area(struct file *file, uns
unsigned long pgoff, unsigned long flags)
{
unsigned long ret;
+ unsigned long (*get_area)(struct file *, unsigned long,
+ unsigned long, unsigned long, unsigned long);
- if (!(flags & MAP_FIXED)) {
- unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
-
- get_area = current->mm->get_unmapped_area;
- if (file && file->f_op && file->f_op->get_unmapped_area)
- get_area = file->f_op->get_unmapped_area;
- addr = get_area(file, addr, len, pgoff, flags);
- if (IS_ERR_VALUE(addr))
- return addr;
- }
+ get_area = current->mm->get_unmapped_area;
+ if (file && file->f_op && file->f_op->get_unmapped_area)
+ get_area = file->f_op->get_unmapped_area;
+ addr = get_area(file, addr, len, pgoff, flags);
+ if (IS_ERR_VALUE(addr))
+ return addr;
if (addr > TASK_SIZE - len)
return -ENOMEM;
if (addr & ~PAGE_MASK)
return -EINVAL;
+
if (file && is_file_hugepages(file)) {
/*
* Check if the given range is hugepage aligned, and
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (9 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:31 ` William Lee Irwin III
2007-04-12 2:20 ` [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
2007-04-12 2:56 ` [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Wu, Bryan
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Generic hugetlb_get_unmapped_area() now handles MAP_FIXED by just
calling prepare_hugepage_range()
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fs/hugetlbfs/inode.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-cell/fs/hugetlbfs/inode.c
===================================================================
--- linux-cell.orig/fs/hugetlbfs/inode.c 2007-03-22 16:12:56.000000000 +1100
+++ linux-cell/fs/hugetlbfs/inode.c 2007-03-22 16:16:02.000000000 +1100
@@ -115,6 +115,12 @@ hugetlb_get_unmapped_area(struct file *f
if (len > TASK_SIZE)
return -ENOMEM;
+ if (flags & MAP_FIXED) {
+ if (prepare_hugepage_range(addr, len, pgoff))
+ return -EINVAL;
+ return addr;
+ }
+
if (addr) {
addr = ALIGN(addr, HPAGE_SIZE);
vma = find_vma(mm, addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs
2007-04-12 2:20 ` [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
@ 2007-04-12 22:31 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:31 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:32PM +1000, Benjamin Herrenschmidt wrote:
> Generic hugetlb_get_unmapped_area() now handles MAP_FIXED by just
> calling prepare_hugepage_range()
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> fs/hugetlbfs/inode.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (10 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
@ 2007-04-12 2:20 ` Benjamin Herrenschmidt
2007-04-12 22:32 ` William Lee Irwin III
2007-04-12 2:56 ` [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Wu, Bryan
12 siblings, 1 reply; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Memory Management, linux-kernel
Remove the hugetlbfs specific hacks in toplevel get_unmapped_area() now
that all archs and hugetlbfs itself do the right thing for both cases.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
mm/mmap.c | 16 ----------------
1 file changed, 16 deletions(-)
Index: linux-cell/mm/mmap.c
===================================================================
--- linux-cell.orig/mm/mmap.c 2007-04-12 12:14:46.000000000 +1000
+++ linux-cell/mm/mmap.c 2007-04-12 12:14:47.000000000 +1000
@@ -1381,22 +1381,6 @@ get_unmapped_area(struct file *file, uns
if (addr & ~PAGE_MASK)
return -EINVAL;
- if (file && is_file_hugepages(file)) {
- /*
- * Check if the given range is hugepage aligned, and
- * can be made suitable for hugepages.
- */
- ret = prepare_hugepage_range(addr, len, pgoff);
- } else {
- /*
- * Ensure that a normal request is not falling in a
- * reserved hugepage range. For some archs like IA-64,
- * there is a separate region for hugepages.
- */
- ret = is_hugepage_only_range(current->mm, addr, len);
- }
- if (ret)
- return -EINVAL;
return addr;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore
2007-04-12 2:20 ` [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
@ 2007-04-12 22:32 ` William Lee Irwin III
0 siblings, 0 replies; 22+ messages in thread
From: William Lee Irwin III @ 2007-04-12 22:32 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, Apr 12, 2007 at 12:20:33PM +1000, Benjamin Herrenschmidt wrote:
> Remove the hugetlbfs specific hacks in toplevel get_unmapped_area() now
> that all archs and hugetlbfs itself do the right thing for both cases.
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> mm/mmap.c | 16 ----------------
> 1 file changed, 16 deletions(-)
Acked-by: William Irwin <bill.irwin@oracle.com>
-- wli
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area
2007-04-12 2:20 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (11 preceding siblings ...)
2007-04-12 2:20 ` [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
@ 2007-04-12 2:56 ` Wu, Bryan
2007-04-12 2:56 ` Benjamin Herrenschmidt
12 siblings, 1 reply; 22+ messages in thread
From: Wu, Bryan @ 2007-04-12 2:56 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linux Memory Management, linux-kernel
On Thu, 2007-04-12 at 12:20 +1000, Benjamin Herrenschmidt wrote:
> This is a "first step" as there are still cleanups to be done in various
> areas touched by that code but I think it's probably good to go as is and
> at least enables me to implement what I need for PowerPC.
>
> (Andrew, this is also candidate for 2.6.22 since I haven't had any real
> objection, mostly suggestion for improving further, which I'll try to
> do later, and I have further powerpc patches that rely on this).
>
> The current get_unmapped_area code calls the f_ops->get_unmapped_area or
> the arch one (via the mm) only when MAP_FIXED is not passed. That makes
> it impossible for archs to impose proper constraints on regions of the
> virtual address space. To work around that, get_unmapped_area() then
> calls some hugetlbfs specific hacks.
>
> This cause several problems, among others:
>
> - It makes it impossible for a driver or filesystem to do the same thing
> that hugetlbfs does (for example, to allow a driver to use larger page
> sizes to map external hardware) if that requires applying a constraint
> on the addresses (constraining that mapping in certain regions and other
> mappings out of those regions).
>
> - Some archs like arm, mips, sparc, sparc64, sh and sh64 already want
> MAP_FIXED to be passed down in order to deal with aliasing issues.
> The code is there to handle it... but is never called.
>
Is there any support consideration for nommu arch such as blackfin which
is in the -mm tree now?
It is very kind of you to point out some idea about MAP_FIXED for
Blackfin arch, I will do some help for this.
Thanks
-Bryan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area
2007-04-12 2:56 ` [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Wu, Bryan
@ 2007-04-12 2:56 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 22+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-12 2:56 UTC (permalink / raw)
To: bryan.wu; +Cc: Andrew Morton, Linux Memory Management, linux-kernel
> Is there any support consideration for nommu arch such as blackfin which
> is in the -mm tree now?
>
> It is very kind of you to point out some idea about MAP_FIXED for
> Blackfin arch, I will do some help for this.
Right now, my understanding is that nommu archs just reject MAP_FIXED
outright... we might be able to be smarter, especially if we bring a
better infrastructure which I'm still thinking about.
Ben.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 22+ messages in thread