blk-iocost: Trace vtime_base_rate instead of vtime_rate
[linux-block.git] / mm / swap.h
CommitLineData
014bb1de
N
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _MM_SWAP_H
3#define _MM_SWAP_H
4
5#ifdef CONFIG_SWAP
6#include <linux/blk_types.h> /* for bio_end_io_t */
7
8/* linux/mm/page_io.c */
e1209d3a 9int sio_pool_init(void);
5169b844
N
10struct swap_iocb;
11int swap_readpage(struct page *page, bool do_poll,
12 struct swap_iocb **plug);
13void __swap_read_unplug(struct swap_iocb *plug);
14static inline void swap_read_unplug(struct swap_iocb *plug)
15{
16 if (unlikely(plug))
17 __swap_read_unplug(plug);
18}
2282679f 19void swap_write_unplug(struct swap_iocb *sio);
014bb1de 20int swap_writepage(struct page *page, struct writeback_control *wbc);
cf1e3fe4 21int __swap_writepage(struct page *page, struct writeback_control *wbc);
014bb1de
N
22
23/* linux/mm/swap_state.c */
24/* One swap address space for each 64M swap space */
25#define SWAP_ADDRESS_SPACE_SHIFT 14
26#define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT)
27extern struct address_space *swapper_spaces[];
28#define swap_address_space(entry) \
29 (&swapper_spaces[swp_type(entry)][swp_offset(entry) \
30 >> SWAP_ADDRESS_SPACE_SHIFT])
31
32void show_swap_cache_info(void);
09c02e56 33bool add_to_swap(struct folio *folio);
014bb1de 34void *get_shadow_from_swap_cache(swp_entry_t entry);
a4c366f0 35int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
014bb1de 36 gfp_t gfp, void **shadowp);
ceff9d33 37void __delete_from_swap_cache(struct folio *folio,
014bb1de 38 swp_entry_t entry, void *shadow);
75fa68a5 39void delete_from_swap_cache(struct folio *folio);
014bb1de
N
40void clear_shadow_from_swap_cache(int type, unsigned long begin,
41 unsigned long end);
c9edc242
MWO
42struct folio *swap_cache_get_folio(swp_entry_t entry,
43 struct vm_area_struct *vma, unsigned long addr);
014bb1de
N
44struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
45
46struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
47 struct vm_area_struct *vma,
48 unsigned long addr,
5169b844
N
49 bool do_poll,
50 struct swap_iocb **plug);
014bb1de
N
51struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
52 struct vm_area_struct *vma,
53 unsigned long addr,
54 bool *new_page_allocated);
55struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
56 struct vm_fault *vmf);
57struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
58 struct vm_fault *vmf);
59
b98c359f 60static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67 61{
b98c359f 62 return page_swap_info(&folio->page)->flags;
d791ea67 63}
014bb1de 64#else /* CONFIG_SWAP */
5169b844
N
65struct swap_iocb;
66static inline int swap_readpage(struct page *page, bool do_poll,
67 struct swap_iocb **plug)
014bb1de
N
68{
69 return 0;
70}
2282679f
N
71static inline void swap_write_unplug(struct swap_iocb *sio)
72{
73}
014bb1de
N
74
75static inline struct address_space *swap_address_space(swp_entry_t entry)
76{
77 return NULL;
78}
79
014bb1de
N
80static inline void show_swap_cache_info(void)
81{
82}
83
84static inline struct page *swap_cluster_readahead(swp_entry_t entry,
85 gfp_t gfp_mask, struct vm_fault *vmf)
86{
87 return NULL;
88}
89
90static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
91 struct vm_fault *vmf)
92{
93 return NULL;
94}
95
96static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
97{
98 return 0;
99}
100
c9edc242
MWO
101static inline struct folio *swap_cache_get_folio(swp_entry_t entry,
102 struct vm_area_struct *vma, unsigned long addr)
103{
104 return NULL;
105}
106
014bb1de
N
107static inline
108struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
109{
110 return find_get_page(mapping, index);
111}
112
09c02e56 113static inline bool add_to_swap(struct folio *folio)
014bb1de 114{
09c02e56 115 return false;
014bb1de
N
116}
117
118static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
119{
120 return NULL;
121}
122
a4c366f0 123static inline int add_to_swap_cache(struct folio *folio, swp_entry_t entry,
014bb1de
N
124 gfp_t gfp_mask, void **shadowp)
125{
126 return -1;
127}
128
ceff9d33 129static inline void __delete_from_swap_cache(struct folio *folio,
014bb1de
N
130 swp_entry_t entry, void *shadow)
131{
132}
133
75fa68a5 134static inline void delete_from_swap_cache(struct folio *folio)
014bb1de
N
135{
136}
137
138static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
139 unsigned long end)
140{
141}
142
b98c359f 143static inline unsigned int folio_swap_flags(struct folio *folio)
d791ea67
N
144{
145 return 0;
146}
014bb1de
N
147#endif /* CONFIG_SWAP */
148#endif /* _MM_SWAP_H */