internal.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* internal.h: mm/ internal definitions
  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. #ifndef __MM_INTERNAL_H
  12. #define __MM_INTERNAL_H
  13. #include <linux/mm.h>
  14. void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
  15. unsigned long floor, unsigned long ceiling);
  16. extern void prep_compound_page(struct page *page, unsigned long order);
  17. static inline void set_page_count(struct page *page, int v)
  18. {
  19. atomic_set(&page->_count, v);
  20. }
  21. /*
  22. * Turn a non-refcounted page (->_count == 0) into refcounted with
  23. * a count of one.
  24. */
  25. static inline void set_page_refcounted(struct page *page)
  26. {
  27. VM_BUG_ON(PageTail(page));
  28. VM_BUG_ON(atomic_read(&page->_count));
  29. set_page_count(page, 1);
  30. }
  31. static inline void __put_page(struct page *page)
  32. {
  33. atomic_dec(&page->_count);
  34. }
  35. /*
  36. * in mm/vmscan.c:
  37. */
  38. extern int isolate_lru_page(struct page *page);
  39. extern void putback_lru_page(struct page *page);
  40. /*
  41. * in mm/page_alloc.c
  42. */
  43. extern void __free_pages_bootmem(struct page *page, unsigned int order);
  44. /*
  45. * function for dealing with page's order in buddy system.
  46. * zone->lock is already acquired when we use these.
  47. * So, we don't need atomic page->flags operations here.
  48. */
  49. static inline unsigned long page_order(struct page *page)
  50. {
  51. VM_BUG_ON(!PageBuddy(page));
  52. return page_private(page);
  53. }
  54. #ifdef CONFIG_UNEVICTABLE_LRU
  55. /*
  56. * unevictable_migrate_page() called only from migrate_page_copy() to
  57. * migrate unevictable flag to new page.
  58. * Note that the old page has been isolated from the LRU lists at this
  59. * point so we don't need to worry about LRU statistics.
  60. */
  61. static inline void unevictable_migrate_page(struct page *new, struct page *old)
  62. {
  63. if (TestClearPageUnevictable(old))
  64. SetPageUnevictable(new);
  65. }
  66. #else
  67. static inline void unevictable_migrate_page(struct page *new, struct page *old)
  68. {
  69. }
  70. #endif
  71. /*
  72. * FLATMEM and DISCONTIGMEM configurations use alloc_bootmem_node,
  73. * so all functions starting at paging_init should be marked __init
  74. * in those cases. SPARSEMEM, however, allows for memory hotplug,
  75. * and alloc_bootmem_node is not used.
  76. */
  77. #ifdef CONFIG_SPARSEMEM
  78. #define __paginginit __meminit
  79. #else
  80. #define __paginginit __init
  81. #endif
  82. /* Memory initialisation debug and verification */
  83. enum mminit_level {
  84. MMINIT_WARNING,
  85. MMINIT_VERIFY,
  86. MMINIT_TRACE
  87. };
  88. #ifdef CONFIG_DEBUG_MEMORY_INIT
  89. extern int mminit_loglevel;
  90. #define mminit_dprintk(level, prefix, fmt, arg...) \
  91. do { \
  92. if (level < mminit_loglevel) { \
  93. printk(level <= MMINIT_WARNING ? KERN_WARNING : KERN_DEBUG); \
  94. printk(KERN_CONT "mminit::" prefix " " fmt, ##arg); \
  95. } \
  96. } while (0)
  97. extern void mminit_verify_pageflags_layout(void);
  98. extern void mminit_verify_page_links(struct page *page,
  99. enum zone_type zone, unsigned long nid, unsigned long pfn);
  100. extern void mminit_verify_zonelist(void);
  101. #else
  102. static inline void mminit_dprintk(enum mminit_level level,
  103. const char *prefix, const char *fmt, ...)
  104. {
  105. }
  106. static inline void mminit_verify_pageflags_layout(void)
  107. {
  108. }
  109. static inline void mminit_verify_page_links(struct page *page,
  110. enum zone_type zone, unsigned long nid, unsigned long pfn)
  111. {
  112. }
  113. static inline void mminit_verify_zonelist(void)
  114. {
  115. }
  116. #endif /* CONFIG_DEBUG_MEMORY_INIT */
  117. /* mminit_validate_memmodel_limits is independent of CONFIG_DEBUG_MEMORY_INIT */
  118. #if defined(CONFIG_SPARSEMEM)
  119. extern void mminit_validate_memmodel_limits(unsigned long *start_pfn,
  120. unsigned long *end_pfn);
  121. #else
  122. static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
  123. unsigned long *end_pfn)
  124. {
  125. }
  126. #endif /* CONFIG_SPARSEMEM */
  127. #endif