]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/swap_slots.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SWAP_SLOTS_H
3 #define _LINUX_SWAP_SLOTS_H
5 #include <linux/swap.h>
6 #include <linux/spinlock.h>
7 #include <linux/mutex.h>
9 #define SWAP_SLOTS_CACHE_SIZE SWAP_BATCH
10 #define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE)
11 #define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (2*SWAP_SLOTS_CACHE_SIZE)
13 struct swap_slots_cache
{
14 bool lock_initialized
;
15 struct mutex alloc_lock
; /* protects slots, nr, cur */
19 spinlock_t free_lock
; /* protects slots_ret, n_ret */
20 swp_entry_t
*slots_ret
;
24 void disable_swap_slots_cache_lock(void);
25 void reenable_swap_slots_cache_unlock(void);
26 int enable_swap_slots_cache(void);
27 int free_swap_slot(swp_entry_t entry
);
29 extern bool swap_slot_cache_enabled
;
31 #endif /* _LINUX_SWAP_SLOTS_H */