page_ext.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __LINUX_PAGE_EXT_H
  2. #define __LINUX_PAGE_EXT_H
  3. #include <linux/types.h>
  4. #include <linux/stacktrace.h>
  5. struct pglist_data;
  6. struct page_ext_operations {
  7. bool (*need)(void);
  8. void (*init)(void);
  9. };
  10. #ifdef CONFIG_PAGE_EXTENSION
  11. /*
  12. * page_ext->flags bits:
  13. *
  14. * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
  15. * implement generic debug pagealloc feature. The pages are filled with
  16. * poison patterns and set this flag after free_pages(). The poisoned
  17. * pages are verified whether the patterns are not corrupted and clear
  18. * the flag before alloc_pages().
  19. */
  20. enum page_ext_flags {
  21. PAGE_EXT_DEBUG_POISON, /* Page is poisoned */
  22. PAGE_EXT_DEBUG_GUARD,
  23. PAGE_EXT_OWNER,
  24. #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
  25. PAGE_EXT_YOUNG,
  26. PAGE_EXT_IDLE,
  27. #endif
  28. };
  29. /*
  30. * Page Extension can be considered as an extended mem_map.
  31. * A page_ext page is associated with every page descriptor. The
  32. * page_ext helps us add more information about the page.
  33. * All page_ext are allocated at boot or memory hotplug event,
  34. * then the page_ext for pfn always exists.
  35. */
  36. struct page_ext {
  37. unsigned long flags;
  38. #ifdef CONFIG_PAGE_OWNER
  39. unsigned int order;
  40. gfp_t gfp_mask;
  41. unsigned int nr_entries;
  42. unsigned long trace_entries[8];
  43. #endif
  44. };
  45. extern void pgdat_page_ext_init(struct pglist_data *pgdat);
  46. #ifdef CONFIG_SPARSEMEM
  47. static inline void page_ext_init_flatmem(void)
  48. {
  49. }
  50. extern void page_ext_init(void);
  51. #else
  52. extern void page_ext_init_flatmem(void);
  53. static inline void page_ext_init(void)
  54. {
  55. }
  56. #endif
  57. struct page_ext *lookup_page_ext(struct page *page);
  58. #else /* !CONFIG_PAGE_EXTENSION */
  59. struct page_ext;
  60. static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
  61. {
  62. }
  63. static inline struct page_ext *lookup_page_ext(struct page *page)
  64. {
  65. return NULL;
  66. }
  67. static inline void page_ext_init(void)
  68. {
  69. }
  70. static inline void page_ext_init_flatmem(void)
  71. {
  72. }
  73. #endif /* CONFIG_PAGE_EXTENSION */
  74. #endif /* __LINUX_PAGE_EXT_H */