Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
8struct lruvec;
9
10extern u64 zswap_pool_total_size;
11extern atomic_t zswap_stored_pages;
12
13#ifdef CONFIG_ZSWAP
14
15struct 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
30bool zswap_store(struct folio *folio);
31bool zswap_load(struct folio *folio);
32void zswap_invalidate(int type, pgoff_t offset);
33void zswap_swapon(int type);
34void zswap_swapoff(int type);
35void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg);
36void zswap_lruvec_state_init(struct lruvec *lruvec);
37void zswap_folio_swapin(struct folio *folio);
38bool is_zswap_enabled(void);
39#else
40
41struct zswap_lruvec_state {};
42
43static inline bool zswap_store(struct folio *folio)
44{
45 return false;
46}
47
48static inline bool zswap_load(struct folio *folio)
49{
50 return false;
51}
52
53static inline void zswap_invalidate(int type, pgoff_t offset) {}
54static inline void zswap_swapon(int type) {}
55static inline void zswap_swapoff(int type) {}
56static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {}
57static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {}
58static inline void zswap_folio_swapin(struct folio *folio) {}
59
60static inline bool is_zswap_enabled(void)
61{
62 return false;
63}
64
65#endif
66
67#endif /* _LINUX_ZSWAP_H */