swap_slots.h 867 B

1234567891011121314151617181920212223242526272829303132
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SWAP_SLOTS_H
  3. #define _LINUX_SWAP_SLOTS_H
  4. #include <linux/swap.h>
  5. #include <linux/spinlock.h>
  6. #include <linux/mutex.h>
  7. #define SWAP_SLOTS_CACHE_SIZE SWAP_BATCH
  8. #define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE)
  9. #define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (2*SWAP_SLOTS_CACHE_SIZE)
  10. struct swap_slots_cache {
  11. bool lock_initialized;
  12. struct mutex alloc_lock; /* protects slots, nr, cur */
  13. swp_entry_t *slots;
  14. int nr;
  15. int cur;
  16. spinlock_t free_lock; /* protects slots_ret, n_ret */
  17. swp_entry_t *slots_ret;
  18. int n_ret;
  19. ANDROID_VENDOR_DATA(1);
  20. };
  21. void disable_swap_slots_cache_lock(void);
  22. void reenable_swap_slots_cache_unlock(void);
  23. void enable_swap_slots_cache(void);
  24. void free_swap_slot(swp_entry_t entry);
  25. extern bool swap_slot_cache_enabled;
  26. #endif /* _LINUX_SWAP_SLOTS_H */