Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* mmu.c: mmu memory info files |
| 2 | * |
| 3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
Alexey Dobriyan | 87400c0 | 2007-10-16 23:26:19 -0700 | [diff] [blame] | 11 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/vmalloc.h> |
Alexey Dobriyan | 87400c0 | 2007-10-16 23:26:19 -0700 | [diff] [blame] | 13 | #include <linux/highmem.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include "internal.h" |
| 16 | |
| 17 | void get_vmalloc_info(struct vmalloc_info *vmi) |
| 18 | { |
| 19 | struct vm_struct *vma; |
| 20 | unsigned long free_area_size; |
| 21 | unsigned long prev_end; |
| 22 | |
| 23 | vmi->used = 0; |
| 24 | |
| 25 | if (!vmlist) { |
| 26 | vmi->largest_chunk = VMALLOC_TOTAL; |
| 27 | } |
| 28 | else { |
| 29 | vmi->largest_chunk = 0; |
| 30 | |
| 31 | prev_end = VMALLOC_START; |
| 32 | |
| 33 | read_lock(&vmlist_lock); |
| 34 | |
| 35 | for (vma = vmlist; vma; vma = vma->next) { |
Hugh Dickins | 64d13c0 | 2005-05-16 21:53:09 -0700 | [diff] [blame] | 36 | unsigned long addr = (unsigned long) vma->addr; |
| 37 | |
| 38 | /* |
| 39 | * Some archs keep another range for modules in vmlist |
| 40 | */ |
| 41 | if (addr < VMALLOC_START) |
| 42 | continue; |
| 43 | if (addr >= VMALLOC_END) |
| 44 | break; |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | vmi->used += vma->size; |
| 47 | |
Hugh Dickins | 64d13c0 | 2005-05-16 21:53:09 -0700 | [diff] [blame] | 48 | free_area_size = addr - prev_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | if (vmi->largest_chunk < free_area_size) |
| 50 | vmi->largest_chunk = free_area_size; |
| 51 | |
Hugh Dickins | 64d13c0 | 2005-05-16 21:53:09 -0700 | [diff] [blame] | 52 | prev_end = vma->size + addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | if (VMALLOC_END - prev_end > vmi->largest_chunk) |
| 56 | vmi->largest_chunk = VMALLOC_END - prev_end; |
| 57 | |
| 58 | read_unlock(&vmlist_lock); |
| 59 | } |
| 60 | } |