]> Git Repo - J-linux.git/blob - include/linux/zswap.h
Merge tag 'apparmor-pr-2024-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git...
[J-linux.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 atomic_t zswap_stored_pages;
11
12 #ifdef CONFIG_ZSWAP
13
14 struct zswap_lruvec_state {
15         /*
16          * Number of pages in zswap that should be protected from the shrinker.
17          * This number is an estimate of the following counts:
18          *
19          * a) Recent page faults.
20          * b) Recent insertion to the zswap LRU. This includes new zswap stores,
21          *    as well as recent zswap LRU rotations.
22          *
23          * These pages are likely to be warm, and might incur IO if the are written
24          * to swap.
25          */
26         atomic_long_t nr_zswap_protected;
27 };
28
29 unsigned long zswap_total_pages(void);
30 bool zswap_store(struct folio *folio);
31 bool zswap_load(struct folio *folio);
32 void zswap_invalidate(swp_entry_t swp);
33 int zswap_swapon(int type, unsigned long nr_pages);
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 zswap_is_enabled(void);
39 bool zswap_never_enabled(void);
40 #else
41
42 struct zswap_lruvec_state {};
43
44 static inline bool zswap_store(struct folio *folio)
45 {
46         return false;
47 }
48
49 static inline bool zswap_load(struct folio *folio)
50 {
51         return false;
52 }
53
54 static inline void zswap_invalidate(swp_entry_t swp) {}
55 static inline int zswap_swapon(int type, unsigned long nr_pages)
56 {
57         return 0;
58 }
59 static inline void zswap_swapoff(int type) {}
60 static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {}
61 static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {}
62 static inline void zswap_folio_swapin(struct folio *folio) {}
63
64 static inline bool zswap_is_enabled(void)
65 {
66         return false;
67 }
68
69 static inline bool zswap_never_enabled(void)
70 {
71         return true;
72 }
73
74 #endif
75
76 #endif /* _LINUX_ZSWAP_H */
This page took 0.0321709999999999 seconds and 4 git commands to generate.