* [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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>
Acked-by: William Irwin <bill.irwin@oracle.com>
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-04-24 15:10:17.000000000 +1000
+++ linux-cell/arch/powerpc/mm/hugetlbpage.c 2007-04-24 15:28:11.000000000 +1000
@@ -566,6 +566,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);
@@ -641,6 +648,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;
@@ -823,6 +837,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] 15+ messages in thread* [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 1/12] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 2/12] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (2 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 4/12] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-25 8:27 ` Russell King
2007-04-24 5:33 ` [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
` (7 subsequent siblings)
11 siblings, 1 reply; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* Re: [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm
2007-04-24 5:33 ` [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
@ 2007-04-25 8:27 ` Russell King
0 siblings, 0 replies; 15+ messages in thread
From: Russell King @ 2007-04-25 8:27 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, linux-kernel, Linux Memory Management
On Tue, Apr 24, 2007 at 03:33:35PM +1000, Benjamin Herrenschmidt wrote:
> 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>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
>
> 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 from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
--
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] 15+ messages in thread
* [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (3 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 3/12] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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>
Acked-by: William Irwin <bill.irwin@oracle.com>
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] 15+ messages in thread* [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (4 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 6/12] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
Handle MAP_FIXED in i386 hugetlb_get_unmapped_area(), just call
prepare_hugepage_range.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: William Irwin <bill.irwin@oracle.com>
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] 15+ messages in thread* [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (5 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 5/12] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (6 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 7/12] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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>
Acked-by: William Irwin <bill.irwin@oracle.com>
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] 15+ messages in thread* [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (7 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 8/12] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (8 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 9/12] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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] 15+ messages in thread* [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (9 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 11/12] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
2007-04-24 5:33 ` [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
Generic hugetlb_get_unmapped_area() now handles MAP_FIXED by just
calling prepare_hugepage_range()
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: William Irwin <bill.irwin@oracle.com>
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] 15+ messages in thread* [PATCH 12/12] get_unmapped_area doesn't need hugetlbfs hacks anymore
2007-04-24 5:33 [PATCH 0/12] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (10 preceding siblings ...)
2007-04-24 5:33 ` [PATCH 10/12] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
@ 2007-04-24 5:33 ` Benjamin Herrenschmidt
11 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-24 5:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Linux Memory Management
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>
Acked-by: William Irwin <bill.irwin@oracle.com>
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] 15+ messages in thread