blob: ca5461efae2f1834a83d7b17289fdb3fecf15be6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Joonsoo Kimeefa864b2014-12-12 16:55:46 -08002#ifndef __LINUX_PAGE_EXT_H
3#define __LINUX_PAGE_EXT_H
4
Joonsoo Kim48c96a32014-12-12 16:56:01 -08005#include <linux/types.h>
6#include <linux/stacktrace.h>
Joonsoo Kimf2ca0b52016-07-26 15:23:55 -07007#include <linux/stackdepot.h>
Joonsoo Kim48c96a32014-12-12 16:56:01 -08008
Joonsoo Kimeefa864b2014-12-12 16:55:46 -08009struct pglist_data;
10struct page_ext_operations {
Joonsoo Kim980ac162016-10-07 16:58:27 -070011 size_t offset;
12 size_t size;
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080013 bool (*need)(void);
14 void (*init)(void);
15};
16
17#ifdef CONFIG_PAGE_EXTENSION
18
19/*
Joonsoo Kime30825f2014-12-12 16:55:49 -080020 * 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
29enum page_ext_flags {
30 PAGE_EXT_DEBUG_POISON, /* Page is poisoned */
31 PAGE_EXT_DEBUG_GUARD,
Joonsoo Kim48c96a32014-12-12 16:56:01 -080032 PAGE_EXT_OWNER,
Vladimir Davydov33c3fc72015-09-09 15:35:45 -070033#if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
34 PAGE_EXT_YOUNG,
35 PAGE_EXT_IDLE,
36#endif
Joonsoo Kime30825f2014-12-12 16:55:49 -080037};
38
39/*
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080040 * 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 */
46struct page_ext {
47 unsigned long flags;
Joonsoo Kimeefa864b2014-12-12 16:55:46 -080048};
49
50extern void pgdat_page_ext_init(struct pglist_data *pgdat);
51
52#ifdef CONFIG_SPARSEMEM
53static inline void page_ext_init_flatmem(void)
54{
55}
56extern void page_ext_init(void);
57#else
58extern void page_ext_init_flatmem(void);
59static inline void page_ext_init(void)
60{
61}
62#endif
63
64struct page_ext *lookup_page_ext(struct page *page);
65
66#else /* !CONFIG_PAGE_EXTENSION */
67struct page_ext;
68
69static inline void pgdat_page_ext_init(struct pglist_data *pgdat)
70{
71}
72
73static inline struct page_ext *lookup_page_ext(struct page *page)
74{
75 return NULL;
76}
77
78static inline void page_ext_init(void)
79{
80}
81
82static inline void page_ext_init_flatmem(void)
83{
84}
85#endif /* CONFIG_PAGE_EXTENSION */
86#endif /* __LINUX_PAGE_EXT_H */