blob: c42981cd99aae91b33d21a0deb4bc9f925a7fbd1 [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>
6
Joonsoo Kimeefa8642014-12-12 16:55:46 -08007struct pglist_data;
8struct page_ext_operations {
9 bool (*need)(void);
10 void (*init)(void);
11};
12
13#ifdef CONFIG_PAGE_EXTENSION
14
15/*
Joonsoo Kime30825f2014-12-12 16:55:49 -080016 * page_ext->flags bits:
17 *
18 * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
19 * implement generic debug pagealloc feature. The pages are filled with
20 * poison patterns and set this flag after free_pages(). The poisoned
21 * pages are verified whether the patterns are not corrupted and clear
22 * the flag before alloc_pages().
23 */
24
25enum page_ext_flags {
26 PAGE_EXT_DEBUG_POISON, /* Page is poisoned */
27 PAGE_EXT_DEBUG_GUARD,
Joonsoo Kim48c96a32014-12-12 16:56:01 -080028 PAGE_EXT_OWNER,
Joonsoo Kime30825f2014-12-12 16:55:49 -080029};
30
31/*
Joonsoo Kimeefa8642014-12-12 16:55:46 -080032 * Page Extension can be considered as an extended mem_map.
33 * A page_ext page is associated with every page descriptor. The
34 * page_ext helps us add more information about the page.
35 * All page_ext are allocated at boot or memory hotplug event,
36 * then the page_ext for pfn always exists.
37 */
38struct page_ext {
39 unsigned long flags;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080040#ifdef CONFIG_PAGE_OWNER
41 unsigned int order;
42 gfp_t gfp_mask;
Sergei Rogachev94f759d62015-02-11 15:28:34 -080043 unsigned int nr_entries;
Joonsoo Kim48c96a32014-12-12 16:56:01 -080044 unsigned long trace_entries[8];
45#endif
Joonsoo Kimeefa8642014-12-12 16:55:46 -080046};
47
48extern void pgdat_page_ext_init(struct pglist_data *pgdat);
49
50#ifdef CONFIG_SPARSEMEM
51static inline void page_ext_init_flatmem(void)
52{
53}
54extern void page_ext_init(void);
55#else
56extern void page_ext_init_flatmem(void);
57static inline void page_ext_init(void)
58{
59}
60#endif
61
62struct page_ext *lookup_page_ext(struct page *page);
63
64#else /* !CONFIG_PAGE_EXTENSION */
65struct page_ext;
66
67static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
68{
69}
70
71static inline struct page_ext *lookup_page_ext(struct page *page)
72{
73 return NULL;
74}
75
76static inline void page_ext_init(void)
77{
78}
79
80static inline void page_ext_init_flatmem(void)
81{
82}
83#endif /* CONFIG_PAGE_EXTENSION */
84#endif /* __LINUX_PAGE_EXT_H */