[PATCHv2 1/3] zpool: add compaction api
From: Vitaly Wool <hidden>
Date: 2015-09-26 08:06:08
Also in:
lkml
Subsystem:
memory management, the rest · Maintainers:
Andrew Morton, Linus Torvalds
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 <redacted> --- 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>