Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.11 76 lines 1.9 kB view raw
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 atomic_t zswap_stored_pages; 11 12#ifdef CONFIG_ZSWAP 13 14struct 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 29unsigned long zswap_total_pages(void); 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 zswap_is_enabled(void); 39bool zswap_never_enabled(void); 40#else 41 42struct zswap_lruvec_state {}; 43 44static inline bool zswap_store(struct folio *folio) 45{ 46 return false; 47} 48 49static inline bool zswap_load(struct folio *folio) 50{ 51 return false; 52} 53 54static inline void zswap_invalidate(swp_entry_t swp) {} 55static inline int zswap_swapon(int type, unsigned long nr_pages) 56{ 57 return 0; 58} 59static inline void zswap_swapoff(int type) {} 60static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {} 61static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {} 62static inline void zswap_folio_swapin(struct folio *folio) {} 63 64static inline bool zswap_is_enabled(void) 65{ 66 return false; 67} 68 69static inline bool zswap_never_enabled(void) 70{ 71 return true; 72} 73 74#endif 75 76#endif /* _LINUX_ZSWAP_H */