1 #ifndef _LINUX_SWAP_SLOTS_H
2 #define _LINUX_SWAP_SLOTS_H
4 #include <linux/swap.h>
5 #include <linux/spinlock.h>
6 #include <linux/mutex.h>
8 #define SWAP_SLOTS_CACHE_SIZE SWAP_BATCH
9 #define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE)
10 #define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (2*SWAP_SLOTS_CACHE_SIZE)
12 struct swap_slots_cache {
13 bool lock_initialized;
14 struct mutex alloc_lock; /* protects slots, nr, cur */
18 spinlock_t free_lock; /* protects slots_ret, n_ret */
19 swp_entry_t *slots_ret;
23 void disable_swap_slots_cache_lock(void);
24 void reenable_swap_slots_cache_unlock(void);
25 int enable_swap_slots_cache(void);
26 int free_swap_slot(swp_entry_t entry);
28 extern bool swap_slot_cache_enabled;
30 #endif /* _LINUX_SWAP_SLOTS_H */