struct swap_slots_cache :: ANDROID_VENDOR_DATA(1) 1) Multiple swap devices can be supported; 2) There are different kinds of data; 3) During data reclamation, different types of data are exchanged to different swap devices; 4) Each swap device has corresponding arrays of slots and slots_ret; 5) Each swap device has corresponding indexes of nr, cur and n_ret; 6) This field is a pointer, it points to a struct which contains all the other arrays and indexes; Bug: 225795494 Change-Id: Icf116135926be98449a2d96fc458e58e5ad3b7e9 Signed-off-by: Bing Han <bing.han@transsion.com> (cherry picked from commit a034320a6855af99fe1ec1dfe6cafa4c2a15ecce)
33 lines
866 B
C
33 lines
866 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_SWAP_SLOTS_H
|
|
#define _LINUX_SWAP_SLOTS_H
|
|
|
|
#include <linux/swap.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/mutex.h>
|
|
|
|
#define SWAP_SLOTS_CACHE_SIZE SWAP_BATCH
|
|
#define THRESHOLD_ACTIVATE_SWAP_SLOTS_CACHE (5*SWAP_SLOTS_CACHE_SIZE)
|
|
#define THRESHOLD_DEACTIVATE_SWAP_SLOTS_CACHE (2*SWAP_SLOTS_CACHE_SIZE)
|
|
|
|
struct swap_slots_cache {
|
|
bool lock_initialized;
|
|
struct mutex alloc_lock; /* protects slots, nr, cur */
|
|
swp_entry_t *slots;
|
|
int nr;
|
|
int cur;
|
|
spinlock_t free_lock; /* protects slots_ret, n_ret */
|
|
swp_entry_t *slots_ret;
|
|
int n_ret;
|
|
ANDROID_VENDOR_DATA(1);
|
|
};
|
|
|
|
void disable_swap_slots_cache_lock(void);
|
|
void reenable_swap_slots_cache_unlock(void);
|
|
void enable_swap_slots_cache(void);
|
|
int free_swap_slot(swp_entry_t entry);
|
|
|
|
extern bool swap_slot_cache_enabled;
|
|
|
|
#endif /* _LINUX_SWAP_SLOTS_H */
|