xen-devel
[Xen-devel] [patch 14/44] Allocate and free vmalloc areas
To: |
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> |
Subject: |
[Xen-devel] [patch 14/44] Allocate and free vmalloc areas |
From: |
Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx> |
Date: |
Mon, 16 Jul 2007 16:15:50 -0700 |
Cc: |
Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Andi Kleen <ak@xxxxxx>, Andi Kleen <ak@xxxxxxx>, Jan Beulich <JBeulich@xxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>, Chris Wright <chrisw@xxxxxxxxxxxx>, Ian Pratt <ian.pratt@xxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Christian Limpach <Christian.Limpach@xxxxxxxxxxxx> |
Delivery-date: |
Mon, 16 Jul 2007 16:58:51 -0700 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxx |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
References: |
<20070716231536.937393000@xxxxxxxxxxxxx>> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
User-agent: |
quilt/0.46-1 |
Allocate/release a chunk of vmalloc address space:
alloc_vm_area reserves a chunk of address space, and makes sure all
the pagetables are constructed for that address range - but no pages.
free_vm_area releases the address space range.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx>
Signed-off-by: Ian Pratt <ian.pratt@xxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
Cc: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Cc: "Andi Kleen" <ak@xxxxxx>
---
include/linux/vmalloc.h | 4 +++
mm/vmalloc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
===================================================================
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -69,6 +69,10 @@ extern int map_vm_area(struct vm_struct
struct page ***pages);
extern void unmap_vm_area(struct vm_struct *area);
+/* Allocate/destroy a 'vmalloc' VM area. */
+extern struct vm_struct *alloc_vm_area(size_t size);
+extern void free_vm_area(struct vm_struct *area);
+
/*
* Internals. Dont't use..
*/
===================================================================
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -762,3 +762,56 @@ void __attribute__((weak)) vmalloc_sync
void __attribute__((weak)) vmalloc_sync_all(void)
{
}
+
+
+static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
+{
+ /* apply_to_page_range() does all the hard work. */
+ return 0;
+}
+
+/**
+ * alloc_vm_area - allocate a range of kernel address space
+ * @size: size of the area
+ * @returns: NULL on failure, vm_struct on success
+ *
+ * This function reserves a range of kernel address space, and
+ * allocates pagetables to map that range. No actual mappings
+ * are created. If the kernel address space is not shared
+ * between processes, it syncs the pagetable across all
+ * processes.
+ */
+struct vm_struct *alloc_vm_area(size_t size)
+{
+ struct vm_struct *area;
+
+ area = get_vm_area(size, VM_IOREMAP);
+ if (area == NULL)
+ return NULL;
+
+ /*
+ * This ensures that page tables are constructed for this region
+ * of kernel virtual address space and mapped into init_mm.
+ */
+ if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
+ area->size, f, NULL)) {
+ free_vm_area(area);
+ return NULL;
+ }
+
+ /* Make sure the pagetables are constructed in process kernel
+ mappings */
+ vmalloc_sync_all();
+
+ return area;
+}
+EXPORT_SYMBOL_GPL(alloc_vm_area);
+
+void free_vm_area(struct vm_struct *area)
+{
+ struct vm_struct *ret;
+ ret = remove_vm_area(area->addr);
+ BUG_ON(ret != area);
+ kfree(area);
+}
+EXPORT_SYMBOL_GPL(free_vm_area);
--
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- Re: [Xen-devel] [patch 03/44] usermodehelper: split setup from execution, (continued)
- [Xen-devel] [patch 10/44] paravirt: unstatic leave_mm, Jeremy Fitzhardinge
- [Xen-devel] [patch 12/44] paravirt: make siblingmap functions visible, Jeremy Fitzhardinge
- [Xen-devel] [patch 08/44] paravirt: add a hook for once the allocator is ready, Jeremy Fitzhardinge
- [Xen-devel] [patch 05/44] usermodehelper: Tidy up waiting, Jeremy Fitzhardinge
- [Xen-devel] [patch 06/44] use elfnote.h to generate vsyscall notes., Jeremy Fitzhardinge
- [Xen-devel] [patch 13/44] paravirt: export __supported_pte_mask, Jeremy Fitzhardinge
- [Xen-devel] [patch 17/44] Add nosegneg capability to the vsyscall page notes, Jeremy Fitzhardinge
- [Xen-devel] [patch 14/44] Allocate and free vmalloc areas,
Jeremy Fitzhardinge <=
- [Xen-devel] [patch 23/44] xen: configuration, Jeremy Fitzhardinge
- [Xen-devel] [patch 26/44] xen: ignore RW mapping of RO pages in pagetable_init, Jeremy Fitzhardinge
- [Xen-devel] [patch 22/44] xen: time implementation, Jeremy Fitzhardinge
- [Xen-devel] [patch 33/44] xen: use the hvc console infrastructure for Xen console, Jeremy Fitzhardinge
- [Xen-devel] [patch 24/44] xen: add pinned page flag, Jeremy Fitzhardinge
- [Xen-devel] [patch 25/44] xen: Complete pagetable pinning, Jeremy Fitzhardinge
- [Xen-devel] [patch 21/44] xen: event channels, Jeremy Fitzhardinge
- [Xen-devel] [patch 38/44] xen: machine operations, Jeremy Fitzhardinge
- [Xen-devel] [patch 29/44] xen: SMP guest support, Jeremy Fitzhardinge
- [Xen-devel] [patch 31/44] xen: lazy-mmu operations, Jeremy Fitzhardinge
|
|
|