1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_PAGE_EXT_H
3 #define __LINUX_PAGE_EXT_H
5 #include <linux/types.h>
6 #include <linux/stacktrace.h>
7 #include <linux/stackdepot.h>
11 #ifdef CONFIG_PAGE_EXTENSION
13 * struct page_ext_operations - per page_ext client operations
14 * @offset: Offset to the client's data within page_ext. Offset is returned to
15 * the client by page_ext_init.
16 * @size: The size of the client data within page_ext.
17 * @need: Function that returns true if client requires page_ext.
18 * @init: (optional) Called to initialize client once page_exts are allocated.
19 * @need_shared_flags: True when client is using shared page_ext->flags
22 * Each Page Extension client must define page_ext_operations in
25 struct page_ext_operations {
30 bool need_shared_flags;
34 * The page_ext_flags users must set need_shared_flags to true.
38 PAGE_EXT_OWNER_ALLOCATED,
39 #if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT)
46 * Page Extension can be considered as an extended mem_map.
47 * A page_ext page is associated with every page descriptor. The
48 * page_ext helps us add more information about the page.
49 * All page_ext are allocated at boot or memory hotplug event,
50 * then the page_ext for pfn always exists.
56 extern bool early_page_ext;
57 extern unsigned long page_ext_size;
58 extern void pgdat_page_ext_init(struct pglist_data *pgdat);
60 static inline bool early_page_ext_enabled(void)
62 return early_page_ext;
65 #ifdef CONFIG_SPARSEMEM
66 static inline void page_ext_init_flatmem(void)
69 extern void page_ext_init(void);
70 static inline void page_ext_init_flatmem_late(void)
74 extern void page_ext_init_flatmem(void);
75 extern void page_ext_init_flatmem_late(void);
76 static inline void page_ext_init(void)
81 extern struct page_ext *page_ext_get(struct page *page);
82 extern void page_ext_put(struct page_ext *page_ext);
84 static inline void *page_ext_data(struct page_ext *page_ext,
85 struct page_ext_operations *ops)
87 return (void *)(page_ext) + ops->offset;
90 static inline struct page_ext *page_ext_next(struct page_ext *curr)
93 next += page_ext_size;
97 #else /* !CONFIG_PAGE_EXTENSION */
100 static inline bool early_page_ext_enabled(void)
105 static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
109 static inline void page_ext_init(void)
113 static inline void page_ext_init_flatmem_late(void)
117 static inline void page_ext_init_flatmem(void)
121 static inline struct page_ext *page_ext_get(struct page *page)
126 static inline void page_ext_put(struct page_ext *page_ext)
129 #endif /* CONFIG_PAGE_EXTENSION */
130 #endif /* __LINUX_PAGE_EXT_H */