diff options
author | Michel Lespinasse <walken@google.com> | 2012-12-11 19:01:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-11 20:22:25 -0500 |
commit | db4fbfb9523c93583c339e66023506f651c1d54b (patch) | |
tree | 8dfc250bb2249feaafe27c11cc4de5a654815833 /include/linux/mm.h | |
parent | e4c6bfd2d79d063017ab19a18915f0bc759f32d9 (diff) |
mm: vm_unmapped_area() lookup function
Implement vm_unmapped_area() using the rb_subtree_gap and highest_vm_end
information to look up for suitable virtual address space gaps.
struct vm_unmapped_area_info is used to define the desired allocation
request:
- lowest or highest possible address matching the remaining constraints
- desired gap length
- low/high address limits that the gap must fit into
- alignment mask and offset
Also update the generic arch_get_unmapped_area[_topdown] functions to make
use of vm_unmapped_area() instead of implementing a brute force search.
[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: Michel Lespinasse <walken@google.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index bcaab4e6fe91..4af4f0b1be4c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1456,6 +1456,37 @@ extern unsigned long vm_mmap(struct file *, unsigned long, | |||
1456 | unsigned long, unsigned long, | 1456 | unsigned long, unsigned long, |
1457 | unsigned long, unsigned long); | 1457 | unsigned long, unsigned long); |
1458 | 1458 | ||
1459 | struct vm_unmapped_area_info { | ||
1460 | #define VM_UNMAPPED_AREA_TOPDOWN 1 | ||
1461 | unsigned long flags; | ||
1462 | unsigned long length; | ||
1463 | unsigned long low_limit; | ||
1464 | unsigned long high_limit; | ||
1465 | unsigned long align_mask; | ||
1466 | unsigned long align_offset; | ||
1467 | }; | ||
1468 | |||
1469 | extern unsigned long unmapped_area(struct vm_unmapped_area_info *info); | ||
1470 | extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info); | ||
1471 | |||
1472 | /* | ||
1473 | * Search for an unmapped address range. | ||
1474 | * | ||
1475 | * We are looking for a range that: | ||
1476 | * - does not intersect with any VMA; | ||
1477 | * - is contained within the [low_limit, high_limit) interval; | ||
1478 | * - is at least the desired size. | ||
1479 | * - satisfies (begin_addr & align_mask) == (align_offset & align_mask) | ||
1480 | */ | ||
1481 | static inline unsigned long | ||
1482 | vm_unmapped_area(struct vm_unmapped_area_info *info) | ||
1483 | { | ||
1484 | if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN)) | ||
1485 | return unmapped_area(info); | ||
1486 | else | ||
1487 | return unmapped_area_topdown(info); | ||
1488 | } | ||
1489 | |||
1459 | /* truncate.c */ | 1490 | /* truncate.c */ |
1460 | extern void truncate_inode_pages(struct address_space *, loff_t); | 1491 | extern void truncate_inode_pages(struct address_space *, loff_t); |
1461 | extern void truncate_inode_pages_range(struct address_space *, | 1492 | extern void truncate_inode_pages_range(struct address_space *, |