This source file includes following definitions.
- frontswap_enabled
- frontswap_test
- frontswap_map_set
- frontswap_map_get
- frontswap_enabled
- frontswap_test
- frontswap_map_set
- frontswap_map_get
- frontswap_store
- frontswap_load
- frontswap_invalidate_page
- frontswap_invalidate_area
- frontswap_init
1
2 #ifndef _LINUX_FRONTSWAP_H
3 #define _LINUX_FRONTSWAP_H
4
5 #include <linux/swap.h>
6 #include <linux/mm.h>
7 #include <linux/bitops.h>
8 #include <linux/jump_label.h>
9
10
11
12
13
14
15 #define FRONTSWAP_PAGES_UNUSED 2
16
17 struct frontswap_ops {
18 void (*init)(unsigned);
19 int (*store)(unsigned, pgoff_t, struct page *);
20 int (*load)(unsigned, pgoff_t, struct page *);
21 void (*invalidate_page)(unsigned, pgoff_t);
22 void (*invalidate_area)(unsigned);
23 struct frontswap_ops *next;
24 };
25
26 extern void frontswap_register_ops(struct frontswap_ops *ops);
27 extern void frontswap_shrink(unsigned long);
28 extern unsigned long frontswap_curr_pages(void);
29 extern void frontswap_writethrough(bool);
30 #define FRONTSWAP_HAS_EXCLUSIVE_GETS
31 extern void frontswap_tmem_exclusive_gets(bool);
32
33 extern bool __frontswap_test(struct swap_info_struct *, pgoff_t);
34 extern void __frontswap_init(unsigned type, unsigned long *map);
35 extern int __frontswap_store(struct page *page);
36 extern int __frontswap_load(struct page *page);
37 extern void __frontswap_invalidate_page(unsigned, pgoff_t);
38 extern void __frontswap_invalidate_area(unsigned);
39
40 #ifdef CONFIG_FRONTSWAP
41 extern struct static_key_false frontswap_enabled_key;
42
43 static inline bool frontswap_enabled(void)
44 {
45 return static_branch_unlikely(&frontswap_enabled_key);
46 }
47
48 static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
49 {
50 return __frontswap_test(sis, offset);
51 }
52
53 static inline void frontswap_map_set(struct swap_info_struct *p,
54 unsigned long *map)
55 {
56 p->frontswap_map = map;
57 }
58
59 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
60 {
61 return p->frontswap_map;
62 }
63 #else
64
65
66 static inline bool frontswap_enabled(void)
67 {
68 return false;
69 }
70
71 static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
72 {
73 return false;
74 }
75
76 static inline void frontswap_map_set(struct swap_info_struct *p,
77 unsigned long *map)
78 {
79 }
80
81 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
82 {
83 return NULL;
84 }
85 #endif
86
87 static inline int frontswap_store(struct page *page)
88 {
89 if (frontswap_enabled())
90 return __frontswap_store(page);
91
92 return -1;
93 }
94
95 static inline int frontswap_load(struct page *page)
96 {
97 if (frontswap_enabled())
98 return __frontswap_load(page);
99
100 return -1;
101 }
102
103 static inline void frontswap_invalidate_page(unsigned type, pgoff_t offset)
104 {
105 if (frontswap_enabled())
106 __frontswap_invalidate_page(type, offset);
107 }
108
109 static inline void frontswap_invalidate_area(unsigned type)
110 {
111 if (frontswap_enabled())
112 __frontswap_invalidate_area(type);
113 }
114
115 static inline void frontswap_init(unsigned type, unsigned long *map)
116 {
117 #ifdef CONFIG_FRONTSWAP
118 __frontswap_init(type, map);
119 #endif
120 }
121
122 #endif