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