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>
10 #ifdef CONFIG_PAGE_EXTENSION
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
;
33 * The page_ext_flags users must set need_shared_flags to true.
37 PAGE_EXT_OWNER_ALLOCATED
,
38 #if defined(CONFIG_PAGE_IDLE_FLAG) && !defined(CONFIG_64BIT)
45 * Page Extension can be considered as an extended mem_map.
46 * A page_ext page is associated with every page descriptor. The
47 * page_ext helps us add more information about the page.
48 * All page_ext are allocated at boot or memory hotplug event,
49 * then the page_ext for pfn always exists.
55 extern bool early_page_ext
;
56 extern unsigned long page_ext_size
;
57 extern void pgdat_page_ext_init(struct pglist_data
*pgdat
);
59 static inline bool early_page_ext_enabled(void)
61 return early_page_ext
;
64 #ifdef CONFIG_SPARSEMEM
65 static inline void page_ext_init_flatmem(void)
68 extern void page_ext_init(void);
69 static inline void page_ext_init_flatmem_late(void)
73 extern void page_ext_init_flatmem(void);
74 extern void page_ext_init_flatmem_late(void);
75 static inline void page_ext_init(void)
80 extern struct page_ext
*page_ext_get(const struct page
*page
);
81 extern void page_ext_put(struct page_ext
*page_ext
);
83 static inline void *page_ext_data(struct page_ext
*page_ext
,
84 struct page_ext_operations
*ops
)
86 return (void *)(page_ext
) + ops
->offset
;
89 static inline struct page_ext
*page_ext_next(struct page_ext
*curr
)
92 next
+= page_ext_size
;
96 #else /* !CONFIG_PAGE_EXTENSION */
99 static inline bool early_page_ext_enabled(void)
104 static inline void pgdat_page_ext_init(struct pglist_data
*pgdat
)
108 static inline void page_ext_init(void)
112 static inline void page_ext_init_flatmem_late(void)
116 static inline void page_ext_init_flatmem(void)
120 static inline struct page_ext
*page_ext_get(const struct page
*page
)
125 static inline void page_ext_put(struct page_ext
*page_ext
)
128 #endif /* CONFIG_PAGE_EXTENSION */
129 #endif /* __LINUX_PAGE_EXT_H */