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(swp_entry_t swp); 33int zswap_swapon(int type, unsigned long nr_pages); 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(swp_entry_t swp) {} 54static inline int zswap_swapon(int type, unsigned long nr_pages) 55{ 56 return 0; 57} 58static inline void zswap_swapoff(int type) {} 59static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {} 60static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {} 61static inline void zswap_folio_swapin(struct folio *folio) {} 62 63static inline bool is_zswap_enabled(void) 64{ 65 return false; 66} 67 68#endif 69 70#endif /* _LINUX_ZSWAP_H */ 71