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>
12 * struct page_ext_operations - per page_ext client operations
13 * @offset: Offset to the client's data within page_ext. Offset is returned to
14 * the client by page_ext_init.
15 * @size: The size of the client data within page_ext.
16 * @need: Function that returns true if client requires page_ext.
17 * @init: (optional) Called to initialize client once page_exts are allocated.
18 * @need_shared_flags: True when client is using shared page_ext->flags
21 * Each Page Extension client must define page_ext_operations in
24 struct page_ext_operations {
29 bool need_shared_flags;
32 #ifdef CONFIG_PAGE_EXTENSION
35 * The page_ext_flags users must set need_shared_flags to true.
39 PAGE_EXT_OWNER_ALLOCATED,
40 #if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT)
47 * Page Extension can be considered as an extended mem_map.
48 * A page_ext page is associated with every page descriptor. The
49 * page_ext helps us add more information about the page.
50 * All page_ext are allocated at boot or memory hotplug event,
51 * then the page_ext for pfn always exists.
57 extern bool early_page_ext;
58 extern unsigned long page_ext_size;
59 extern void pgdat_page_ext_init(struct pglist_data *pgdat);
61 static inline bool early_page_ext_enabled(void)
63 return early_page_ext;
66 #ifdef CONFIG_SPARSEMEM
67 static inline void page_ext_init_flatmem(void)
70 extern void page_ext_init(void);
71 static inline void page_ext_init_flatmem_late(void)
75 extern void page_ext_init_flatmem(void);
76 extern void page_ext_init_flatmem_late(void);
77 static inline void page_ext_init(void)
82 extern struct page_ext *page_ext_get(struct page *page);
83 extern void page_ext_put(struct page_ext *page_ext);
85 static inline struct page_ext *page_ext_next(struct page_ext *curr)
88 next += page_ext_size;
92 #else /* !CONFIG_PAGE_EXTENSION */
95 static inline bool early_page_ext_enabled(void)
100 static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
104 static inline void page_ext_init(void)
108 static inline void page_ext_init_flatmem_late(void)
112 static inline void page_ext_init_flatmem(void)
116 static inline struct page_ext *page_ext_get(struct page *page)
121 static inline void page_ext_put(struct page_ext *page_ext)
124 #endif /* CONFIG_PAGE_EXTENSION */
125 #endif /* __LINUX_PAGE_EXT_H */