int max_comp_streams;
char comp_algorithm[MAX_TYPE_LENGTH];
float ratio;
- unsigned long zram_reclaim_bytes;
+ unsigned long long zram_reclaim_bytes;
};
static struct swap_zram_control zram_control = {
static int swap_zram_compact(void)
{
- unsigned int total;
- static unsigned int last_total;
+ unsigned long long total_bytes;
+ static unsigned long long last_total_bytes;
int r;
_D("call zram compact");
- r = fread_uint(SWAP_ZRAM_MEM_USED_TOTAL, &total);
+ r = fread_ulonglong(SWAP_ZRAM_MEM_USED_TOTAL, &total_bytes);
if (r < 0) {
_E("fail to read %s", SWAP_ZRAM_MEM_USED_TOTAL);
return r;
* Until zram size not increased of at least 1 MB from last compaction
* then it not makes any sense to compact it again.
*/
- if ((total - last_total) < MBYTE_TO_BYTE(1))
+ if ((total_bytes - last_total_bytes) < MBYTE_TO_BYTE(1))
return -ENOMEM;
- last_total = total;
+ last_total_bytes = total_bytes;
r = fwrite_int(SWAP_ZRAM_COMPACT, 1);
if (r < 0) {
_E("fail to write %s", SWAP_ZRAM_COMPACT);
return r;
}
- r = fread_uint(SWAP_ZRAM_MEM_USED_TOTAL, &total);
+ r = fread_ulonglong(SWAP_ZRAM_MEM_USED_TOTAL, &total_bytes);
if (r < 0) {
_E("fail to read %s", SWAP_ZRAM_MEM_USED_TOTAL);
return r;
static int swap_zram_activate(void *data)
{
struct swap_module_ops *swap = (struct swap_module_ops *)data;
- unsigned int swap_size_bytes, read_size_bytes;
+ unsigned long long swap_size_bytes, read_size_bytes;
int r;
swap_size_bytes = KBYTE_TO_BYTE(swap->k_size);
}
}
- r = fread_uint(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
+ r = fread_ulonglong(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
if (r < 0) {
_E("fail to read zram disk_size");
return r;
/* disksize can be pre-fixed by other means, do not set size in that case */
if (read_size_bytes == 0) {
- r = fwrite_uint(SWAP_ZRAM_DISK_SIZE, swap_size_bytes);
+ r = fwrite_ulonglong(SWAP_ZRAM_DISK_SIZE, swap_size_bytes);
if (r < 0) {
_E("fail to write disk_size");
return r;
}
- r = fread_uint(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
+ r = fread_ulonglong(SWAP_ZRAM_DISK_SIZE, &read_size_bytes);
if (r < 0) {
_E("fail to read zram disk_size");
return r;
/* Check if zram was sucessfully initialized (zcomp rollback case) */
if (read_size_bytes < swap_size_bytes) {
- _E("swap size (%d) less than expected swap size (%d)",
+ _E("swap size (%llu) less than expected swap size (%llu)",
read_size_bytes, swap_size_bytes);
return RESOURCED_ERROR_OUT_OF_MEMORY;
}
static int swap_zram_reclaim(void *data)
{
int r, type;
- static unsigned int swap_total = 0;
+ static unsigned long long swap_total_bytes = 0;
static bool zram_compact;
- unsigned long swap_available;
- unsigned int swap_usage;
+ unsigned long long swap_available_bytes;
+ unsigned long long swap_usage_bytes;
float swapcg_usage_ratio;
unsigned int ram_available;
- swap_available = KBYTE_TO_BYTE(proc_get_swap_free());
-
- _D("swap available %lu, reclaimg byte %lu", swap_available, zram_control.zram_reclaim_bytes);
+ swap_available_bytes = KBYTE_TO_BYTE(proc_get_swap_free());
/*
* Most kernel doesn't support migration and compaction of zmalloc.
return -ENOSPC;
}
- if (swap_available >= zram_control.zram_reclaim_bytes)
+ if (swap_available_bytes >= zram_control.zram_reclaim_bytes)
return 0;
if (!zram_compact) {
* If swap usage of this cgroup is higher, run LMK about background applications.
* Otherwise, need to check all processes in order to find mallicious process.
*/
- if (!swap_total)
- swap_total = proc_get_swap_total();
+ if (!swap_total_bytes)
+ swap_total_bytes = KBYTE_TO_BYTE(proc_get_swap_total());
- r = memcg_get_swap_usage(MEMCG_LOW_GROUP_PATH, &swap_usage);
+ r = memcg_get_swap_usage(MEMCG_LOW_GROUP_PATH, &swap_usage_bytes);
if (r)
return r;
- swapcg_usage_ratio = (float)(swap_usage / (swap_total - swap_available) *100);
+ swapcg_usage_ratio = (float)(swap_usage_bytes / (swap_total_bytes - swap_available_bytes) *100);
if (swapcg_usage_ratio > SWAPCG_CHECK_RATIO)
type = CGROUP_LOW;
else