Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/spidev-test', 'spi...
[sfrench/cifs-2.6.git] / include / linux / swap_slots.h
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
12 struct 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
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);
27
28 extern bool swap_slot_cache_enabled;
29
30 #endif /* _LINUX_SWAP_SLOTS_H */