blob: 03f2a3e7d76d40ee457b8ab6f2d140d1ee9475b1 [file] [log] [blame]
Joonsoo Kimeefa8642014-12-12 16:55:46 -08001#ifndef __LINUX_PAGE_EXT_H
2#define __LINUX_PAGE_EXT_H
3
Joonsoo Kim48c96a32014-12-12 16:56:01 -08004#include <linux/types.h>
5#include <linux/stacktrace.h>
Joonsoo Kimf2ca0b52016-07-26 15:23:55 -07006#include <linux/stackdepot.h>
Joonsoo Kim48c96a32014-12-12 16:56:01 -08007
Joonsoo Kimeefa8642014-12-12 16:55:46 -08008struct pglist_data;
9struct page_ext_operations {
10 bool (*need)(void);
11 void (*init)(void);
12};
13
14#ifdef CONFIG_PAGE_EXTENSION
15
16/*
Joonsoo Kime30825f2014-12-12 16:55:49 -080017 * page_ext->flags bits:
18 *
19 * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
20 * implement generic debug pagealloc feature. The pages are filled with
21 * poison patterns and set this flag after free_pages(). The poisoned
22 * pages are verified whether the patterns are not corrupted and clear
23 * the flag before alloc_pages().
24 */
25
26enum page_ext_flags {
27 PAGE_EXT_DEBUG_POISON, /* Page is poisoned */
28 PAGE_EXT_DEBUG_GUARD,
Joonsoo Kim48c96a32014-12-12 16:56:01 -080029 PAGE_EXT_OWNER,
Vladimir Davydov33c3fc72015-09-09 15:35:45 -070030#if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
31 PAGE_EXT_YOUNG,
32 PAGE_EXT_IDLE,
33#endif
Joonsoo Kime30825f2014-12-12 16:55:49 -080034};
35
36/*
Joonsoo Kimeefa8642014-12-12 16:55:46 -080037 * Page Extension can be considered as an extended mem_map.
38 * A page_ext page is associated with every page descriptor. The
39 * page_ext helps us add more information about the page.
40 * All page_ext are allocated at boot or memory hotplug event,
41 * then the page_ext for pfn always exists.
42 */
43struct page_ext {
44 unsigned long flags;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080045#ifdef CONFIG_PAGE_OWNER
46 unsigned int order;
47 gfp_t gfp_mask;
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070048 int last_migrate_reason;
Joonsoo Kimf2ca0b52016-07-26 15:23:55 -070049 depot_stack_handle_t handle;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080050#endif
Joonsoo Kimeefa8642014-12-12 16:55:46 -080051};
52
53extern void pgdat_page_ext_init(struct pglist_data *pgdat);
54
55#ifdef CONFIG_SPARSEMEM
56static inline void page_ext_init_flatmem(void)
57{
58}
59extern void page_ext_init(void);
60#else
61extern void page_ext_init_flatmem(void);
62static inline void page_ext_init(void)
63{
64}
65#endif
66
67struct page_ext *lookup_page_ext(struct page *page);
68
69#else /* !CONFIG_PAGE_EXTENSION */
70struct page_ext;
71
72static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
73{
74}
75
76static inline struct page_ext *lookup_page_ext(struct page *page)
77{
78 return NULL;
79}
80
81static inline void page_ext_init(void)
82{
83}
84
85static inline void page_ext_init_flatmem(void)
86{
87}
88#endif /* CONFIG_PAGE_EXTENSION */
89#endif /* __LINUX_PAGE_EXT_H */