page_ext.h 1.6 KB

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