mmu.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. */
  11. #include <linux/types.h>
  12. #include <linux/errno.h>
  13. #include <linux/time.h>
  14. #include <linux/kernel.h>
  15. #include <linux/string.h>
  16. #include <linux/mman.h>
  17. #include <linux/proc_fs.h>
  18. #include <linux/mm.h>
  19. #include <linux/mmzone.h>
  20. #include <linux/pagemap.h>
  21. #include <linux/swap.h>
  22. #include <linux/slab.h>
  23. #include <linux/smp.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/hugetlb.h>
  26. #include <linux/vmalloc.h>
  27. #include <asm/uaccess.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/tlb.h>
  30. #include <asm/div64.h>
  31. #include "internal.h"
  32. void get_vmalloc_info(struct vmalloc_info *vmi)
  33. {
  34. struct vm_struct *vma;
  35. unsigned long free_area_size;
  36. unsigned long prev_end;
  37. vmi->used = 0;
  38. if (!vmlist) {
  39. vmi->largest_chunk = VMALLOC_TOTAL;
  40. }
  41. else {
  42. vmi->largest_chunk = 0;
  43. prev_end = VMALLOC_START;
  44. read_lock(&vmlist_lock);
  45. for (vma = vmlist; vma; vma = vma->next) {
  46. unsigned long addr = (unsigned long) vma->addr;
  47. /*
  48. * Some archs keep another range for modules in vmlist
  49. */
  50. if (addr < VMALLOC_START)
  51. continue;
  52. if (addr >= VMALLOC_END)
  53. break;
  54. vmi->used += vma->size;
  55. free_area_size = addr - prev_end;
  56. if (vmi->largest_chunk < free_area_size)
  57. vmi->largest_chunk = free_area_size;
  58. prev_end = vma->size + addr;
  59. }
  60. if (VMALLOC_END - prev_end > vmi->largest_chunk)
  61. vmi->largest_chunk = VMALLOC_END - prev_end;
  62. read_unlock(&vmlist_lock);
  63. }
  64. }