From: Vitaly Wool <vitalywool@gmail.com>
To: ddstreet@ieee.org, akpm@linux-foundation.org,
Seth Jennings <sjennings@variantweb.net>
Cc: Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: [PATCHv2 1/3] zpool: add compaction api
Date: Sat, 26 Sep 2015 10:05:51 +0200 [thread overview]
Message-ID: <20150926100551.6c16d0ea3bb7758849150a0a@gmail.com> (raw)
In-Reply-To: <20150926100401.96a36c7cd3c913b063887466@gmail.com>
This patch adds two functions to the zpool API: zpool_compact()
and zpool_get_num_compacted(). The former triggers compaction for
the underlying allocator and the latter retrieves the number of
pages migrated due to compaction for the whole time of this pool's
existence.
Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
---
include/linux/zpool.h | 9 +++++++++
mm/zpool.c | 23 +++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/include/linux/zpool.h b/include/linux/zpool.h
index 42f8ec9..be1ed58 100644
--- a/include/linux/zpool.h
+++ b/include/linux/zpool.h
@@ -58,6 +58,10 @@ void *zpool_map_handle(struct zpool *pool, unsigned long handle,
void zpool_unmap_handle(struct zpool *pool, unsigned long handle);
+unsigned long zpool_compact(struct zpool *pool);
+
+unsigned long zpool_get_num_compacted(struct zpool *pool);
+
u64 zpool_get_total_size(struct zpool *pool);
@@ -72,6 +76,8 @@ u64 zpool_get_total_size(struct zpool *pool);
* @shrink: shrink the pool.
* @map: map a handle.
* @unmap: unmap a handle.
+ * @compact: try to run compaction over a pool
+ * @get_num_compacted: get amount of compacted pages for a pool
* @total_size: get total size of a pool.
*
* This is created by a zpool implementation and registered
@@ -98,6 +104,9 @@ struct zpool_driver {
enum zpool_mapmode mm);
void (*unmap)(void *pool, unsigned long handle);
+ unsigned long (*compact)(void *pool);
+ unsigned long (*get_num_compacted)(void *pool);
+
u64 (*total_size)(void *pool);
};
diff --git a/mm/zpool.c b/mm/zpool.c
index 8f670d3..e469a66 100644
--- a/mm/zpool.c
+++ b/mm/zpool.c
@@ -340,6 +340,29 @@ void zpool_unmap_handle(struct zpool *zpool, unsigned long handle)
zpool->driver->unmap(zpool->pool, handle);
}
+ /**
+ * zpool_compact() - try to run compaction over zpool
+ * @pool The zpool to compact
+ *
+ * Returns: the number of migrated pages
+ */
+unsigned long zpool_compact(struct zpool *zpool)
+{
+ return zpool->driver->compact(zpool->pool);
+}
+
+
+/**
+ * zpool_get_num_compacted() - get the number of migrated/compacted pages
+ * @stats stats to fill in
+ *
+ * Returns: the total number of migrated pages for the pool
+ */
+unsigned long zpool_get_num_compacted(struct zpool *zpool)
+{
+ zpool->driver->get_num_compacted(zpool->pool);
+}
+
/**
* zpool_get_total_size() - The total size of the pool
* @pool The zpool to check
--
1.9.1
--
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>
next prev parent reply other threads:[~2015-09-26 8:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-26 8:04 [PATCHv2 0/3] align zpool/zbud/zsmalloc on the api Vitaly Wool
2015-09-26 8:05 ` Vitaly Wool [this message]
2015-09-26 8:07 ` [PATCHv2 2/3] zbud: add compaction callbacks Vitaly Wool
2015-09-26 8:09 ` [PATCHv2 3/3] zsmalloc: " Vitaly Wool
2015-09-30 8:03 ` [PATCHv2 0/3] align zpool/zbud/zsmalloc on the api Minchan Kim
2015-10-09 12:36 ` Dan Streetman
2015-10-14 1:27 ` Sergey Senozhatsky
-- strict thread matches above, loose matches on Subject: below --
2019-12-19 14:19 [PATCHv2 0/3] Allow ZRAM to use any zpool-compatible backend Vitaly Wool
2019-12-19 14:21 ` [PATCHv2 1/3] zpool: add compaction api Vitaly Wool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150926100551.6c16d0ea3bb7758849150a0a@gmail.com \
--to=vitalywool@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=sjennings@variantweb.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).