|
@@ -28,6 +28,7 @@
|
|
#include <linux/spinlock.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/types.h>
|
|
#include <linux/types.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/atomic.h>
|
|
|
|
+#include <linux/math64.h>
|
|
#include "tmem.h"
|
|
#include "tmem.h"
|
|
|
|
|
|
#include "../zram/xvmalloc.h" /* if built in drivers/staging */
|
|
#include "../zram/xvmalloc.h" /* if built in drivers/staging */
|
|
@@ -1162,6 +1163,7 @@ static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph,
|
|
uint16_t client_id = get_client_id_from_client(cli);
|
|
uint16_t client_id = get_client_id_from_client(cli);
|
|
unsigned long zv_mean_zsize;
|
|
unsigned long zv_mean_zsize;
|
|
unsigned long curr_pers_pampd_count;
|
|
unsigned long curr_pers_pampd_count;
|
|
|
|
+ u64 total_zsize;
|
|
|
|
|
|
if (eph) {
|
|
if (eph) {
|
|
ret = zcache_compress(page, &cdata, &clen);
|
|
ret = zcache_compress(page, &cdata, &clen);
|
|
@@ -1194,8 +1196,9 @@ static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph,
|
|
}
|
|
}
|
|
/* reject if mean compression is too poor */
|
|
/* reject if mean compression is too poor */
|
|
if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) {
|
|
if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) {
|
|
- zv_mean_zsize = xv_get_total_size_bytes(cli->xvpool) /
|
|
|
|
- curr_pers_pampd_count;
|
|
|
|
|
|
+ total_zsize = xv_get_total_size_bytes(cli->xvpool);
|
|
|
|
+ zv_mean_zsize = div_u64(total_zsize,
|
|
|
|
+ curr_pers_pampd_count);
|
|
if (zv_mean_zsize > zv_max_mean_zsize) {
|
|
if (zv_mean_zsize > zv_max_mean_zsize) {
|
|
zcache_mean_compress_poor++;
|
|
zcache_mean_compress_poor++;
|
|
goto out;
|
|
goto out;
|