* [PATCH v5 1/7] zsmalloc: drop unused variable `nr_to_migrate'
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 2/7] zsmalloc: always keep per-class stats Sergey Senozhatsky
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
__zs_compact() does not use `nr_to_migrate', drop it.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
---
mm/zsmalloc.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 3538b8c..2aecdb3 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1712,7 +1712,6 @@ static struct page *isolate_source_page(struct size_class *class)
static unsigned long __zs_compact(struct zs_pool *pool,
struct size_class *class)
{
- int nr_to_migrate;
struct zs_compact_control cc;
struct page *src_page;
struct page *dst_page = NULL;
@@ -1723,8 +1722,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
BUG_ON(!is_first_page(src_page));
- /* The goal is to migrate all live objects in source page */
- nr_to_migrate = src_page->inuse;
cc.index = 0;
cc.s_page = src_page;
@@ -1739,7 +1736,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
putback_zspage(pool, class, dst_page);
nr_total_migrated += cc.nr_migrated;
- nr_to_migrate -= cc.nr_migrated;
}
/* Stop if we couldn't find slot */
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v5 2/7] zsmalloc: always keep per-class stats
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 1/7] zsmalloc: drop unused variable `nr_to_migrate' Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 3/7] zsmalloc: introduce zs_can_compact() function Sergey Senozhatsky
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
Always account per-class `zs_size_stat' stats. This data will
help us make better decisions during compaction. We are especially
interested in OBJ_ALLOCATED and OBJ_USED, which can tell us if
class compaction will result in any memory gain.
For instance, we know the number of allocated objects in the class,
the number of objects being used (so we also know how many objects
are not used) and the number of objects per-page. So we can ensure
if we have enough unused objects to form at least one ZS_EMPTY
zspage during compaction.
We calculate this value on per-class basis so we can calculate a
total number of zspages that can be released. Which is exactly what
a shrinker wants to know.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
---
mm/zsmalloc.c | 48 ++++++++++++------------------------------------
1 file changed, 12 insertions(+), 36 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2aecdb3..036baa8 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -169,14 +169,12 @@ enum zs_stat_type {
NR_ZS_STAT_TYPE,
};
-#ifdef CONFIG_ZSMALLOC_STAT
-
-static struct dentry *zs_stat_root;
-
struct zs_size_stat {
unsigned long objs[NR_ZS_STAT_TYPE];
};
+#ifdef CONFIG_ZSMALLOC_STAT
+static struct dentry *zs_stat_root;
#endif
/*
@@ -201,25 +199,21 @@ static int zs_size_classes;
static const int fullness_threshold_frac = 4;
struct size_class {
+ spinlock_t lock;
+ struct page *fullness_list[_ZS_NR_FULLNESS_GROUPS];
/*
* Size of objects stored in this class. Must be multiple
* of ZS_ALIGN.
*/
- int size;
- unsigned int index;
+ int size;
+ unsigned int index;
/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
- int pages_per_zspage;
- /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */
- bool huge;
-
-#ifdef CONFIG_ZSMALLOC_STAT
- struct zs_size_stat stats;
-#endif
-
- spinlock_t lock;
+ int pages_per_zspage;
+ struct zs_size_stat stats;
- struct page *fullness_list[_ZS_NR_FULLNESS_GROUPS];
+ /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */
+ bool huge;
};
/*
@@ -441,8 +435,6 @@ static int get_size_class_index(int size)
return min(zs_size_classes - 1, idx);
}
-#ifdef CONFIG_ZSMALLOC_STAT
-
static inline void zs_stat_inc(struct size_class *class,
enum zs_stat_type type, unsigned long cnt)
{
@@ -461,6 +453,8 @@ static inline unsigned long zs_stat_get(struct size_class *class,
return class->stats.objs[type];
}
+#ifdef CONFIG_ZSMALLOC_STAT
+
static int __init zs_stat_init(void)
{
if (!debugfs_initialized())
@@ -576,23 +570,6 @@ static void zs_pool_stat_destroy(struct zs_pool *pool)
}
#else /* CONFIG_ZSMALLOC_STAT */
-
-static inline void zs_stat_inc(struct size_class *class,
- enum zs_stat_type type, unsigned long cnt)
-{
-}
-
-static inline void zs_stat_dec(struct size_class *class,
- enum zs_stat_type type, unsigned long cnt)
-{
-}
-
-static inline unsigned long zs_stat_get(struct size_class *class,
- enum zs_stat_type type)
-{
- return 0;
-}
-
static int __init zs_stat_init(void)
{
return 0;
@@ -610,7 +587,6 @@ static inline int zs_pool_stat_create(char *name, struct zs_pool *pool)
static inline void zs_pool_stat_destroy(struct zs_pool *pool)
{
}
-
#endif
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v5 3/7] zsmalloc: introduce zs_can_compact() function
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 1/7] zsmalloc: drop unused variable `nr_to_migrate' Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 2/7] zsmalloc: always keep per-class stats Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 4/7] zsmalloc: cosmetic compaction code adjustments Sergey Senozhatsky
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
This function checks if class compaction will free any pages.
Rephrasing -- do we have enough unused objects to form at least
one ZS_EMPTY page and free it. It aborts compaction if class
compaction will not result in any (further) savings.
EXAMPLE (this debug output is not part of this patch set):
-- class size
-- number of allocated objects
-- number of used objects
-- max objects per zspage
-- pages per zspage
-- estimated number of pages that will be freed
[..]
class-512 objs:544 inuse:540 maxobj-per-zspage:8 pages-per-zspage:1 zspages-to-free:0
... class-512 compaction is useless. break
class-496 objs:660 inuse:570 maxobj-per-zspage:33 pages-per-zspage:4 zspages-to-free:2
class-496 objs:627 inuse:570 maxobj-per-zspage:33 pages-per-zspage:4 zspages-to-free:1
class-496 objs:594 inuse:570 maxobj-per-zspage:33 pages-per-zspage:4 zspages-to-free:0
... class-496 compaction is useless. break
class-448 objs:657 inuse:617 maxobj-per-zspage:9 pages-per-zspage:1 zspages-to-free:4
class-448 objs:648 inuse:617 maxobj-per-zspage:9 pages-per-zspage:1 zspages-to-free:3
class-448 objs:639 inuse:617 maxobj-per-zspage:9 pages-per-zspage:1 zspages-to-free:2
class-448 objs:630 inuse:617 maxobj-per-zspage:9 pages-per-zspage:1 zspages-to-free:1
class-448 objs:621 inuse:617 maxobj-per-zspage:9 pages-per-zspage:1 zspages-to-free:0
... class-448 compaction is useless. break
class-432 objs:728 inuse:685 maxobj-per-zspage:28 pages-per-zspage:3 zspages-to-free:1
class-432 objs:700 inuse:685 maxobj-per-zspage:28 pages-per-zspage:3 zspages-to-free:0
... class-432 compaction is useless. break
class-416 objs:819 inuse:705 maxobj-per-zspage:39 pages-per-zspage:4 zspages-to-free:2
class-416 objs:780 inuse:705 maxobj-per-zspage:39 pages-per-zspage:4 zspages-to-free:1
class-416 objs:741 inuse:705 maxobj-per-zspage:39 pages-per-zspage:4 zspages-to-free:0
... class-416 compaction is useless. break
class-400 objs:690 inuse:674 maxobj-per-zspage:10 pages-per-zspage:1 zspages-to-free:1
class-400 objs:680 inuse:674 maxobj-per-zspage:10 pages-per-zspage:1 zspages-to-free:0
... class-400 compaction is useless. break
class-384 objs:736 inuse:709 maxobj-per-zspage:32 pages-per-zspage:3 zspages-to-free:0
... class-384 compaction is useless. break
[..]
Every "compaction is useless" indicates that we saved CPU cycles.
class-512 has
544 object allocated
540 objects used
8 objects per-page
Even if we have a ALMOST_EMPTY zspage, we still don't have enough room to
migrate all of its objects and free this zspage; so compaction will not
make a lot of sense, it's better to just leave it as is.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
mm/zsmalloc.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 036baa8..b7410c1 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1685,6 +1685,28 @@ static struct page *isolate_source_page(struct size_class *class)
return page;
}
+/*
+ *
+ * Based on the number of unused allocated objects calculate
+ * and return the number of pages that we can free.
+ *
+ * Should be called under class->lock.
+ */
+static unsigned long zs_can_compact(struct size_class *class)
+{
+ unsigned long obj_wasted;
+
+ if (!zs_stat_get(class, CLASS_ALMOST_EMPTY))
+ return 0;
+
+ obj_wasted = zs_stat_get(class, OBJ_ALLOCATED) -
+ zs_stat_get(class, OBJ_USED);
+
+ obj_wasted /= get_maxobj_per_zspage(class->size,
+ class->pages_per_zspage);
+ return obj_wasted * get_pages_per_zspage(class->size);
+}
+
static unsigned long __zs_compact(struct zs_pool *pool,
struct size_class *class)
{
@@ -1698,6 +1720,9 @@ static unsigned long __zs_compact(struct zs_pool *pool,
BUG_ON(!is_first_page(src_page));
+ if (!zs_can_compact(class))
+ break;
+
cc.index = 0;
cc.s_page = src_page;
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v5 4/7] zsmalloc: cosmetic compaction code adjustments
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
` (2 preceding siblings ...)
2015-07-06 12:17 ` [PATCH v5 3/7] zsmalloc: introduce zs_can_compact() function Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 5/7] zsmalloc/zram: store compaction stats in zspool Sergey Senozhatsky
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
Change zs_object_copy() argument order to be (DST, SRC) rather
than (SRC, DST). copy/move functions usually have (to, from)
arguments order.
Rename alloc_target_page() to isolate_target_page(). This
function doesn't allocate anything, it isolates target page,
pretty much like isolate_source_page().
Tweak __zs_compact() comment.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
---
mm/zsmalloc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index b7410c1..ce1484e 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1480,7 +1480,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle)
}
EXPORT_SYMBOL_GPL(zs_free);
-static void zs_object_copy(unsigned long src, unsigned long dst,
+static void zs_object_copy(unsigned long dst, unsigned long src,
struct size_class *class)
{
struct page *s_page, *d_page;
@@ -1621,7 +1621,7 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
used_obj = handle_to_obj(handle);
free_obj = obj_malloc(d_page, class, handle);
- zs_object_copy(used_obj, free_obj, class);
+ zs_object_copy(free_obj, used_obj, class);
index++;
record_obj(handle, free_obj);
unpin_tag(handle);
@@ -1637,7 +1637,7 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
return ret;
}
-static struct page *alloc_target_page(struct size_class *class)
+static struct page *isolate_target_page(struct size_class *class)
{
int i;
struct page *page;
@@ -1726,11 +1726,11 @@ static unsigned long __zs_compact(struct zs_pool *pool,
cc.index = 0;
cc.s_page = src_page;
- while ((dst_page = alloc_target_page(class))) {
+ while ((dst_page = isolate_target_page(class))) {
cc.d_page = dst_page;
/*
- * If there is no more space in dst_page, try to
- * allocate another zspage.
+ * If there is no more space in dst_page, resched
+ * and see if anyone had allocated another zspage.
*/
if (!migrate_zspage(pool, class, &cc))
break;
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v5 5/7] zsmalloc/zram: store compaction stats in zspool
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
` (3 preceding siblings ...)
2015-07-06 12:17 ` [PATCH v5 4/7] zsmalloc: cosmetic compaction code adjustments Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
[not found] ` <20150706132728.GB16529@blaptop>
2015-07-06 12:17 ` [PATCH v5 6/7] zsmalloc: account the number of compacted pages Sergey Senozhatsky
2015-07-06 12:17 ` [PATCH v5 7/7] zsmalloc: register a shrinker to trigger auto-compaction Sergey Senozhatsky
6 siblings, 1 reply; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
`zs_compact_control' accounts the number of migrated objects but
it has a limited lifespan -- we lose it as soon as zs_compaction()
returns back to zram. It was fine, because (a) zram had it's own
counter of migrated objects and (b) only zram could trigger
compaction. However, this does not work for automatic pool
compaction (not issued by zram). To account objects migrated
during auto-compaction (issued by the shrinker) we need to store
this number in zs_pool.
A new zsmalloc zs_get_num_migrated() symbol exports zs_pool's
->num_migrated counter, so we better start using it, rather than
continue keeping zram's own `num_migrated' copy in zram_stats.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/block/zram/zram_drv.c | 12 ++++++------
drivers/block/zram/zram_drv.h | 1 -
include/linux/zsmalloc.h | 1 +
mm/zsmalloc.c | 44 ++++++++++++++++++++++---------------------
4 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index fb655e8..28ad3f8 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -388,7 +388,6 @@ static ssize_t comp_algorithm_store(struct device *dev,
static ssize_t compact_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- unsigned long nr_migrated;
struct zram *zram = dev_to_zram(dev);
struct zram_meta *meta;
@@ -399,8 +398,7 @@ static ssize_t compact_store(struct device *dev,
}
meta = zram->meta;
- nr_migrated = zs_compact(meta->mem_pool);
- atomic64_add(nr_migrated, &zram->stats.num_migrated);
+ zs_compact(meta->mem_pool);
up_read(&zram->init_lock);
return len;
@@ -428,13 +426,15 @@ static ssize_t mm_stat_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct zram *zram = dev_to_zram(dev);
- u64 orig_size, mem_used = 0;
+ u64 orig_size, mem_used = 0, num_migrated = 0;
long max_used;
ssize_t ret;
down_read(&zram->init_lock);
- if (init_done(zram))
+ if (init_done(zram)) {
mem_used = zs_get_total_pages(zram->meta->mem_pool);
+ num_migrated = zs_get_num_migrated(zram->meta->mem_pool);
+ }
orig_size = atomic64_read(&zram->stats.pages_stored);
max_used = atomic_long_read(&zram->stats.max_used_pages);
@@ -447,7 +447,7 @@ static ssize_t mm_stat_show(struct device *dev,
zram->limit_pages << PAGE_SHIFT,
max_used << PAGE_SHIFT,
(u64)atomic64_read(&zram->stats.zero_pages),
- (u64)atomic64_read(&zram->stats.num_migrated));
+ num_migrated);
up_read(&zram->init_lock);
return ret;
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 6dbe2df..8e92339 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -78,7 +78,6 @@ struct zram_stats {
atomic64_t compr_data_size; /* compressed size of pages stored */
atomic64_t num_reads; /* failed + successful */
atomic64_t num_writes; /* --do-- */
- atomic64_t num_migrated; /* no. of migrated object */
atomic64_t failed_reads; /* can happen when memory is too low */
atomic64_t failed_writes; /* can happen when memory is too low */
atomic64_t invalid_io; /* non-page-aligned I/O requests */
diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h
index 1338190..e878875 100644
--- a/include/linux/zsmalloc.h
+++ b/include/linux/zsmalloc.h
@@ -47,6 +47,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
unsigned long zs_get_total_pages(struct zs_pool *pool);
+unsigned long zs_get_num_migrated(struct zs_pool *pool);
unsigned long zs_compact(struct zs_pool *pool);
#endif
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index ce1484e..e0f508a 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -237,16 +237,19 @@ struct link_free {
};
struct zs_pool {
- char *name;
+ char *name;
- struct size_class **size_class;
- struct kmem_cache *handle_cachep;
+ struct size_class **size_class;
+ struct kmem_cache *handle_cachep;
- gfp_t flags; /* allocation flags used when growing pool */
- atomic_long_t pages_allocated;
+ /* Allocation flags used when growing pool */
+ gfp_t flags;
+ atomic_long_t pages_allocated;
+ /* How many objects were migrated */
+ unsigned long num_migrated;
#ifdef CONFIG_ZSMALLOC_STAT
- struct dentry *stat_dentry;
+ struct dentry *stat_dentry;
#endif
};
@@ -1221,6 +1224,12 @@ unsigned long zs_get_total_pages(struct zs_pool *pool)
}
EXPORT_SYMBOL_GPL(zs_get_total_pages);
+unsigned long zs_get_num_migrated(struct zs_pool *pool)
+{
+ return pool->num_migrated;
+}
+EXPORT_SYMBOL_GPL(zs_get_num_migrated);
+
/**
* zs_map_object - get address of allocated object from handle.
* @pool: pool from which the object was allocated
@@ -1587,7 +1596,7 @@ struct zs_compact_control {
/* Starting object index within @s_page which used for live object
* in the subpage. */
int index;
- /* how many of objects are migrated */
+ /* How many of objects were migrated */
int nr_migrated;
};
@@ -1599,7 +1608,6 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
struct page *s_page = cc->s_page;
struct page *d_page = cc->d_page;
unsigned long index = cc->index;
- int nr_migrated = 0;
int ret = 0;
while (1) {
@@ -1626,13 +1634,12 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
record_obj(handle, free_obj);
unpin_tag(handle);
obj_free(pool, class, used_obj);
- nr_migrated++;
+ cc->nr_migrated++;
}
/* Remember last position in this iteration */
cc->s_page = s_page;
cc->index = index;
- cc->nr_migrated = nr_migrated;
return ret;
}
@@ -1707,14 +1714,13 @@ static unsigned long zs_can_compact(struct size_class *class)
return obj_wasted * get_pages_per_zspage(class->size);
}
-static unsigned long __zs_compact(struct zs_pool *pool,
- struct size_class *class)
+static void __zs_compact(struct zs_pool *pool, struct size_class *class)
{
struct zs_compact_control cc;
struct page *src_page;
struct page *dst_page = NULL;
- unsigned long nr_total_migrated = 0;
+ cc.nr_migrated = 0;
spin_lock(&class->lock);
while ((src_page = isolate_source_page(class))) {
@@ -1736,7 +1742,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
break;
putback_zspage(pool, class, dst_page);
- nr_total_migrated += cc.nr_migrated;
}
/* Stop if we couldn't find slot */
@@ -1746,7 +1751,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
putback_zspage(pool, class, dst_page);
putback_zspage(pool, class, src_page);
spin_unlock(&class->lock);
- nr_total_migrated += cc.nr_migrated;
cond_resched();
spin_lock(&class->lock);
}
@@ -1754,15 +1758,14 @@ static unsigned long __zs_compact(struct zs_pool *pool,
if (src_page)
putback_zspage(pool, class, src_page);
- spin_unlock(&class->lock);
+ pool->num_migrated += cc.nr_migrated;
- return nr_total_migrated;
+ spin_unlock(&class->lock);
}
unsigned long zs_compact(struct zs_pool *pool)
{
int i;
- unsigned long nr_migrated = 0;
struct size_class *class;
for (i = zs_size_classes - 1; i >= 0; i--) {
@@ -1771,10 +1774,9 @@ unsigned long zs_compact(struct zs_pool *pool)
continue;
if (class->index != i)
continue;
- nr_migrated += __zs_compact(pool, class);
+ __zs_compact(pool, class);
}
-
- return nr_migrated;
+ return pool->num_migrated;
}
EXPORT_SYMBOL_GPL(zs_compact);
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v5 6/7] zsmalloc: account the number of compacted pages
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
` (4 preceding siblings ...)
2015-07-06 12:17 ` [PATCH v5 5/7] zsmalloc/zram: store compaction stats in zspool Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
2015-07-06 13:22 ` Minchan Kim
2015-07-06 12:17 ` [PATCH v5 7/7] zsmalloc: register a shrinker to trigger auto-compaction Sergey Senozhatsky
6 siblings, 1 reply; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
Compaction returns back to zram the number of migrated objects,
which is quite uninformative -- we have objects of different
sizes so user space cannot obtain any valuable data from that
number. Change compaction to operate in terms of pages and
return back to compaction issuer the number of pages that
were freed during compaction. So from now on `num_compacted'
column in zram<id>/mm_stat represents more meaningful value:
the number of freed (compacted) pages.
Return first_page's fullness_group from putback_zspage(),
so we now for sure know that putback_zspage() has issued
free_zspage() and we must update compaction stats.
Update documentation.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
Documentation/blockdev/zram.txt | 3 ++-
mm/zsmalloc.c | 27 +++++++++++++++++----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index c4de576..71f4744 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -144,7 +144,8 @@ mem_used_max RW the maximum amount memory zram have consumed to
store compressed data
mem_limit RW the maximum amount of memory ZRAM can use to store
the compressed data
-num_migrated RO the number of objects migrated migrated by compaction
+num_migrated RO the number of pages freed during compaction
+ (available only via zram<id>/mm_stat node)
compact WO trigger memory compaction
WARNING
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index e0f508a..a761733 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -245,7 +245,7 @@ struct zs_pool {
/* Allocation flags used when growing pool */
gfp_t flags;
atomic_long_t pages_allocated;
- /* How many objects were migrated */
+ /* How many pages were migrated (freed) */
unsigned long num_migrated;
#ifdef CONFIG_ZSMALLOC_STAT
@@ -1596,8 +1596,6 @@ struct zs_compact_control {
/* Starting object index within @s_page which used for live object
* in the subpage. */
int index;
- /* How many of objects were migrated */
- int nr_migrated;
};
static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
@@ -1634,7 +1632,6 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
record_obj(handle, free_obj);
unpin_tag(handle);
obj_free(pool, class, used_obj);
- cc->nr_migrated++;
}
/* Remember last position in this iteration */
@@ -1660,8 +1657,17 @@ static struct page *isolate_target_page(struct size_class *class)
return page;
}
-static void putback_zspage(struct zs_pool *pool, struct size_class *class,
- struct page *first_page)
+/*
+ * putback_zspage - add @first_page into right class's fullness list
+ * @pool: target pool
+ * @class: destination class
+ * @first_page: target page
+ *
+ * Return @fist_page's fullness_group
+ */
+static enum fullness_group putback_zspage(struct zs_pool *pool,
+ struct size_class *class,
+ struct page *first_page)
{
enum fullness_group fullness;
@@ -1679,6 +1685,8 @@ static void putback_zspage(struct zs_pool *pool, struct size_class *class,
free_zspage(first_page);
}
+
+ return fullness;
}
static struct page *isolate_source_page(struct size_class *class)
@@ -1720,7 +1728,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
struct page *src_page;
struct page *dst_page = NULL;
- cc.nr_migrated = 0;
spin_lock(&class->lock);
while ((src_page = isolate_source_page(class))) {
@@ -1749,7 +1756,9 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
break;
putback_zspage(pool, class, dst_page);
- putback_zspage(pool, class, src_page);
+ if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
+ pool->num_migrated +=
+ get_pages_per_zspage(class->size);
spin_unlock(&class->lock);
cond_resched();
spin_lock(&class->lock);
@@ -1758,8 +1767,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
if (src_page)
putback_zspage(pool, class, src_page);
- pool->num_migrated += cc.nr_migrated;
-
spin_unlock(&class->lock);
}
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v5 6/7] zsmalloc: account the number of compacted pages
2015-07-06 12:17 ` [PATCH v5 6/7] zsmalloc: account the number of compacted pages Sergey Senozhatsky
@ 2015-07-06 13:22 ` Minchan Kim
2015-07-06 13:48 ` Sergey Senozhatsky
0 siblings, 1 reply; 13+ messages in thread
From: Minchan Kim @ 2015-07-06 13:22 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Andrew Morton, linux-mm, linux-kernel
On Mon, Jul 06, 2015 at 09:17:49PM +0900, Sergey Senozhatsky wrote:
> Compaction returns back to zram the number of migrated objects,
> which is quite uninformative -- we have objects of different
> sizes so user space cannot obtain any valuable data from that
> number. Change compaction to operate in terms of pages and
> return back to compaction issuer the number of pages that
> were freed during compaction. So from now on `num_compacted'
> column in zram<id>/mm_stat represents more meaningful value:
> the number of freed (compacted) pages.
Fair enough.
The main reason I introduced num_migrated is to investigate
the effieciency of compaction. ie, num_freed / num_migrated.
However, I didn't put num_freed at that time so I can't get
my goal with only num_migrated.
We could put new knob num_compacted as well as num_migrated
but I don't think we need it now. Zram's compaction would be
much efficient compared to VM's compaction because we don't
have any non-movable objects in zspages and we can account
exact number of free slots.
So, I want to change name from num_migrated to num_compacted
and maintain only it which is more useful for admin, you said.
It's not far since we introduced num_migrated so I don't think
change name wouldn't be a big problem for userspace,(I hope).
>
> Return first_page's fullness_group from putback_zspage(),
> so we now for sure know that putback_zspage() has issued
> free_zspage() and we must update compaction stats.
>
> Update documentation.
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> ---
> Documentation/blockdev/zram.txt | 3 ++-
> mm/zsmalloc.c | 27 +++++++++++++++++----------
> 2 files changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
> index c4de576..71f4744 100644
> --- a/Documentation/blockdev/zram.txt
> +++ b/Documentation/blockdev/zram.txt
> @@ -144,7 +144,8 @@ mem_used_max RW the maximum amount memory zram have consumed to
> store compressed data
> mem_limit RW the maximum amount of memory ZRAM can use to store
> the compressed data
> -num_migrated RO the number of objects migrated migrated by compaction
> +num_migrated RO the number of pages freed during compaction
> + (available only via zram<id>/mm_stat node)
> compact WO trigger memory compaction
>
> WARNING
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index e0f508a..a761733 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -245,7 +245,7 @@ struct zs_pool {
> /* Allocation flags used when growing pool */
> gfp_t flags;
> atomic_long_t pages_allocated;
> - /* How many objects were migrated */
> + /* How many pages were migrated (freed) */
> unsigned long num_migrated;
>
> #ifdef CONFIG_ZSMALLOC_STAT
> @@ -1596,8 +1596,6 @@ struct zs_compact_control {
> /* Starting object index within @s_page which used for live object
> * in the subpage. */
> int index;
> - /* How many of objects were migrated */
> - int nr_migrated;
> };
>
> static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
> @@ -1634,7 +1632,6 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
> record_obj(handle, free_obj);
> unpin_tag(handle);
> obj_free(pool, class, used_obj);
> - cc->nr_migrated++;
> }
>
> /* Remember last position in this iteration */
> @@ -1660,8 +1657,17 @@ static struct page *isolate_target_page(struct size_class *class)
> return page;
> }
>
> -static void putback_zspage(struct zs_pool *pool, struct size_class *class,
> - struct page *first_page)
> +/*
> + * putback_zspage - add @first_page into right class's fullness list
> + * @pool: target pool
> + * @class: destination class
> + * @first_page: target page
> + *
> + * Return @fist_page's fullness_group
> + */
> +static enum fullness_group putback_zspage(struct zs_pool *pool,
> + struct size_class *class,
> + struct page *first_page)
> {
> enum fullness_group fullness;
>
> @@ -1679,6 +1685,8 @@ static void putback_zspage(struct zs_pool *pool, struct size_class *class,
>
> free_zspage(first_page);
> }
> +
> + return fullness;
> }
>
> static struct page *isolate_source_page(struct size_class *class)
> @@ -1720,7 +1728,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
> struct page *src_page;
> struct page *dst_page = NULL;
>
> - cc.nr_migrated = 0;
> spin_lock(&class->lock);
> while ((src_page = isolate_source_page(class))) {
>
> @@ -1749,7 +1756,9 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
> break;
>
> putback_zspage(pool, class, dst_page);
> - putback_zspage(pool, class, src_page);
> + if (putback_zspage(pool, class, src_page) == ZS_EMPTY)
> + pool->num_migrated +=
> + get_pages_per_zspage(class->size);
> spin_unlock(&class->lock);
> cond_resched();
> spin_lock(&class->lock);
> @@ -1758,8 +1767,6 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class)
> if (src_page)
> putback_zspage(pool, class, src_page);
>
> - pool->num_migrated += cc.nr_migrated;
> -
> spin_unlock(&class->lock);
> }
>
> --
> 2.5.0.rc0.3.g912bd49
>
--
Kind regards,
Minchan Kim
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v5 6/7] zsmalloc: account the number of compacted pages
2015-07-06 13:22 ` Minchan Kim
@ 2015-07-06 13:48 ` Sergey Senozhatsky
2015-07-06 14:00 ` Minchan Kim
0 siblings, 1 reply; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 13:48 UTC (permalink / raw)
To: Minchan Kim; +Cc: Sergey Senozhatsky, Andrew Morton, linux-mm, linux-kernel
On (07/06/15 22:22), Minchan Kim wrote:
> On Mon, Jul 06, 2015 at 09:17:49PM +0900, Sergey Senozhatsky wrote:
> > Compaction returns back to zram the number of migrated objects,
> > which is quite uninformative -- we have objects of different
> > sizes so user space cannot obtain any valuable data from that
> > number. Change compaction to operate in terms of pages and
> > return back to compaction issuer the number of pages that
> > were freed during compaction. So from now on `num_compacted'
> > column in zram<id>/mm_stat represents more meaningful value:
> > the number of freed (compacted) pages.
>
> Fair enough.
>
> The main reason I introduced num_migrated is to investigate
> the effieciency of compaction. ie, num_freed / num_migrated.
> However, I didn't put num_freed at that time so I can't get
> my goal with only num_migrated.
>
> We could put new knob num_compacted as well as num_migrated
> but I don't think we need it now. Zram's compaction would be
> much efficient compared to VM's compaction because we don't
> have any non-movable objects in zspages and we can account
> exact number of free slots.
>
> So, I want to change name from num_migrated to num_compacted
> and maintain only it which is more useful for admin, you said.
>
> It's not far since we introduced num_migrated so I don't think
> change name wouldn't be a big problem for userspace,(I hope).
>
Hello,
Yes, num_migrated rename patch was on my table.
I was thinking about two variants:
struct zs_pool
atomic_long_t pages_allocated;
unsigned long num_compacted;
or
struct zs_pool
atomic_long_t pages_allocated;
unsigned long pages_compacted;
the latter looks even better I think. But I didn't come up with a
sane API name to get these stats-- zs_get_pages_compacted() is a bit
misleading. So I decided to keep num_compacted to make the patch set
smaller.
Hm, exporting a new `struct zs_pool_stat' to zram is probably a good
way to go.
-ss
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v5 6/7] zsmalloc: account the number of compacted pages
2015-07-06 13:48 ` Sergey Senozhatsky
@ 2015-07-06 14:00 ` Minchan Kim
0 siblings, 0 replies; 13+ messages in thread
From: Minchan Kim @ 2015-07-06 14:00 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Andrew Morton, linux-mm, linux-kernel
On Mon, Jul 06, 2015 at 10:48:50PM +0900, Sergey Senozhatsky wrote:
> On (07/06/15 22:22), Minchan Kim wrote:
> > On Mon, Jul 06, 2015 at 09:17:49PM +0900, Sergey Senozhatsky wrote:
> > > Compaction returns back to zram the number of migrated objects,
> > > which is quite uninformative -- we have objects of different
> > > sizes so user space cannot obtain any valuable data from that
> > > number. Change compaction to operate in terms of pages and
> > > return back to compaction issuer the number of pages that
> > > were freed during compaction. So from now on `num_compacted'
> > > column in zram<id>/mm_stat represents more meaningful value:
> > > the number of freed (compacted) pages.
> >
> > Fair enough.
> >
> > The main reason I introduced num_migrated is to investigate
> > the effieciency of compaction. ie, num_freed / num_migrated.
> > However, I didn't put num_freed at that time so I can't get
> > my goal with only num_migrated.
> >
> > We could put new knob num_compacted as well as num_migrated
> > but I don't think we need it now. Zram's compaction would be
> > much efficient compared to VM's compaction because we don't
> > have any non-movable objects in zspages and we can account
> > exact number of free slots.
> >
> > So, I want to change name from num_migrated to num_compacted
> > and maintain only it which is more useful for admin, you said.
> >
> > It's not far since we introduced num_migrated so I don't think
> > change name wouldn't be a big problem for userspace,(I hope).
> >
>
> Hello,
>
> Yes, num_migrated rename patch was on my table.
> I was thinking about two variants:
>
> struct zs_pool
> atomic_long_t pages_allocated;
> unsigned long num_compacted;
>
> or
>
> struct zs_pool
> atomic_long_t pages_allocated;
> unsigned long pages_compacted;
>
> the latter looks even better I think. But I didn't come up with a
Yeb.
> sane API name to get these stats-- zs_get_pages_compacted() is a bit
> misleading. So I decided to keep num_compacted to make the patch set
> smaller.
>
> Hm, exporting a new `struct zs_pool_stat' to zram is probably a good
> way to go.
Agreed.
>
> -ss
--
Kind regards,
Minchan Kim
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v5 7/7] zsmalloc: register a shrinker to trigger auto-compaction
2015-07-06 12:17 [PATCH v5 0/7] mm/zsmalloc: introduce automatic pool compaction Sergey Senozhatsky
` (5 preceding siblings ...)
2015-07-06 12:17 ` [PATCH v5 6/7] zsmalloc: account the number of compacted pages Sergey Senozhatsky
@ 2015-07-06 12:17 ` Sergey Senozhatsky
6 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2015-07-06 12:17 UTC (permalink / raw)
To: Minchan Kim
Cc: Andrew Morton, linux-mm, linux-kernel, Sergey,
Senozhatsky <sergey.senozhatsky.work, Sergey Senozhatsky
Perform automatic pool compaction by a shrinker when system
is getting tight on memory.
User-space has a very little knowledge regarding zsmalloc fragmentation
and basically has no mechanism to tell whether compaction will result
in any memory gain. Another issue is that user space is not always
aware of the fact that system is getting tight on memory. Which leads
to very uncomfortable scenarios when user space may start issuing
compaction 'randomly' or from crontab (for example). Fragmentation
is not always necessarily bad, allocated and unused objects, after all,
may be filled with the data later, w/o the need of allocating a new
zspage. On the other hand, we obviously don't want to waste memory
when the system needs it.
Compaction now has a relatively quick pool scan so we are able to
estimate the number of pages that will be freed easily, which makes it
possible to call this function from a shrinker->count_objects() callback.
We also abort compaction as soon as we detect that we can't free any
pages any more, preventing wasteful objects migrations.
Minchan Kim proposed to use the shrinker (the original patch was too
aggressive and was attempting to perform compaction for every
ALMOST_EMPTY zspage).
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Suggested-by: Minchan Kim <minchan@kernel.org>
---
mm/zsmalloc.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 73 insertions(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index a761733..e557c16 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -247,7 +247,9 @@ struct zs_pool {
atomic_long_t pages_allocated;
/* How many pages were migrated (freed) */
unsigned long num_migrated;
-
+ /* Compact classes */
+ struct shrinker shrinker;
+ bool shrinker_enabled;
#ifdef CONFIG_ZSMALLOC_STAT
struct dentry *stat_dentry;
#endif
@@ -1787,6 +1789,69 @@ unsigned long zs_compact(struct zs_pool *pool)
}
EXPORT_SYMBOL_GPL(zs_compact);
+static unsigned long zs_shrinker_scan(struct shrinker *shrinker,
+ struct shrink_control *sc)
+{
+ unsigned long pages_freed;
+ struct zs_pool *pool = container_of(shrinker, struct zs_pool,
+ shrinker);
+
+ pages_freed = pool->num_migrated;
+ /*
+ * Compact classes and calculate compaction delta.
+ * Can run concurrently with a manually triggered
+ * (by user) compaction.
+ */
+ pages_freed = zs_compact(pool) - pages_freed;
+
+ return pages_freed ? pages_freed : SHRINK_STOP;
+}
+
+static unsigned long zs_shrinker_count(struct shrinker *shrinker,
+ struct shrink_control *sc)
+{
+ int i;
+ struct size_class *class;
+ unsigned long pages_to_free = 0;
+ struct zs_pool *pool = container_of(shrinker, struct zs_pool,
+ shrinker);
+
+ if (!pool->shrinker_enabled)
+ return 0;
+
+ for (i = zs_size_classes - 1; i >= 0; i--) {
+ class = pool->size_class[i];
+ if (!class)
+ continue;
+ if (class->index != i)
+ continue;
+
+ spin_lock(&class->lock);
+ pages_to_free += zs_can_compact(class);
+ spin_unlock(&class->lock);
+ }
+
+ return pages_to_free;
+}
+
+static void zs_unregister_shrinker(struct zs_pool *pool)
+{
+ if (pool->shrinker_enabled) {
+ unregister_shrinker(&pool->shrinker);
+ pool->shrinker_enabled = false;
+ }
+}
+
+static int zs_register_shrinker(struct zs_pool *pool)
+{
+ pool->shrinker.scan_objects = zs_shrinker_scan;
+ pool->shrinker.count_objects = zs_shrinker_count;
+ pool->shrinker.batch = 0;
+ pool->shrinker.seeks = DEFAULT_SEEKS;
+
+ return register_shrinker(&pool->shrinker);
+}
+
/**
* zs_create_pool - Creates an allocation pool to work from.
* @flags: allocation flags used to allocate pool metadata
@@ -1872,6 +1937,12 @@ struct zs_pool *zs_create_pool(char *name, gfp_t flags)
if (zs_pool_stat_create(name, pool))
goto err;
+ /*
+ * Not critical, we still can use the pool
+ * and user can trigger compaction manually.
+ */
+ if (zs_register_shrinker(pool) == 0)
+ pool->shrinker_enabled = true;
return pool;
err:
@@ -1884,6 +1955,7 @@ void zs_destroy_pool(struct zs_pool *pool)
{
int i;
+ zs_unregister_shrinker(pool);
zs_pool_stat_destroy(pool);
for (i = 0; i < zs_size_classes; i++) {
--
2.5.0.rc0.3.g912bd49
--
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>
^ permalink raw reply [flat|nested] 13+ messages in thread