page_ext.h 1.9 KB

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