Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.git] / mm / vmalloc.c
index 712ae47..f1cc03b 100644 (file)
@@ -15,9 +15,9 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/debugobjects.h>
-#include <linux/vmalloc.h>
 #include <linux/kallsyms.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
@@ -175,6 +175,21 @@ static int vmap_page_range(unsigned long addr, unsigned long end,
        return nr;
 }
 
+static inline int is_vmalloc_or_module_addr(const void *x)
+{
+       /*
+        * x86-64 and sparc64 put modules in a special place,
+        * and fall back on vmalloc() if that fails. Others
+        * just put it in the vmalloc space.
+        */
+#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
+       unsigned long addr = (unsigned long)x;
+       if (addr >= MODULES_VADDR && addr < MODULES_END)
+               return 1;
+#endif
+       return is_vmalloc_addr(x);
+}
+
 /*
  * Walk a vmap address to the struct page it maps.
  */
@@ -188,8 +203,7 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
         * XXX we might need to change this if we add VIRTUAL_BUG_ON for
         * architectures that do not vmalloc module space
         */
-       VIRTUAL_BUG_ON(!is_vmalloc_addr(vmalloc_addr) &&
-                       !is_module_address(addr));
+       VIRTUAL_BUG_ON(!is_vmalloc_or_module_addr(vmalloc_addr));
 
        if (!pgd_none(*pgd)) {
                pud_t *pud = pud_offset(pgd, addr);
@@ -883,7 +897,8 @@ EXPORT_SYMBOL(vm_unmap_ram);
  * @count: number of pages
  * @node: prefer to allocate data structures on this node
  * @prot: memory protection to use. PAGE_KERNEL for regular RAM
- * @returns: a pointer to the address that has been mapped, or NULL on failure
+ *
+ * Returns: a pointer to the address that has been mapped, or %NULL on failure
  */
 void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t prot)
 {
@@ -1705,11 +1720,41 @@ static int s_show(struct seq_file *m, void *p)
        return 0;
 }
 
-const struct seq_operations vmalloc_op = {
+static const struct seq_operations vmalloc_op = {
        .start = s_start,
        .next = s_next,
        .stop = s_stop,
        .show = s_show,
 };
+
+static int vmalloc_open(struct inode *inode, struct file *file)
+{
+       unsigned int *ptr = NULL;
+       int ret;
+
+       if (NUMA_BUILD)
+               ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
+       ret = seq_open(file, &vmalloc_op);
+       if (!ret) {
+               struct seq_file *m = file->private_data;
+               m->private = ptr;
+       } else
+               kfree(ptr);
+       return ret;
+}
+
+static const struct file_operations proc_vmalloc_operations = {
+       .open           = vmalloc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release_private,
+};
+
+static int __init proc_vmalloc_init(void)
+{
+       proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
+       return 0;
+}
+module_init(proc_vmalloc_init);
 #endif