Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_SWAP_SLOTS_H
0003 #define _LINUX_SWAP_SLOTS_H
0004 
0005 #include <linux/swap.h>
0006 #include <linux/spinlock.h>
0007 #include <linux/mutex.h>
0008 
0009 #define SWAP_SLOTS_CACHE_SIZE           SWAP_BATCH
0010 #define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE)
0011 #define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE   (2*SWAP_SLOTS_CACHE_SIZE)
0012 
0013 struct swap_slots_cache {
0014     bool        lock_initialized;
0015     struct mutex    alloc_lock; /* protects slots, nr, cur */
0016     swp_entry_t *slots;
0017     int     nr;
0018     int     cur;
0019     spinlock_t  free_lock;  /* protects slots_ret, n_ret */
0020     swp_entry_t *slots_ret;
0021     int     n_ret;
0022 };
0023 
0024 void disable_swap_slots_cache_lock(void);
0025 void reenable_swap_slots_cache_unlock(void);
0026 void enable_swap_slots_cache(void);
0027 void free_swap_slot(swp_entry_t entry);
0028 
0029 extern bool swap_slot_cache_enabled;
0030 
0031 #endif /* _LINUX_SWAP_SLOTS_H */