at v4.13 30 lines 801 B view raw
1#ifndef _LINUX_SWAP_SLOTS_H 2#define _LINUX_SWAP_SLOTS_H 3 4#include <linux/swap.h> 5#include <linux/spinlock.h> 6#include <linux/mutex.h> 7 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) 11 12struct swap_slots_cache { 13 bool lock_initialized; 14 struct mutex alloc_lock; /* protects slots, nr, cur */ 15 swp_entry_t *slots; 16 int nr; 17 int cur; 18 spinlock_t free_lock; /* protects slots_ret, n_ret */ 19 swp_entry_t *slots_ret; 20 int n_ret; 21}; 22 23void disable_swap_slots_cache_lock(void); 24void reenable_swap_slots_cache_unlock(void); 25int enable_swap_slots_cache(void); 26int free_swap_slot(swp_entry_t entry); 27 28extern bool swap_slot_cache_enabled; 29 30#endif /* _LINUX_SWAP_SLOTS_H */