blob: 179bdc4a470c06cde4c266722d60270604fe3a83 [file] [log] [blame]
Joonsoo Kimeefa864b2014-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 Kimeefa864b2014-12-12 16:55:46 -08008struct pglist_data;
9struct page_ext_operations {
Joonsoo Kim980ac162016-10-07 16:58:27 -070010 size_t offset;
11 size_t size;
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080012 bool (*need)(void);
13 void (*init)(void);
14};
15
16#ifdef CONFIG_PAGE_EXTENSION
17
18/*
Joonsoo Kime30825f2014-12-12 16:55:49 -080019 * page_ext->flags bits:
20 *
21 * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
22 * implement generic debug pagealloc feature. The pages are filled with
23 * poison patterns and set this flag after free_pages(). The poisoned
24 * pages are verified whether the patterns are not corrupted and clear
25 * the flag before alloc_pages().
26 */
27
28enum page_ext_flags {
29 PAGE_EXT_DEBUG_POISON, /* Page is poisoned */
30 PAGE_EXT_DEBUG_GUARD,
Joonsoo Kim48c96a32014-12-12 16:56:01 -080031 PAGE_EXT_OWNER,
Vladimir Davydov33c3fc72015-09-09 15:35:45 -070032#if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
33 PAGE_EXT_YOUNG,
34 PAGE_EXT_IDLE,
35#endif
Joonsoo Kime30825f2014-12-12 16:55:49 -080036};
37
38/*
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080039 * Page Extension can be considered as an extended mem_map.
40 * A page_ext page is associated with every page descriptor. The
41 * page_ext helps us add more information about the page.
42 * All page_ext are allocated at boot or memory hotplug event,
43 * then the page_ext for pfn always exists.
44 */
45struct page_ext {
46 unsigned long flags;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080047#ifdef CONFIG_PAGE_OWNER
48 unsigned int order;
49 gfp_t gfp_mask;
Vlastimil Babka7cd12b42016-03-15 14:56:18 -070050 int last_migrate_reason;
Joonsoo Kimf2ca0b52016-07-26 15:23:55 -070051 depot_stack_handle_t handle;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080052#endif
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080053};
54
55extern void pgdat_page_ext_init(struct pglist_data *pgdat);
56
57#ifdef CONFIG_SPARSEMEM
58static inline void page_ext_init_flatmem(void)
59{
60}
61extern void page_ext_init(void);
62#else
63extern void page_ext_init_flatmem(void);
64static inline void page_ext_init(void)
65{
66}
67#endif
68
69struct page_ext *lookup_page_ext(struct page *page);
70
71#else /* !CONFIG_PAGE_EXTENSION */
72struct page_ext;
73
74static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
75{
76}
77
78static inline struct page_ext *lookup_page_ext(struct page *page)
79{
80 return NULL;
81}
82
83static inline void page_ext_init(void)
84{
85}
86
87static inline void page_ext_init_flatmem(void)
88{
89}
90#endif /* CONFIG_PAGE_EXTENSION */
91#endif /* __LINUX_PAGE_EXT_H */