Commit b430d1fd authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Linus Torvalds

zsmalloc: drop unused variable `nr_to_migrate'

This patchset tweaks compaction and makes it possible to trigger pool
compaction automatically when system is getting low on memory.

zsmalloc in some cases can suffer from a notable fragmentation and
compaction can release some considerable amount of memory.  The problem
here is that currently we fully rely on user space to perform compaction
when needed.  However, performing zsmalloc compaction is not always an
obvious thing to do.  For example, suppose we have a `idle' fragmented
(compaction was never performed) zram device and system is getting low
on memory due to some 3rd party user processes (gcc LTO, or firefox,
etc.).  It's quite unlikely that user space will issue zpool compaction
in this case.  Besides, user space cannot tell for sure how badly pool
is fragmented; however, this info is known to zsmalloc and, hence, to a
shrinker.

This patch (of 7):

__zs_compact() does not use `nr_to_migrate', drop it.
Signed-off-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: default avatarMinchan Kim <minchan@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ad5ea8cd
...@@ -1703,7 +1703,6 @@ static struct page *isolate_source_page(struct size_class *class) ...@@ -1703,7 +1703,6 @@ static struct page *isolate_source_page(struct size_class *class)
static unsigned long __zs_compact(struct zs_pool *pool, static unsigned long __zs_compact(struct zs_pool *pool,
struct size_class *class) struct size_class *class)
{ {
int nr_to_migrate;
struct zs_compact_control cc; struct zs_compact_control cc;
struct page *src_page; struct page *src_page;
struct page *dst_page = NULL; struct page *dst_page = NULL;
...@@ -1714,8 +1713,6 @@ static unsigned long __zs_compact(struct zs_pool *pool, ...@@ -1714,8 +1713,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
BUG_ON(!is_first_page(src_page)); 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.index = 0;
cc.s_page = src_page; cc.s_page = src_page;
...@@ -1730,7 +1727,6 @@ static unsigned long __zs_compact(struct zs_pool *pool, ...@@ -1730,7 +1727,6 @@ static unsigned long __zs_compact(struct zs_pool *pool,
putback_zspage(pool, class, dst_page); putback_zspage(pool, class, dst_page);
nr_total_migrated += cc.nr_migrated; nr_total_migrated += cc.nr_migrated;
nr_to_migrate -= cc.nr_migrated;
} }
/* Stop if we couldn't find slot */ /* Stop if we couldn't find slot */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment