1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _LINUX_SWAPOPS_H
3*4882a593Smuzhiyun #define _LINUX_SWAPOPS_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun #include <linux/radix-tree.h>
6*4882a593Smuzhiyun #include <linux/bug.h>
7*4882a593Smuzhiyun #include <linux/mm_types.h>
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #ifdef CONFIG_MMU
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun /*
12*4882a593Smuzhiyun * swapcache pages are stored in the swapper_space radix tree. We want to
13*4882a593Smuzhiyun * get good packing density in that tree, so the index should be dense in
14*4882a593Smuzhiyun * the low-order bits.
15*4882a593Smuzhiyun *
16*4882a593Smuzhiyun * We arrange the `type' and `offset' fields so that `type' is at the seven
17*4882a593Smuzhiyun * high-order bits of the swp_entry_t and `offset' is right-aligned in the
18*4882a593Smuzhiyun * remaining bits. Although `type' itself needs only five bits, we allow for
19*4882a593Smuzhiyun * shmem/tmpfs to shift it all up a further two bits: see swp_to_radix_entry().
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun * swp_entry_t's are *never* stored anywhere in their arch-dependent format.
22*4882a593Smuzhiyun */
23*4882a593Smuzhiyun #define SWP_TYPE_SHIFT (BITS_PER_XA_VALUE - MAX_SWAPFILES_SHIFT)
24*4882a593Smuzhiyun #define SWP_OFFSET_MASK ((1UL << SWP_TYPE_SHIFT) - 1)
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun /* Clear all flags but only keep swp_entry_t related information */
pte_swp_clear_flags(pte_t pte)27*4882a593Smuzhiyun static inline pte_t pte_swp_clear_flags(pte_t pte)
28*4882a593Smuzhiyun {
29*4882a593Smuzhiyun if (pte_swp_soft_dirty(pte))
30*4882a593Smuzhiyun pte = pte_swp_clear_soft_dirty(pte);
31*4882a593Smuzhiyun if (pte_swp_uffd_wp(pte))
32*4882a593Smuzhiyun pte = pte_swp_clear_uffd_wp(pte);
33*4882a593Smuzhiyun return pte;
34*4882a593Smuzhiyun }
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun /*
37*4882a593Smuzhiyun * Store a type+offset into a swp_entry_t in an arch-independent format
38*4882a593Smuzhiyun */
swp_entry(unsigned long type,pgoff_t offset)39*4882a593Smuzhiyun static inline swp_entry_t swp_entry(unsigned long type, pgoff_t offset)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun swp_entry_t ret;
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun ret.val = (type << SWP_TYPE_SHIFT) | (offset & SWP_OFFSET_MASK);
44*4882a593Smuzhiyun return ret;
45*4882a593Smuzhiyun }
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun /*
48*4882a593Smuzhiyun * Extract the `type' field from a swp_entry_t. The swp_entry_t is in
49*4882a593Smuzhiyun * arch-independent format
50*4882a593Smuzhiyun */
swp_type(swp_entry_t entry)51*4882a593Smuzhiyun static inline unsigned swp_type(swp_entry_t entry)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun return (entry.val >> SWP_TYPE_SHIFT);
54*4882a593Smuzhiyun }
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun /*
57*4882a593Smuzhiyun * Extract the `offset' field from a swp_entry_t. The swp_entry_t is in
58*4882a593Smuzhiyun * arch-independent format
59*4882a593Smuzhiyun */
swp_offset(swp_entry_t entry)60*4882a593Smuzhiyun static inline pgoff_t swp_offset(swp_entry_t entry)
61*4882a593Smuzhiyun {
62*4882a593Smuzhiyun return entry.val & SWP_OFFSET_MASK;
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun /* check whether a pte points to a swap entry */
is_swap_pte(pte_t pte)66*4882a593Smuzhiyun static inline int is_swap_pte(pte_t pte)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun return !pte_none(pte) && !pte_present(pte);
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun /*
72*4882a593Smuzhiyun * Convert the arch-dependent pte representation of a swp_entry_t into an
73*4882a593Smuzhiyun * arch-independent swp_entry_t.
74*4882a593Smuzhiyun */
pte_to_swp_entry(pte_t pte)75*4882a593Smuzhiyun static inline swp_entry_t pte_to_swp_entry(pte_t pte)
76*4882a593Smuzhiyun {
77*4882a593Smuzhiyun swp_entry_t arch_entry;
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun pte = pte_swp_clear_flags(pte);
80*4882a593Smuzhiyun arch_entry = __pte_to_swp_entry(pte);
81*4882a593Smuzhiyun return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
82*4882a593Smuzhiyun }
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun /*
85*4882a593Smuzhiyun * Convert the arch-independent representation of a swp_entry_t into the
86*4882a593Smuzhiyun * arch-dependent pte representation.
87*4882a593Smuzhiyun */
swp_entry_to_pte(swp_entry_t entry)88*4882a593Smuzhiyun static inline pte_t swp_entry_to_pte(swp_entry_t entry)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun swp_entry_t arch_entry;
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
93*4882a593Smuzhiyun return __swp_entry_to_pte(arch_entry);
94*4882a593Smuzhiyun }
95*4882a593Smuzhiyun
radix_to_swp_entry(void * arg)96*4882a593Smuzhiyun static inline swp_entry_t radix_to_swp_entry(void *arg)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun swp_entry_t entry;
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun entry.val = xa_to_value(arg);
101*4882a593Smuzhiyun return entry;
102*4882a593Smuzhiyun }
103*4882a593Smuzhiyun
swp_to_radix_entry(swp_entry_t entry)104*4882a593Smuzhiyun static inline void *swp_to_radix_entry(swp_entry_t entry)
105*4882a593Smuzhiyun {
106*4882a593Smuzhiyun return xa_mk_value(entry.val);
107*4882a593Smuzhiyun }
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
make_device_private_entry(struct page * page,bool write)110*4882a593Smuzhiyun static inline swp_entry_t make_device_private_entry(struct page *page, bool write)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun return swp_entry(write ? SWP_DEVICE_WRITE : SWP_DEVICE_READ,
113*4882a593Smuzhiyun page_to_pfn(page));
114*4882a593Smuzhiyun }
115*4882a593Smuzhiyun
is_device_private_entry(swp_entry_t entry)116*4882a593Smuzhiyun static inline bool is_device_private_entry(swp_entry_t entry)
117*4882a593Smuzhiyun {
118*4882a593Smuzhiyun int type = swp_type(entry);
119*4882a593Smuzhiyun return type == SWP_DEVICE_READ || type == SWP_DEVICE_WRITE;
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun
make_device_private_entry_read(swp_entry_t * entry)122*4882a593Smuzhiyun static inline void make_device_private_entry_read(swp_entry_t *entry)
123*4882a593Smuzhiyun {
124*4882a593Smuzhiyun *entry = swp_entry(SWP_DEVICE_READ, swp_offset(*entry));
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun
is_write_device_private_entry(swp_entry_t entry)127*4882a593Smuzhiyun static inline bool is_write_device_private_entry(swp_entry_t entry)
128*4882a593Smuzhiyun {
129*4882a593Smuzhiyun return unlikely(swp_type(entry) == SWP_DEVICE_WRITE);
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun
device_private_entry_to_pfn(swp_entry_t entry)132*4882a593Smuzhiyun static inline unsigned long device_private_entry_to_pfn(swp_entry_t entry)
133*4882a593Smuzhiyun {
134*4882a593Smuzhiyun return swp_offset(entry);
135*4882a593Smuzhiyun }
136*4882a593Smuzhiyun
device_private_entry_to_page(swp_entry_t entry)137*4882a593Smuzhiyun static inline struct page *device_private_entry_to_page(swp_entry_t entry)
138*4882a593Smuzhiyun {
139*4882a593Smuzhiyun return pfn_to_page(swp_offset(entry));
140*4882a593Smuzhiyun }
141*4882a593Smuzhiyun #else /* CONFIG_DEVICE_PRIVATE */
make_device_private_entry(struct page * page,bool write)142*4882a593Smuzhiyun static inline swp_entry_t make_device_private_entry(struct page *page, bool write)
143*4882a593Smuzhiyun {
144*4882a593Smuzhiyun return swp_entry(0, 0);
145*4882a593Smuzhiyun }
146*4882a593Smuzhiyun
make_device_private_entry_read(swp_entry_t * entry)147*4882a593Smuzhiyun static inline void make_device_private_entry_read(swp_entry_t *entry)
148*4882a593Smuzhiyun {
149*4882a593Smuzhiyun }
150*4882a593Smuzhiyun
is_device_private_entry(swp_entry_t entry)151*4882a593Smuzhiyun static inline bool is_device_private_entry(swp_entry_t entry)
152*4882a593Smuzhiyun {
153*4882a593Smuzhiyun return false;
154*4882a593Smuzhiyun }
155*4882a593Smuzhiyun
is_write_device_private_entry(swp_entry_t entry)156*4882a593Smuzhiyun static inline bool is_write_device_private_entry(swp_entry_t entry)
157*4882a593Smuzhiyun {
158*4882a593Smuzhiyun return false;
159*4882a593Smuzhiyun }
160*4882a593Smuzhiyun
device_private_entry_to_pfn(swp_entry_t entry)161*4882a593Smuzhiyun static inline unsigned long device_private_entry_to_pfn(swp_entry_t entry)
162*4882a593Smuzhiyun {
163*4882a593Smuzhiyun return 0;
164*4882a593Smuzhiyun }
165*4882a593Smuzhiyun
device_private_entry_to_page(swp_entry_t entry)166*4882a593Smuzhiyun static inline struct page *device_private_entry_to_page(swp_entry_t entry)
167*4882a593Smuzhiyun {
168*4882a593Smuzhiyun return NULL;
169*4882a593Smuzhiyun }
170*4882a593Smuzhiyun #endif /* CONFIG_DEVICE_PRIVATE */
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun #ifdef CONFIG_MIGRATION
make_migration_entry(struct page * page,int write)173*4882a593Smuzhiyun static inline swp_entry_t make_migration_entry(struct page *page, int write)
174*4882a593Smuzhiyun {
175*4882a593Smuzhiyun BUG_ON(!PageLocked(compound_head(page)));
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun return swp_entry(write ? SWP_MIGRATION_WRITE : SWP_MIGRATION_READ,
178*4882a593Smuzhiyun page_to_pfn(page));
179*4882a593Smuzhiyun }
180*4882a593Smuzhiyun
is_migration_entry(swp_entry_t entry)181*4882a593Smuzhiyun static inline int is_migration_entry(swp_entry_t entry)
182*4882a593Smuzhiyun {
183*4882a593Smuzhiyun return unlikely(swp_type(entry) == SWP_MIGRATION_READ ||
184*4882a593Smuzhiyun swp_type(entry) == SWP_MIGRATION_WRITE);
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun
is_write_migration_entry(swp_entry_t entry)187*4882a593Smuzhiyun static inline int is_write_migration_entry(swp_entry_t entry)
188*4882a593Smuzhiyun {
189*4882a593Smuzhiyun return unlikely(swp_type(entry) == SWP_MIGRATION_WRITE);
190*4882a593Smuzhiyun }
191*4882a593Smuzhiyun
migration_entry_to_pfn(swp_entry_t entry)192*4882a593Smuzhiyun static inline unsigned long migration_entry_to_pfn(swp_entry_t entry)
193*4882a593Smuzhiyun {
194*4882a593Smuzhiyun return swp_offset(entry);
195*4882a593Smuzhiyun }
196*4882a593Smuzhiyun
migration_entry_to_page(swp_entry_t entry)197*4882a593Smuzhiyun static inline struct page *migration_entry_to_page(swp_entry_t entry)
198*4882a593Smuzhiyun {
199*4882a593Smuzhiyun struct page *p = pfn_to_page(swp_offset(entry));
200*4882a593Smuzhiyun /*
201*4882a593Smuzhiyun * Any use of migration entries may only occur while the
202*4882a593Smuzhiyun * corresponding page is locked
203*4882a593Smuzhiyun */
204*4882a593Smuzhiyun BUG_ON(!PageLocked(compound_head(p)));
205*4882a593Smuzhiyun return p;
206*4882a593Smuzhiyun }
207*4882a593Smuzhiyun
make_migration_entry_read(swp_entry_t * entry)208*4882a593Smuzhiyun static inline void make_migration_entry_read(swp_entry_t *entry)
209*4882a593Smuzhiyun {
210*4882a593Smuzhiyun *entry = swp_entry(SWP_MIGRATION_READ, swp_offset(*entry));
211*4882a593Smuzhiyun }
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun extern void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep,
214*4882a593Smuzhiyun spinlock_t *ptl);
215*4882a593Smuzhiyun extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
216*4882a593Smuzhiyun unsigned long address);
217*4882a593Smuzhiyun extern void migration_entry_wait_huge(struct vm_area_struct *vma,
218*4882a593Smuzhiyun struct mm_struct *mm, pte_t *pte);
219*4882a593Smuzhiyun #else
220*4882a593Smuzhiyun
221*4882a593Smuzhiyun #define make_migration_entry(page, write) swp_entry(0, 0)
is_migration_entry(swp_entry_t swp)222*4882a593Smuzhiyun static inline int is_migration_entry(swp_entry_t swp)
223*4882a593Smuzhiyun {
224*4882a593Smuzhiyun return 0;
225*4882a593Smuzhiyun }
226*4882a593Smuzhiyun
migration_entry_to_pfn(swp_entry_t entry)227*4882a593Smuzhiyun static inline unsigned long migration_entry_to_pfn(swp_entry_t entry)
228*4882a593Smuzhiyun {
229*4882a593Smuzhiyun return 0;
230*4882a593Smuzhiyun }
231*4882a593Smuzhiyun
migration_entry_to_page(swp_entry_t entry)232*4882a593Smuzhiyun static inline struct page *migration_entry_to_page(swp_entry_t entry)
233*4882a593Smuzhiyun {
234*4882a593Smuzhiyun return NULL;
235*4882a593Smuzhiyun }
236*4882a593Smuzhiyun
make_migration_entry_read(swp_entry_t * entryp)237*4882a593Smuzhiyun static inline void make_migration_entry_read(swp_entry_t *entryp) { }
__migration_entry_wait(struct mm_struct * mm,pte_t * ptep,spinlock_t * ptl)238*4882a593Smuzhiyun static inline void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep,
239*4882a593Smuzhiyun spinlock_t *ptl) { }
migration_entry_wait(struct mm_struct * mm,pmd_t * pmd,unsigned long address)240*4882a593Smuzhiyun static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
241*4882a593Smuzhiyun unsigned long address) { }
migration_entry_wait_huge(struct vm_area_struct * vma,struct mm_struct * mm,pte_t * pte)242*4882a593Smuzhiyun static inline void migration_entry_wait_huge(struct vm_area_struct *vma,
243*4882a593Smuzhiyun struct mm_struct *mm, pte_t *pte) { }
is_write_migration_entry(swp_entry_t entry)244*4882a593Smuzhiyun static inline int is_write_migration_entry(swp_entry_t entry)
245*4882a593Smuzhiyun {
246*4882a593Smuzhiyun return 0;
247*4882a593Smuzhiyun }
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun #endif
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun struct page_vma_mapped_walk;
252*4882a593Smuzhiyun
253*4882a593Smuzhiyun #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
254*4882a593Smuzhiyun extern void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
255*4882a593Smuzhiyun struct page *page);
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun extern void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
258*4882a593Smuzhiyun struct page *new);
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun extern void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd);
261*4882a593Smuzhiyun
pmd_to_swp_entry(pmd_t pmd)262*4882a593Smuzhiyun static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd)
263*4882a593Smuzhiyun {
264*4882a593Smuzhiyun swp_entry_t arch_entry;
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun if (pmd_swp_soft_dirty(pmd))
267*4882a593Smuzhiyun pmd = pmd_swp_clear_soft_dirty(pmd);
268*4882a593Smuzhiyun if (pmd_swp_uffd_wp(pmd))
269*4882a593Smuzhiyun pmd = pmd_swp_clear_uffd_wp(pmd);
270*4882a593Smuzhiyun arch_entry = __pmd_to_swp_entry(pmd);
271*4882a593Smuzhiyun return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
272*4882a593Smuzhiyun }
273*4882a593Smuzhiyun
swp_entry_to_pmd(swp_entry_t entry)274*4882a593Smuzhiyun static inline pmd_t swp_entry_to_pmd(swp_entry_t entry)
275*4882a593Smuzhiyun {
276*4882a593Smuzhiyun swp_entry_t arch_entry;
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun arch_entry = __swp_entry(swp_type(entry), swp_offset(entry));
279*4882a593Smuzhiyun return __swp_entry_to_pmd(arch_entry);
280*4882a593Smuzhiyun }
281*4882a593Smuzhiyun
is_pmd_migration_entry(pmd_t pmd)282*4882a593Smuzhiyun static inline int is_pmd_migration_entry(pmd_t pmd)
283*4882a593Smuzhiyun {
284*4882a593Smuzhiyun return !pmd_present(pmd) && is_migration_entry(pmd_to_swp_entry(pmd));
285*4882a593Smuzhiyun }
286*4882a593Smuzhiyun #else
set_pmd_migration_entry(struct page_vma_mapped_walk * pvmw,struct page * page)287*4882a593Smuzhiyun static inline void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw,
288*4882a593Smuzhiyun struct page *page)
289*4882a593Smuzhiyun {
290*4882a593Smuzhiyun BUILD_BUG();
291*4882a593Smuzhiyun }
292*4882a593Smuzhiyun
remove_migration_pmd(struct page_vma_mapped_walk * pvmw,struct page * new)293*4882a593Smuzhiyun static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw,
294*4882a593Smuzhiyun struct page *new)
295*4882a593Smuzhiyun {
296*4882a593Smuzhiyun BUILD_BUG();
297*4882a593Smuzhiyun }
298*4882a593Smuzhiyun
pmd_migration_entry_wait(struct mm_struct * m,pmd_t * p)299*4882a593Smuzhiyun static inline void pmd_migration_entry_wait(struct mm_struct *m, pmd_t *p) { }
300*4882a593Smuzhiyun
pmd_to_swp_entry(pmd_t pmd)301*4882a593Smuzhiyun static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd)
302*4882a593Smuzhiyun {
303*4882a593Smuzhiyun return swp_entry(0, 0);
304*4882a593Smuzhiyun }
305*4882a593Smuzhiyun
swp_entry_to_pmd(swp_entry_t entry)306*4882a593Smuzhiyun static inline pmd_t swp_entry_to_pmd(swp_entry_t entry)
307*4882a593Smuzhiyun {
308*4882a593Smuzhiyun return __pmd(0);
309*4882a593Smuzhiyun }
310*4882a593Smuzhiyun
is_pmd_migration_entry(pmd_t pmd)311*4882a593Smuzhiyun static inline int is_pmd_migration_entry(pmd_t pmd)
312*4882a593Smuzhiyun {
313*4882a593Smuzhiyun return 0;
314*4882a593Smuzhiyun }
315*4882a593Smuzhiyun #endif
316*4882a593Smuzhiyun
317*4882a593Smuzhiyun #ifdef CONFIG_MEMORY_FAILURE
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun extern atomic_long_t num_poisoned_pages __read_mostly;
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun /*
322*4882a593Smuzhiyun * Support for hardware poisoned pages
323*4882a593Smuzhiyun */
make_hwpoison_entry(struct page * page)324*4882a593Smuzhiyun static inline swp_entry_t make_hwpoison_entry(struct page *page)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun BUG_ON(!PageLocked(page));
327*4882a593Smuzhiyun return swp_entry(SWP_HWPOISON, page_to_pfn(page));
328*4882a593Smuzhiyun }
329*4882a593Smuzhiyun
is_hwpoison_entry(swp_entry_t entry)330*4882a593Smuzhiyun static inline int is_hwpoison_entry(swp_entry_t entry)
331*4882a593Smuzhiyun {
332*4882a593Smuzhiyun return swp_type(entry) == SWP_HWPOISON;
333*4882a593Smuzhiyun }
334*4882a593Smuzhiyun
num_poisoned_pages_inc(void)335*4882a593Smuzhiyun static inline void num_poisoned_pages_inc(void)
336*4882a593Smuzhiyun {
337*4882a593Smuzhiyun atomic_long_inc(&num_poisoned_pages);
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun
num_poisoned_pages_dec(void)340*4882a593Smuzhiyun static inline void num_poisoned_pages_dec(void)
341*4882a593Smuzhiyun {
342*4882a593Smuzhiyun atomic_long_dec(&num_poisoned_pages);
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun #else
346*4882a593Smuzhiyun
make_hwpoison_entry(struct page * page)347*4882a593Smuzhiyun static inline swp_entry_t make_hwpoison_entry(struct page *page)
348*4882a593Smuzhiyun {
349*4882a593Smuzhiyun return swp_entry(0, 0);
350*4882a593Smuzhiyun }
351*4882a593Smuzhiyun
is_hwpoison_entry(swp_entry_t swp)352*4882a593Smuzhiyun static inline int is_hwpoison_entry(swp_entry_t swp)
353*4882a593Smuzhiyun {
354*4882a593Smuzhiyun return 0;
355*4882a593Smuzhiyun }
356*4882a593Smuzhiyun
num_poisoned_pages_inc(void)357*4882a593Smuzhiyun static inline void num_poisoned_pages_inc(void)
358*4882a593Smuzhiyun {
359*4882a593Smuzhiyun }
360*4882a593Smuzhiyun #endif
361*4882a593Smuzhiyun
362*4882a593Smuzhiyun #if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) || \
363*4882a593Smuzhiyun defined(CONFIG_DEVICE_PRIVATE)
non_swap_entry(swp_entry_t entry)364*4882a593Smuzhiyun static inline int non_swap_entry(swp_entry_t entry)
365*4882a593Smuzhiyun {
366*4882a593Smuzhiyun return swp_type(entry) >= MAX_SWAPFILES;
367*4882a593Smuzhiyun }
368*4882a593Smuzhiyun #else
non_swap_entry(swp_entry_t entry)369*4882a593Smuzhiyun static inline int non_swap_entry(swp_entry_t entry)
370*4882a593Smuzhiyun {
371*4882a593Smuzhiyun return 0;
372*4882a593Smuzhiyun }
373*4882a593Smuzhiyun #endif
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun #endif /* CONFIG_MMU */
376*4882a593Smuzhiyun #endif /* _LINUX_SWAPOPS_H */
377