Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1423095 > unrolled thread

[PATCH] zram: update zram to use zpool

Started byGeliang Tang <geliangtang@gmail.com>
First post2016-06-15 16:50 +0200
Last post2016-06-20 10:10 +0200
Articles 6 — 5 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] zram: update zram to use zpool Geliang Tang <geliangtang@gmail.com> - 2016-06-15 16:50 +0200
    Re: [PATCH] zram: update zram to use zpool Dan Streetman <dan.streetman@canonical.com> - 2016-06-15 17:00 +0200
    Re: [PATCH] zram: update zram to use zpool Minchan Kim <minchan@kernel.org> - 2016-06-16 01:20 +0200
      Re: [PATCH] zram: update zram to use zpool Vitaly Wool <vitalywool@gmail.com> - 2016-06-17 10:40 +0200
        Re: [PATCH] zram: update zram to use zpool "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-06-17 14:30 +0200
        Re: [PATCH] zram: update zram to use zpool Minchan Kim <minchan@kernel.org> - 2016-06-20 10:10 +0200

#1423095 — [PATCH] zram: update zram to use zpool

FromGeliang Tang <geliangtang@gmail.com>
Date2016-06-15 16:50 +0200
Subject[PATCH] zram: update zram to use zpool
Message-ID<rKkiJ-3Lp-1@gated-at.bofh.it>
Change zram to use the zpool api instead of directly using zsmalloc.
The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
I did the following two things to fix it.
1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
   call zs_compact() in zsmalloc.
2) The 'pages_compacted' attribute is showed in zram by calling
   zs_pool_stats(). So in order not to call zs_pool_state() I move the
   attribute to zsmalloc.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/block/zram/Kconfig    |  3 ++-
 drivers/block/zram/zram_drv.c | 59 ++++++++++++++++++++++---------------------
 drivers/block/zram/zram_drv.h |  4 +--
 mm/zsmalloc.c                 | 12 +++++----
 4 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index b8ecba6..6389a5a 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -1,6 +1,7 @@
 config ZRAM
 	tristate "Compressed RAM block device support"
-	depends on BLOCK && SYSFS && ZSMALLOC && CRYPTO
+	depends on BLOCK && SYSFS && ZPOOL && CRYPTO
+	select ZSMALLOC
 	select CRYPTO_LZO
 	default n
 	help
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 7454cf1..7ee9050 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -39,6 +39,7 @@ static DEFINE_MUTEX(zram_index_mutex);
 
 static int zram_major;
 static const char *default_compressor = "lzo";
+static char *default_zpool_type = "zsmalloc";
 
 /* Module params (documentation at end) */
 static unsigned int num_devices = 1;
@@ -228,11 +229,11 @@ static ssize_t mem_used_total_show(struct device *dev,
 	down_read(&zram->init_lock);
 	if (init_done(zram)) {
 		struct zram_meta *meta = zram->meta;
-		val = zs_get_total_pages(meta->mem_pool);
+		val = zpool_get_total_size(meta->mem_pool);
 	}
 	up_read(&zram->init_lock);
 
-	return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT);
+	return scnprintf(buf, PAGE_SIZE, "%llu\n", val);
 }
 
 static ssize_t mem_limit_show(struct device *dev,
@@ -297,7 +298,7 @@ static ssize_t mem_used_max_store(struct device *dev,
 	if (init_done(zram)) {
 		struct zram_meta *meta = zram->meta;
 		atomic_long_set(&zram->stats.max_used_pages,
-				zs_get_total_pages(meta->mem_pool));
+			zpool_get_total_size(meta->mem_pool) >> PAGE_SHIFT);
 	}
 	up_read(&zram->init_lock);
 
@@ -379,7 +380,7 @@ static ssize_t compact_store(struct device *dev,
 	}
 
 	meta = zram->meta;
-	zs_compact(meta->mem_pool);
+	zpool_shrink(meta->mem_pool, 0, NULL);
 	up_read(&zram->init_lock);
 
 	return len;
@@ -407,31 +408,25 @@ static ssize_t mm_stat_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct zram *zram = dev_to_zram(dev);
-	struct zs_pool_stats pool_stats;
 	u64 orig_size, mem_used = 0;
 	long max_used;
 	ssize_t ret;
 
-	memset(&pool_stats, 0x00, sizeof(struct zs_pool_stats));
-
 	down_read(&zram->init_lock);
-	if (init_done(zram)) {
-		mem_used = zs_get_total_pages(zram->meta->mem_pool);
-		zs_pool_stats(zram->meta->mem_pool, &pool_stats);
-	}
+	if (init_done(zram))
+		mem_used = zpool_get_total_size(zram->meta->mem_pool);
 
 	orig_size = atomic64_read(&zram->stats.pages_stored);
 	max_used = atomic_long_read(&zram->stats.max_used_pages);
 
 	ret = scnprintf(buf, PAGE_SIZE,
-			"%8llu %8llu %8llu %8lu %8ld %8llu %8lu\n",
+			"%8llu %8llu %8llu %8lu %8ld %8llu\n",
 			orig_size << PAGE_SHIFT,
 			(u64)atomic64_read(&zram->stats.compr_data_size),
-			mem_used << PAGE_SHIFT,
+			mem_used,
 			zram->limit_pages << PAGE_SHIFT,
 			max_used << PAGE_SHIFT,
-			(u64)atomic64_read(&zram->stats.zero_pages),
-			pool_stats.pages_compacted);
+			(u64)atomic64_read(&zram->stats.zero_pages));
 	up_read(&zram->init_lock);
 
 	return ret;
@@ -490,10 +485,10 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize)
 		if (!handle)
 			continue;
 
-		zs_free(meta->mem_pool, handle);
+		zpool_free(meta->mem_pool, handle);
 	}
 
-	zs_destroy_pool(meta->mem_pool);
+	zpool_destroy_pool(meta->mem_pool);
 	vfree(meta->table);
 	kfree(meta);
 }
@@ -513,7 +508,13 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
 		goto out_error;
 	}
 
-	meta->mem_pool = zs_create_pool(pool_name);
+	if (!zpool_has_pool(default_zpool_type)) {
+		pr_err("zpool %s not available\n", default_zpool_type);
+		goto out_error;
+	}
+
+	meta->mem_pool = zpool_create_pool(default_zpool_type,
+					   pool_name, 0, NULL);
 	if (!meta->mem_pool) {
 		pr_err("Error creating memory pool\n");
 		goto out_error;
@@ -549,7 +550,7 @@ static void zram_free_page(struct zram *zram, size_t index)
 		return;
 	}
 
-	zs_free(meta->mem_pool, handle);
+	zpool_free(meta->mem_pool, handle);
 
 	atomic64_sub(zram_get_obj_size(meta, index),
 			&zram->stats.compr_data_size);
@@ -577,7 +578,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
 		return 0;
 	}
 
-	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO);
+	cmem = zpool_map_handle(meta->mem_pool, handle, ZPOOL_MM_RO);
 	if (size == PAGE_SIZE) {
 		copy_page(mem, cmem);
 	} else {
@@ -586,7 +587,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
 		ret = zcomp_decompress(zstrm, cmem, size, mem);
 		zcomp_stream_put(zram->comp);
 	}
-	zs_unmap_object(meta->mem_pool, handle);
+	zpool_unmap_handle(meta->mem_pool, handle);
 	bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
 
 	/* Should NEVER happen. Return bio error if it does. */
@@ -735,20 +736,20 @@ compress_again:
 	 * from the slow path and handle has already been allocated.
 	 */
 	if (!handle)
-		handle = zs_malloc(meta->mem_pool, clen,
+		ret = zpool_malloc(meta->mem_pool, clen,
 				__GFP_KSWAPD_RECLAIM |
 				__GFP_NOWARN |
 				__GFP_HIGHMEM |
-				__GFP_MOVABLE);
+				__GFP_MOVABLE, &handle);
 	if (!handle) {
 		zcomp_stream_put(zram->comp);
 		zstrm = NULL;
 
 		atomic64_inc(&zram->stats.writestall);
 
-		handle = zs_malloc(meta->mem_pool, clen,
+		ret = zpool_malloc(meta->mem_pool, clen,
 				GFP_NOIO | __GFP_HIGHMEM |
-				__GFP_MOVABLE);
+				__GFP_MOVABLE, &handle);
 		if (handle)
 			goto compress_again;
 
@@ -758,16 +759,16 @@ compress_again:
 		goto out;
 	}
 
-	alloced_pages = zs_get_total_pages(meta->mem_pool);
+	alloced_pages = zpool_get_total_size(meta->mem_pool) >> PAGE_SHIFT;
 	update_used_max(zram, alloced_pages);
 
 	if (zram->limit_pages && alloced_pages > zram->limit_pages) {
-		zs_free(meta->mem_pool, handle);
+		zpool_free(meta->mem_pool, handle);
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO);
+	cmem = zpool_map_handle(meta->mem_pool, handle, ZPOOL_MM_WO);
 
 	if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) {
 		src = kmap_atomic(page);
@@ -779,7 +780,7 @@ compress_again:
 
 	zcomp_stream_put(zram->comp);
 	zstrm = NULL;
-	zs_unmap_object(meta->mem_pool, handle);
+	zpool_unmap_handle(meta->mem_pool, handle);
 
 	/*
 	 * Free memory associated with this sector
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 74fcf10..de3e013 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -16,7 +16,7 @@
 #define _ZRAM_DRV_H_
 
 #include <linux/rwsem.h>
-#include <linux/zsmalloc.h>
+#include <linux/zpool.h>
 #include <linux/crypto.h>
 
 #include "zcomp.h"
@@ -91,7 +91,7 @@ struct zram_stats {
 
 struct zram_meta {
 	struct zram_table_entry *table;
-	struct zs_pool *mem_pool;
+	struct zpool *mem_pool;
 };
 
 struct zram {
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 6a58edc..56e6439 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -421,7 +421,8 @@ static void zs_zpool_free(void *pool, unsigned long handle)
 static int zs_zpool_shrink(void *pool, unsigned int pages,
 			unsigned int *reclaimed)
 {
-	return -EINVAL;
+	zs_compact(pool);
+	return 0;
 }
 
 static void *zs_zpool_map(void *pool, unsigned long handle,
@@ -609,10 +610,10 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
 	unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0;
 	unsigned long total_freeable = 0;
 
-	seq_printf(s, " %5s %5s %11s %12s %13s %10s %10s %16s %8s\n",
+	seq_printf(s, " %5s %5s %11s %12s %13s %10s %10s %16s %8s %15s\n",
 			"class", "size", "almost_full", "almost_empty",
 			"obj_allocated", "obj_used", "pages_used",
-			"pages_per_zspage", "freeable");
+			"pages_per_zspage", "freeable", "pages_compacted");
 
 	for (i = 0; i < zs_size_classes; i++) {
 		class = pool->size_class[i];
@@ -648,10 +649,11 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
 	}
 
 	seq_puts(s, "\n");
-	seq_printf(s, " %5s %5s %11lu %12lu %13lu %10lu %10lu %16s %8lu\n",
+	seq_printf(s, " %5s %5s %11lu %12lu %13lu %10lu %10lu %16s %8lu %15lu\n",
 			"Total", "", total_class_almost_full,
 			total_class_almost_empty, total_objs,
-			total_used_objs, total_pages, "", total_freeable);
+			total_used_objs, total_pages, "", total_freeable,
+			pool->stats.pages_compacted);
 
 	return 0;
 }
-- 
2.5.5

[toc] | [next] | [standalone]


#1423105

FromDan Streetman <dan.streetman@canonical.com>
Date2016-06-15 17:00 +0200
Message-ID<rKksp-3QZ-3@gated-at.bofh.it>
In reply to#1423095
On Wed, Jun 15, 2016 at 10:42 AM, Geliang Tang <geliangtang@gmail.com> wrote:
> Change zram to use the zpool api instead of directly using zsmalloc.
> The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
> I did the following two things to fix it.
> 1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
>    call zs_compact() in zsmalloc.
> 2) The 'pages_compacted' attribute is showed in zram by calling
>    zs_pool_stats(). So in order not to call zs_pool_state() I move the
>    attribute to zsmalloc.

I think you're going to have quite a hard time getting a patch like
this accepted without doing some convincing that it's really needed,
and I don't see any new reasons here.  Possibly hard data on how it
improves speed or some other metric, plus reasoning on how using zpool
is better for zram than keeping its direct link to zsmalloc (meaning,
why can't zsmalloc just be improved to perform on par with zpool, on
whatever metric you're comparing).

>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/block/zram/Kconfig    |  3 ++-
>  drivers/block/zram/zram_drv.c | 59 ++++++++++++++++++++++---------------------
>  drivers/block/zram/zram_drv.h |  4 +--
>  mm/zsmalloc.c                 | 12 +++++----
>  4 files changed, 41 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
> index b8ecba6..6389a5a 100644
> --- a/drivers/block/zram/Kconfig
> +++ b/drivers/block/zram/Kconfig
> @@ -1,6 +1,7 @@
>  config ZRAM
>         tristate "Compressed RAM block device support"
> -       depends on BLOCK && SYSFS && ZSMALLOC && CRYPTO
> +       depends on BLOCK && SYSFS && ZPOOL && CRYPTO
> +       select ZSMALLOC
>         select CRYPTO_LZO
>         default n
>         help
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 7454cf1..7ee9050 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -39,6 +39,7 @@ static DEFINE_MUTEX(zram_index_mutex);
>
>  static int zram_major;
>  static const char *default_compressor = "lzo";
> +static char *default_zpool_type = "zsmalloc";
>
>  /* Module params (documentation at end) */
>  static unsigned int num_devices = 1;
> @@ -228,11 +229,11 @@ static ssize_t mem_used_total_show(struct device *dev,
>         down_read(&zram->init_lock);
>         if (init_done(zram)) {
>                 struct zram_meta *meta = zram->meta;
> -               val = zs_get_total_pages(meta->mem_pool);
> +               val = zpool_get_total_size(meta->mem_pool);
>         }
>         up_read(&zram->init_lock);
>
> -       return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT);
> +       return scnprintf(buf, PAGE_SIZE, "%llu\n", val);
>  }
>
>  static ssize_t mem_limit_show(struct device *dev,
> @@ -297,7 +298,7 @@ static ssize_t mem_used_max_store(struct device *dev,
>         if (init_done(zram)) {
>                 struct zram_meta *meta = zram->meta;
>                 atomic_long_set(&zram->stats.max_used_pages,
> -                               zs_get_total_pages(meta->mem_pool));
> +                       zpool_get_total_size(meta->mem_pool) >> PAGE_SHIFT);
>         }
>         up_read(&zram->init_lock);
>
> @@ -379,7 +380,7 @@ static ssize_t compact_store(struct device *dev,
>         }
>
>         meta = zram->meta;
> -       zs_compact(meta->mem_pool);
> +       zpool_shrink(meta->mem_pool, 0, NULL);
>         up_read(&zram->init_lock);
>
>         return len;
> @@ -407,31 +408,25 @@ static ssize_t mm_stat_show(struct device *dev,
>                 struct device_attribute *attr, char *buf)
>  {
>         struct zram *zram = dev_to_zram(dev);
> -       struct zs_pool_stats pool_stats;
>         u64 orig_size, mem_used = 0;
>         long max_used;
>         ssize_t ret;
>
> -       memset(&pool_stats, 0x00, sizeof(struct zs_pool_stats));
> -
>         down_read(&zram->init_lock);
> -       if (init_done(zram)) {
> -               mem_used = zs_get_total_pages(zram->meta->mem_pool);
> -               zs_pool_stats(zram->meta->mem_pool, &pool_stats);
> -       }
> +       if (init_done(zram))
> +               mem_used = zpool_get_total_size(zram->meta->mem_pool);
>
>         orig_size = atomic64_read(&zram->stats.pages_stored);
>         max_used = atomic_long_read(&zram->stats.max_used_pages);
>
>         ret = scnprintf(buf, PAGE_SIZE,
> -                       "%8llu %8llu %8llu %8lu %8ld %8llu %8lu\n",
> +                       "%8llu %8llu %8llu %8lu %8ld %8llu\n",
>                         orig_size << PAGE_SHIFT,
>                         (u64)atomic64_read(&zram->stats.compr_data_size),
> -                       mem_used << PAGE_SHIFT,
> +                       mem_used,
>                         zram->limit_pages << PAGE_SHIFT,
>                         max_used << PAGE_SHIFT,
> -                       (u64)atomic64_read(&zram->stats.zero_pages),
> -                       pool_stats.pages_compacted);
> +                       (u64)atomic64_read(&zram->stats.zero_pages));
>         up_read(&zram->init_lock);
>
>         return ret;
> @@ -490,10 +485,10 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize)
>                 if (!handle)
>                         continue;
>
> -               zs_free(meta->mem_pool, handle);
> +               zpool_free(meta->mem_pool, handle);
>         }
>
> -       zs_destroy_pool(meta->mem_pool);
> +       zpool_destroy_pool(meta->mem_pool);
>         vfree(meta->table);
>         kfree(meta);
>  }
> @@ -513,7 +508,13 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
>                 goto out_error;
>         }
>
> -       meta->mem_pool = zs_create_pool(pool_name);
> +       if (!zpool_has_pool(default_zpool_type)) {
> +               pr_err("zpool %s not available\n", default_zpool_type);
> +               goto out_error;
> +       }
> +
> +       meta->mem_pool = zpool_create_pool(default_zpool_type,
> +                                          pool_name, 0, NULL);
>         if (!meta->mem_pool) {
>                 pr_err("Error creating memory pool\n");
>                 goto out_error;
> @@ -549,7 +550,7 @@ static void zram_free_page(struct zram *zram, size_t index)
>                 return;
>         }
>
> -       zs_free(meta->mem_pool, handle);
> +       zpool_free(meta->mem_pool, handle);
>
>         atomic64_sub(zram_get_obj_size(meta, index),
>                         &zram->stats.compr_data_size);
> @@ -577,7 +578,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
>                 return 0;
>         }
>
> -       cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO);
> +       cmem = zpool_map_handle(meta->mem_pool, handle, ZPOOL_MM_RO);
>         if (size == PAGE_SIZE) {
>                 copy_page(mem, cmem);
>         } else {
> @@ -586,7 +587,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
>                 ret = zcomp_decompress(zstrm, cmem, size, mem);
>                 zcomp_stream_put(zram->comp);
>         }
> -       zs_unmap_object(meta->mem_pool, handle);
> +       zpool_unmap_handle(meta->mem_pool, handle);
>         bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
>
>         /* Should NEVER happen. Return bio error if it does. */
> @@ -735,20 +736,20 @@ compress_again:
>          * from the slow path and handle has already been allocated.
>          */
>         if (!handle)
> -               handle = zs_malloc(meta->mem_pool, clen,
> +               ret = zpool_malloc(meta->mem_pool, clen,
>                                 __GFP_KSWAPD_RECLAIM |
>                                 __GFP_NOWARN |
>                                 __GFP_HIGHMEM |
> -                               __GFP_MOVABLE);
> +                               __GFP_MOVABLE, &handle);
>         if (!handle) {
>                 zcomp_stream_put(zram->comp);
>                 zstrm = NULL;
>
>                 atomic64_inc(&zram->stats.writestall);
>
> -               handle = zs_malloc(meta->mem_pool, clen,
> +               ret = zpool_malloc(meta->mem_pool, clen,
>                                 GFP_NOIO | __GFP_HIGHMEM |
> -                               __GFP_MOVABLE);
> +                               __GFP_MOVABLE, &handle);
>                 if (handle)
>                         goto compress_again;
>
> @@ -758,16 +759,16 @@ compress_again:
>                 goto out;
>         }
>
> -       alloced_pages = zs_get_total_pages(meta->mem_pool);
> +       alloced_pages = zpool_get_total_size(meta->mem_pool) >> PAGE_SHIFT;
>         update_used_max(zram, alloced_pages);
>
>         if (zram->limit_pages && alloced_pages > zram->limit_pages) {
> -               zs_free(meta->mem_pool, handle);
> +               zpool_free(meta->mem_pool, handle);
>                 ret = -ENOMEM;
>                 goto out;
>         }
>
> -       cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO);
> +       cmem = zpool_map_handle(meta->mem_pool, handle, ZPOOL_MM_WO);
>
>         if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) {
>                 src = kmap_atomic(page);
> @@ -779,7 +780,7 @@ compress_again:
>
>         zcomp_stream_put(zram->comp);
>         zstrm = NULL;
> -       zs_unmap_object(meta->mem_pool, handle);
> +       zpool_unmap_handle(meta->mem_pool, handle);
>
>         /*
>          * Free memory associated with this sector
> diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
> index 74fcf10..de3e013 100644
> --- a/drivers/block/zram/zram_drv.h
> +++ b/drivers/block/zram/zram_drv.h
> @@ -16,7 +16,7 @@
>  #define _ZRAM_DRV_H_
>
>  #include <linux/rwsem.h>
> -#include <linux/zsmalloc.h>
> +#include <linux/zpool.h>
>  #include <linux/crypto.h>
>
>  #include "zcomp.h"
> @@ -91,7 +91,7 @@ struct zram_stats {
>
>  struct zram_meta {
>         struct zram_table_entry *table;
> -       struct zs_pool *mem_pool;
> +       struct zpool *mem_pool;
>  };
>
>  struct zram {
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 6a58edc..56e6439 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -421,7 +421,8 @@ static void zs_zpool_free(void *pool, unsigned long handle)
>  static int zs_zpool_shrink(void *pool, unsigned int pages,
>                         unsigned int *reclaimed)
>  {
> -       return -EINVAL;
> +       zs_compact(pool);
> +       return 0;

If we're doing this, I'd like it to be implemented correctly;
zs_compact returns the number of pages compacted, so you should set
reclaimed to that.

>  }
>
>  static void *zs_zpool_map(void *pool, unsigned long handle,
> @@ -609,10 +610,10 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
>         unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0;
>         unsigned long total_freeable = 0;
>
> -       seq_printf(s, " %5s %5s %11s %12s %13s %10s %10s %16s %8s\n",
> +       seq_printf(s, " %5s %5s %11s %12s %13s %10s %10s %16s %8s %15s\n",
>                         "class", "size", "almost_full", "almost_empty",
>                         "obj_allocated", "obj_used", "pages_used",
> -                       "pages_per_zspage", "freeable");
> +                       "pages_per_zspage", "freeable", "pages_compacted");
>
>         for (i = 0; i < zs_size_classes; i++) {
>                 class = pool->size_class[i];
> @@ -648,10 +649,11 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
>         }
>
>         seq_puts(s, "\n");
> -       seq_printf(s, " %5s %5s %11lu %12lu %13lu %10lu %10lu %16s %8lu\n",
> +       seq_printf(s, " %5s %5s %11lu %12lu %13lu %10lu %10lu %16s %8lu %15lu\n",
>                         "Total", "", total_class_almost_full,
>                         total_class_almost_empty, total_objs,
> -                       total_used_objs, total_pages, "", total_freeable);
> +                       total_used_objs, total_pages, "", total_freeable,
> +                       pool->stats.pages_compacted);
>
>         return 0;
>  }
> --
> 2.5.5
>

[toc] | [prev] | [next] | [standalone]


#1423572

FromMinchan Kim <minchan@kernel.org>
Date2016-06-16 01:20 +0200
Message-ID<rKsgh-wr-1@gated-at.bofh.it>
In reply to#1423095
On Wed, Jun 15, 2016 at 10:42:07PM +0800, Geliang Tang wrote:
> Change zram to use the zpool api instead of directly using zsmalloc.
> The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
> I did the following two things to fix it.
> 1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
>    call zs_compact() in zsmalloc.
> 2) The 'pages_compacted' attribute is showed in zram by calling
>    zs_pool_stats(). So in order not to call zs_pool_state() I move the
>    attribute to zsmalloc.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

NACK.

I already explained why.
http://lkml.kernel.org/r/20160609013411.GA29779@bbox

[toc] | [prev] | [next] | [standalone]


#1424809

FromVitaly Wool <vitalywool@gmail.com>
Date2016-06-17 10:40 +0200
Message-ID<rKXtM-49O-13@gated-at.bofh.it>
In reply to#1423572
Hi Minchan,

On Thu, Jun 16, 2016 at 1:17 AM, Minchan Kim <minchan@kernel.org> wrote:
> On Wed, Jun 15, 2016 at 10:42:07PM +0800, Geliang Tang wrote:
>> Change zram to use the zpool api instead of directly using zsmalloc.
>> The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
>> I did the following two things to fix it.
>> 1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
>>    call zs_compact() in zsmalloc.
>> 2) The 'pages_compacted' attribute is showed in zram by calling
>>    zs_pool_stats(). So in order not to call zs_pool_state() I move the
>>    attribute to zsmalloc.
>>
>> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
>
> NACK.
>
> I already explained why.
> http://lkml.kernel.org/r/20160609013411.GA29779@bbox

This is a fair statement, to a certain extent. I'll let Geliang speak
for himself but I am personally interested in this zram extension
because I want it to work on MMU-less systems. zsmalloc can not handle
that, so I want to be able to use zram over z3fold.

Best regards,
   Vitaly

[toc] | [prev] | [next] | [standalone]


#1425004

From"Austin S. Hemmelgarn" <ahferroin7@gmail.com>
Date2016-06-17 14:30 +0200
Message-ID<rL14l-6sY-7@gated-at.bofh.it>
In reply to#1424809
On 2016-06-17 04:30, Vitaly Wool wrote:
> Hi Minchan,
>
> On Thu, Jun 16, 2016 at 1:17 AM, Minchan Kim <minchan@kernel.org> wrote:
>> On Wed, Jun 15, 2016 at 10:42:07PM +0800, Geliang Tang wrote:
>>> Change zram to use the zpool api instead of directly using zsmalloc.
>>> The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
>>> I did the following two things to fix it.
>>> 1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
>>>    call zs_compact() in zsmalloc.
>>> 2) The 'pages_compacted' attribute is showed in zram by calling
>>>    zs_pool_stats(). So in order not to call zs_pool_state() I move the
>>>    attribute to zsmalloc.
>>>
>>> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
>>
>> NACK.
>>
>> I already explained why.
>> http://lkml.kernel.org/r/20160609013411.GA29779@bbox
>
> This is a fair statement, to a certain extent. I'll let Geliang speak
> for himself but I am personally interested in this zram extension
> because I want it to work on MMU-less systems. zsmalloc can not handle
> that, so I want to be able to use zram over z3fold.
I concur with this.

It's also worth pointing out that people can and do use zram for things 
other than swap, so the assumption that zswap is a viable alternative is 
not universally correct.  In my case for example, I use it on a VM host 
for temporary storage for transient SSI VM's.  Making it more 
deterministic would be seriously helpful in this case, as it would mean 
I can more precisely provision resources on this particular system, and 
could better account for latencies in the testing these transient VM's 
are used for.

[toc] | [prev] | [next] | [standalone]


#1426310

FromMinchan Kim <minchan@kernel.org>
Date2016-06-20 10:10 +0200
Message-ID<rM2ro-5J9-41@gated-at.bofh.it>
In reply to#1424809
On Fri, Jun 17, 2016 at 10:30:58AM +0200, Vitaly Wool wrote:
> Hi Minchan,
> 
> On Thu, Jun 16, 2016 at 1:17 AM, Minchan Kim <minchan@kernel.org> wrote:
> > On Wed, Jun 15, 2016 at 10:42:07PM +0800, Geliang Tang wrote:
> >> Change zram to use the zpool api instead of directly using zsmalloc.
> >> The zpool api doesn't have zs_compact() and zs_pool_stats() functions.
> >> I did the following two things to fix it.
> >> 1) I replace zs_compact() with zpool_shrink(), use zpool_shrink() to
> >>    call zs_compact() in zsmalloc.
> >> 2) The 'pages_compacted' attribute is showed in zram by calling
> >>    zs_pool_stats(). So in order not to call zs_pool_state() I move the
> >>    attribute to zsmalloc.
> >>
> >> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> >
> > NACK.
> >
> > I already explained why.
> > http://lkml.kernel.org/r/20160609013411.GA29779@bbox
> 
> This is a fair statement, to a certain extent. I'll let Geliang speak
> for himself but I am personally interested in this zram extension
> because I want it to work on MMU-less systems. zsmalloc can not handle
> that, so I want to be able to use zram over z3fold.

Could you tell me more detail? What's the usecase?

> 
> Best regards,
>    Vitaly
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web