* [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
` (13 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
` (12 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
` (11 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (2 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
` (10 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (3 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
` (9 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (4 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
` (8 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (5 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
` (7 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (6 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
` (6 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (7 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
` (5 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (8 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
` (4 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
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] 23+ messages in thread* [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu)
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (9 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 10:16 ` David Howells
2007-04-04 4:02 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
` (3 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
fs/ramfs/file-nommu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux-cell/fs/ramfs/file-nommu.c
===================================================================
--- linux-cell.orig/fs/ramfs/file-nommu.c 2007-03-22 16:18:27.000000000 +1100
+++ linux-cell/fs/ramfs/file-nommu.c 2007-03-22 16:20:14.000000000 +1100
@@ -238,7 +238,10 @@ unsigned long ramfs_nommu_get_unmapped_a
struct page **pages = NULL, **ptr, *page;
loff_t isize;
- if (!(flags & MAP_SHARED))
+ /* Deal with MAP_FIXED differently ? Forbid it ? Need help from some nommu
+ * folks there... --BenH.
+ */
+ if ((flags & MAP_FIXED) || !(flags & MAP_SHARED))
return addr;
/* the mapping mustn't extend beyond the EOF */
--
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] 23+ messages in thread* Re: [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu)
2007-04-04 4:02 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
@ 2007-04-04 10:16 ` David Howells
2007-04-04 23:13 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 23+ messages in thread
From: David Howells @ 2007-04-04 10:16 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> - if (!(flags & MAP_SHARED))
> + /* Deal with MAP_FIXED differently ? Forbid it ? Need help from some nommu
> + * folks there... --BenH.
> + */
> + if ((flags & MAP_FIXED) || !(flags & MAP_SHARED))
MAP_FIXED on NOMMU? Surely you jest...
See the first if-statement in validate_mmap_request().
If anything, you should be adding BUG_ON(flags & MAP_FIXED).
David
--
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] 23+ messages in thread
* Re: [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu)
2007-04-04 10:16 ` David Howells
@ 2007-04-04 23:13 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 23:13 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
On Wed, 2007-04-04 at 11:16 +0100, David Howells wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
> > - if (!(flags & MAP_SHARED))
> > + /* Deal with MAP_FIXED differently ? Forbid it ? Need help from some nommu
> > + * folks there... --BenH.
> > + */
> > + if ((flags & MAP_FIXED) || !(flags & MAP_SHARED))
>
> MAP_FIXED on NOMMU? Surely you jest...
Heh, see the comment, I was actually wondering about it :-)
> See the first if-statement in validate_mmap_request().
>
> If anything, you should be adding BUG_ON(flags & MAP_FIXED).
Yeah, I missed that bit. That will simplify the problem.
Thanks,
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] 23+ messages in thread
* [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu)
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (10 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 10:31 ` David Howells
2007-04-04 4:02 ` [PATCH 13/14] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
` (2 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
This also fixes a bug, I think, it used to return a pgoff (pfn)
instead of an address. (To split ?)
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/char/mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux-cell/drivers/char/mem.c
===================================================================
--- linux-cell.orig/drivers/char/mem.c 2007-03-22 16:24:04.000000000 +1100
+++ linux-cell/drivers/char/mem.c 2007-03-22 16:26:30.000000000 +1100
@@ -246,9 +246,12 @@ static unsigned long get_unmapped_area_m
unsigned long pgoff,
unsigned long flags)
{
+ if (flags & MAP_FIXED)
+ if ((addr >> PAGE_SHIFT) != pgoff)
+ return (unsigned long) -EINVAL;
if (!valid_mmap_phys_addr_range(pgoff, len))
return (unsigned long) -EINVAL;
- return pgoff;
+ return pgoff << PAGE_SHIFT;
}
/* can't do an in-place private mapping if there's no MMU */
--
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] 23+ messages in thread* Re: [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu)
2007-04-04 4:02 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
@ 2007-04-04 10:31 ` David Howells
2007-04-04 23:14 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 23+ messages in thread
From: David Howells @ 2007-04-04 10:31 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> + if (flags & MAP_FIXED)
> + if ((addr >> PAGE_SHIFT) != pgoff)
> + return (unsigned long) -EINVAL;
Again... in NOMMU-mode there is no MAP_FIXED - it's rejected before we get
this far.
> - return pgoff;
> + return pgoff << PAGE_SHIFT;
That, however, does appear to be a genuine bugfix.
David
--
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] 23+ messages in thread
* Re: [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu)
2007-04-04 10:31 ` David Howells
@ 2007-04-04 23:14 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 23:14 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
On Wed, 2007-04-04 at 11:31 +0100, David Howells wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
> > + if (flags & MAP_FIXED)
> > + if ((addr >> PAGE_SHIFT) != pgoff)
> > + return (unsigned long) -EINVAL;
>
> Again... in NOMMU-mode there is no MAP_FIXED - it's rejected before we get
> this far.
>
> > - return pgoff;
> > + return pgoff << PAGE_SHIFT;
>
> That, however, does appear to be a genuine bugfix.
I'll separate it from the rest of the patches
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] 23+ messages in thread
* [PATCH 13/14] get_unmapped_area handles MAP_FIXED in generic code
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (11 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 4:02 ` [PATCH 14/14] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
2007-04-04 10:31 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area David Howells
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
and change the caller now that everybody can handle it.
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] 23+ messages in thread* [PATCH 14/14] get_unmapped_area doesn't need hugetlbfs hacks anymore
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (12 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 13/14] get_unmapped_area handles MAP_FIXED in generic code Benjamin Herrenschmidt
@ 2007-04-04 4:02 ` Benjamin Herrenschmidt
2007-04-04 10:31 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area David Howells
14 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 4:02 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel
---
mm/mmap.c | 16 ----------------
1 file changed, 16 deletions(-)
Index: linux-cell/mm/mmap.c
===================================================================
--- linux-cell.orig/mm/mmap.c 2007-03-22 16:30:24.000000000 +1100
+++ linux-cell/mm/mmap.c 2007-03-22 16:30:48.000000000 +1100
@@ -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] 23+ messages in thread* Re: [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area
2007-04-04 4:02 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
` (13 preceding siblings ...)
2007-04-04 4:02 ` [PATCH 14/14] get_unmapped_area doesn't need hugetlbfs hacks anymore Benjamin Herrenschmidt
@ 2007-04-04 10:31 ` David Howells
2007-04-04 23:20 ` Benjamin Herrenschmidt
14 siblings, 1 reply; 23+ messages in thread
From: David Howells @ 2007-04-04 10:31 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> This serie of patches moves the logic to handle MAP_FIXED down to the
> various arch/driver get_unmapped_area() implementations, and then changes
> the generic code to always call them. The hugetlbfs hacks then disappear
> from the generic code.
This sounds like get_unmapped_area() is now doing more than it says on the
tin. As I understand it, it's to be called to locate an unmapped area when
one wasn't specified by MAP_FIXED, and so shouldn't be called if MAP_FIXED is
set.
Admittedly, on NOMMU, it's also used to find the location of quasi-memory
devices such as framebuffers and ramfs files, but that's not a great deviation
from the original intent.
Perhaps a change of name is in order for the function?
> Since I need to do some special 64K pages mappings for SPEs on cell, I need
> to work around the first problem at least. I have further patches thus
> implementing a "slices" layer that handles multiple page sizes through
> slices of the address space for use by hugetlbfs, the SPE code, and possibly
> others, but it requires that serie of patches first/
That makes it sound like there should be an "unget" too for when an error
occurs between ->get_unmapped_area() being called and ->mmap() returning
successfully.
David
--
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] 23+ messages in thread* Re: [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area
2007-04-04 10:31 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area David Howells
@ 2007-04-04 23:20 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 23+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 23:20 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, linux-arch, Linux Memory Management, linux-kernel
On Wed, 2007-04-04 at 11:31 +0100, David Howells wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
>
> > This serie of patches moves the logic to handle MAP_FIXED down to the
> > various arch/driver get_unmapped_area() implementations, and then changes
> > the generic code to always call them. The hugetlbfs hacks then disappear
> > from the generic code.
>
> This sounds like get_unmapped_area() is now doing more than it says on the
> tin. As I understand it, it's to be called to locate an unmapped area when
> one wasn't specified by MAP_FIXED, and so shouldn't be called if MAP_FIXED is
> set.
Well... that was the initial implementation. But that doesn't quite deal
well with various issues like page size constraints like the segment
constraints on powerpc or other hugetlbfs realted issues, and the
aliasing problems on architectures with virtually caches...
Just look at how many architectures already have special case for
MAP_FIXED in their arch_get_unmapped_area ! It was never called so far
though, my patch makes it being called.
I agree it's probably not the best interface, but I'm still trying to
figure out something that would be nicer as a "second step", as I don't
want to do too much in one set of patches. This serie allows me to hook
in my SPE 64K page thingy, to cleanup & improve a bit my hugetlb
handling, and possibly fixes some of those aliasing issues on
architectures with virtual caches...
> Admittedly, on NOMMU, it's also used to find the location of quasi-memory
> devices such as framebuffers and ramfs files, but that's not a great deviation
> from the original intent.
>
> Perhaps a change of name is in order for the function?
I'm not sure. "get" can mean "obtain" :-) The way it's currently
implemented for me on powerpc works fine that way, I don't need an
"unget".
> > Since I need to do some special 64K pages mappings for SPEs on cell, I need
> > to work around the first problem at least. I have further patches thus
> > implementing a "slices" layer that handles multiple page sizes through
> > slices of the address space for use by hugetlbfs, the SPE code, and possibly
> > others, but it requires that serie of patches first/
>
> That makes it sound like there should be an "unget" too for when an error
> occurs between ->get_unmapped_area() being called and ->mmap() returning
> successfully.
I don't need it because I can flip the page size of the segment back if
it has no VMA in it on the next get_unmapped_area(). Again, I'd like to
come up with a better interface, and I might post something in that
direction next week, but I beleive those patches (+/- bug fixes) are a
good first step in the right direction. I also need to find a proper way
to solve the mremap problem as it's bogus as it is already with things
like hugetlbfs on powerpc at least.
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] 23+ messages in thread