]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* mmu.c: mmu memory info files |
2 | * | |
3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | |
4 | * Written by David Howells ([email protected]) | |
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 | */ | |
11 | ||
12 | #include <linux/types.h> | |
13 | #include <linux/errno.h> | |
14 | #include <linux/time.h> | |
15 | #include <linux/kernel.h> | |
16 | #include <linux/string.h> | |
17 | #include <linux/mman.h> | |
18 | #include <linux/proc_fs.h> | |
19 | #include <linux/mm.h> | |
20 | #include <linux/mmzone.h> | |
21 | #include <linux/pagemap.h> | |
22 | #include <linux/swap.h> | |
23 | #include <linux/slab.h> | |
24 | #include <linux/smp.h> | |
25 | #include <linux/seq_file.h> | |
26 | #include <linux/hugetlb.h> | |
27 | #include <linux/vmalloc.h> | |
28 | #include <asm/uaccess.h> | |
29 | #include <asm/pgtable.h> | |
30 | #include <asm/tlb.h> | |
31 | #include <asm/div64.h> | |
32 | #include "internal.h" | |
33 | ||
34 | void get_vmalloc_info(struct vmalloc_info *vmi) | |
35 | { | |
36 | struct vm_struct *vma; | |
37 | unsigned long free_area_size; | |
38 | unsigned long prev_end; | |
39 | ||
40 | vmi->used = 0; | |
41 | ||
42 | if (!vmlist) { | |
43 | vmi->largest_chunk = VMALLOC_TOTAL; | |
44 | } | |
45 | else { | |
46 | vmi->largest_chunk = 0; | |
47 | ||
48 | prev_end = VMALLOC_START; | |
49 | ||
50 | read_lock(&vmlist_lock); | |
51 | ||
52 | for (vma = vmlist; vma; vma = vma->next) { | |
64d13c00 HD |
53 | unsigned long addr = (unsigned long) vma->addr; |
54 | ||
55 | /* | |
56 | * Some archs keep another range for modules in vmlist | |
57 | */ | |
58 | if (addr < VMALLOC_START) | |
59 | continue; | |
60 | if (addr >= VMALLOC_END) | |
61 | break; | |
62 | ||
1da177e4 LT |
63 | vmi->used += vma->size; |
64 | ||
64d13c00 | 65 | free_area_size = addr - prev_end; |
1da177e4 LT |
66 | if (vmi->largest_chunk < free_area_size) |
67 | vmi->largest_chunk = free_area_size; | |
68 | ||
64d13c00 | 69 | prev_end = vma->size + addr; |
1da177e4 LT |
70 | } |
71 | ||
72 | if (VMALLOC_END - prev_end > vmi->largest_chunk) | |
73 | vmi->largest_chunk = VMALLOC_END - prev_end; | |
74 | ||
75 | read_unlock(&vmlist_lock); | |
76 | } | |
77 | } |