]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/staging/zcache/zcache-main.c
staging: zcache: fix typos
[karo-tx-linux.git] / drivers / staging / zcache / zcache-main.c
index a58a03f66d73ad72f3a995f1cae010ca676d9c42..6c0f001c3586d3930d8b2d6f4b726cc47eaf0d21 100644 (file)
@@ -19,6 +19,7 @@
  *   http://marc.info/?l=linux-mm&m=127811271605009
  */
 
+#include <linux/module.h>
 #include <linux/cpu.h>
 #include <linux/highmem.h>
 #include <linux/list.h>
@@ -27,6 +28,7 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/atomic.h>
+#include <linux/math64.h>
 #include "tmem.h"
 
 #include "../zram/xvmalloc.h" /* if built in drivers/staging */
@@ -649,7 +651,7 @@ static unsigned int zv_max_zsize = (PAGE_SIZE / 8) * 7;
 /*
  * byte count defining poor *mean* compression; pages with greater zsize
  * will be rejected until sufficient better-compressed pages are accepted
- * driving the man below this threshold
+ * driving the mean below this threshold
  */
 static unsigned int zv_max_mean_zsize = (PAGE_SIZE / 8) * 5;
 
@@ -1161,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);
        unsigned long zv_mean_zsize;
        unsigned long curr_pers_pampd_count;
+       u64 total_zsize;
 
        if (eph) {
                ret = zcache_compress(page, &cdata, &clen);
@@ -1193,8 +1196,9 @@ static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph,
                }
                /* reject if mean compression is too poor */
                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) {
                                zcache_mean_compress_poor++;
                                goto out;
@@ -1664,7 +1668,7 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags)
        if (cli == NULL)
                goto out;
        atomic_inc(&cli->refcount);
-       pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL);
+       pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC);
        if (pool == NULL) {
                pr_info("zcache: pool creation failed: out of memory\n");
                goto out;
@@ -1932,9 +1936,9 @@ __setup("nofrontswap", no_frontswap);
 
 static int __init zcache_init(void)
 {
-#ifdef CONFIG_SYSFS
        int ret = 0;
 
+#ifdef CONFIG_SYSFS
        ret = sysfs_create_group(mm_kobj, &zcache_attr_group);
        if (ret) {
                pr_err("zcache: can't create sysfs\n");
@@ -1989,7 +1993,7 @@ static int __init zcache_init(void)
                pr_info("zcache: frontswap enabled using kernel "
                        "transcendent memory and xvmalloc\n");
                if (old_ops.init != NULL)
-                       pr_warning("ktmem: frontswap_ops overridden");
+                       pr_warning("zcache: frontswap_ops overridden");
        }
 #endif
 out: