Merge tag 'rcu.next.v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/boqun...
[linux-2.6-microblaze.git] / include / linux / zswap.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ZSWAP_H
3 #define _LINUX_ZSWAP_H
4
5 #include <linux/types.h>
6 #include <linux/mm_types.h>
7
8 struct lruvec;
9
10 extern u64 zswap_pool_total_size;
11 extern atomic_t zswap_stored_pages;
12
13 #ifdef CONFIG_ZSWAP
14
15 struct zswap_lruvec_state {
16         /*
17          * Number of pages in zswap that should be protected from the shrinker.
18          * This number is an estimate of the following counts:
19          *
20          * a) Recent page faults.
21          * b) Recent insertion to the zswap LRU. This includes new zswap stores,
22          *    as well as recent zswap LRU rotations.
23          *
24          * These pages are likely to be warm, and might incur IO if the are written
25          * to swap.
26          */
27         atomic_long_t nr_zswap_protected;
28 };
29
30 bool zswap_store(struct folio *folio);
31 bool zswap_load(struct folio *folio);
32 void zswap_invalidate(int type, pgoff_t offset);
33 void zswap_swapon(int type);
34 void zswap_swapoff(int type);
35 void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg);
36 void zswap_lruvec_state_init(struct lruvec *lruvec);
37 void zswap_folio_swapin(struct folio *folio);
38 bool is_zswap_enabled(void);
39 #else
40
41 struct zswap_lruvec_state {};
42
43 static inline bool zswap_store(struct folio *folio)
44 {
45         return false;
46 }
47
48 static inline bool zswap_load(struct folio *folio)
49 {
50         return false;
51 }
52
53 static inline void zswap_invalidate(int type, pgoff_t offset) {}
54 static inline void zswap_swapon(int type) {}
55 static inline void zswap_swapoff(int type) {}
56 static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {}
57 static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {}
58 static inline void zswap_folio_swapin(struct folio *folio) {}
59
60 static inline bool is_zswap_enabled(void)
61 {
62         return false;
63 }
64
65 #endif
66
67 #endif /* _LINUX_ZSWAP_H */