mmu.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. vmi->used += vma->size;
  47. free_area_size = (unsigned long) vma->addr - prev_end;
  48. if (vmi->largest_chunk < free_area_size)
  49. vmi->largest_chunk = free_area_size;
  50. prev_end = vma->size + (unsigned long) vma->addr;
  51. }
  52. if (VMALLOC_END - prev_end > vmi->largest_chunk)
  53. vmi->largest_chunk = VMALLOC_END - prev_end;
  54. read_unlock(&vmlist_lock);
  55. }
  56. }