1 #ifndef _LINUX_FRONTSWAP_H
2 #define _LINUX_FRONTSWAP_H
4 #include <linux/swap.h>
6 #include <linux/bitops.h>
7 #include <linux/jump_label.h>
10 void (*init
)(unsigned); /* this swap type was just swapon'ed */
11 int (*store
)(unsigned, pgoff_t
, struct page
*); /* store a page */
12 int (*load
)(unsigned, pgoff_t
, struct page
*); /* load a page */
13 void (*invalidate_page
)(unsigned, pgoff_t
); /* page no longer needed */
14 void (*invalidate_area
)(unsigned); /* swap type just swapoff'ed */
15 struct frontswap_ops
*next
; /* private pointer to next ops */
18 extern void frontswap_register_ops(struct frontswap_ops
*ops
);
19 extern void frontswap_shrink(unsigned long);
20 extern unsigned long frontswap_curr_pages(void);
21 extern void frontswap_writethrough(bool);
22 #define FRONTSWAP_HAS_EXCLUSIVE_GETS
23 extern void frontswap_tmem_exclusive_gets(bool);
25 extern bool __frontswap_test(struct swap_info_struct
*, pgoff_t
);
26 extern void __frontswap_init(unsigned type
, unsigned long *map
);
27 extern int __frontswap_store(struct page
*page
);
28 extern int __frontswap_load(struct page
*page
);
29 extern void __frontswap_invalidate_page(unsigned, pgoff_t
);
30 extern void __frontswap_invalidate_area(unsigned);
32 #ifdef CONFIG_FRONTSWAP
33 extern struct static_key_false frontswap_enabled_key
;
35 static inline bool frontswap_enabled(void)
37 return static_branch_unlikely(&frontswap_enabled_key
);
40 static inline bool frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
42 return __frontswap_test(sis
, offset
);
45 static inline void frontswap_map_set(struct swap_info_struct
*p
,
48 p
->frontswap_map
= map
;
51 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
53 return p
->frontswap_map
;
56 /* all inline routines become no-ops and all externs are ignored */
58 static inline bool frontswap_enabled(void)
63 static inline bool frontswap_test(struct swap_info_struct
*sis
, pgoff_t offset
)
68 static inline void frontswap_map_set(struct swap_info_struct
*p
,
73 static inline unsigned long *frontswap_map_get(struct swap_info_struct
*p
)
79 static inline int frontswap_store(struct page
*page
)
81 if (frontswap_enabled())
82 return __frontswap_store(page
);
87 static inline int frontswap_load(struct page
*page
)
89 if (frontswap_enabled())
90 return __frontswap_load(page
);
95 static inline void frontswap_invalidate_page(unsigned type
, pgoff_t offset
)
97 if (frontswap_enabled())
98 __frontswap_invalidate_page(type
, offset
);
101 static inline void frontswap_invalidate_area(unsigned type
)
103 if (frontswap_enabled())
104 __frontswap_invalidate_area(type
);
107 static inline void frontswap_init(unsigned type
, unsigned long *map
)
109 #ifdef CONFIG_FRONTSWAP
110 __frontswap_init(type
, map
);
114 #endif /* _LINUX_FRONTSWAP_H */