From: Dan Streetman <ddstreet@ieee.org>
To: Vitaly Wool <vitalywool@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Vlastimil Babka <vbabka@suse.cz>,
Shakeel Butt <shakeelb@google.com>,
Henry Burns <henrywolfeburns@gmail.com>,
"Theodore Ts'o" <tytso@thunk.org>
Subject: Re: [PATCH 1/3] zpool: extend API to match zsmalloc
Date: Fri, 18 Oct 2019 07:23:57 -0400 [thread overview]
Message-ID: <CALZtONAuO4FfM6z19qRCW8x9PvjocN-RT=0cJ7eRaH3kXDJqrg@mail.gmail.com> (raw)
In-Reply-To: <20191010230915.f68401e9c9e0fa053dcbe199@gmail.com>
On Thu, Oct 10, 2019 at 4:09 PM Vitaly Wool <vitalywool@gmail.com> wrote:
>
> This patch adds the following functions to the zpool API:
> - zpool_compact()
> - zpool_get_num_compacted()
> - zpool_huge_class_size()
>
> The first one triggers compaction for the underlying allocator, the
> second retrieves the number of pages migrated due to compaction for
> the whole time of this pool's existence and the third one returns
> the huge class size.
>
> This API extension is done to align zpool API with zsmalloc API.
>
> Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Seems reasonable to me.
Reviewed-by: Dan Streetman <ddstreet@ieee.org>
> ---
> include/linux/zpool.h | 14 +++++++++++++-
> mm/zpool.c | 36 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/zpool.h b/include/linux/zpool.h
> index 51bf43076165..31f0c1360569 100644
> --- a/include/linux/zpool.h
> +++ b/include/linux/zpool.h
> @@ -61,8 +61,13 @@ 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);
>
> +size_t zpool_huge_class_size(struct zpool *zpool);
>
> /**
> * struct zpool_driver - driver implementation for zpool
> @@ -75,7 +80,10 @@ u64 zpool_get_total_size(struct zpool *pool);
> * @shrink: shrink the pool.
> * @map: map a handle.
> * @unmap: unmap a handle.
> - * @total_size: get total size of a pool.
> + * @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
> + * @huge_class_size: huge class threshold for pool pages.
> *
> * This is created by a zpool implementation and registered
> * with zpool.
> @@ -104,7 +112,11 @@ 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);
> + size_t (*huge_class_size)(void *pool);
> };
>
> void zpool_register_driver(struct zpool_driver *driver);
> diff --git a/mm/zpool.c b/mm/zpool.c
> index 863669212070..55e69213c2eb 100644
> --- a/mm/zpool.c
> +++ b/mm/zpool.c
> @@ -362,6 +362,30 @@ 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->driver->compact(zpool->pool) : 0;
> +}
> +
> +
> +/**
> + * zpool_get_num_compacted() - get the number of migrated/compacted pages
> + * @pool The zpool to get compaction statistic for
> + *
> + * Returns: the total number of migrated pages for the pool
> + */
> +unsigned long zpool_get_num_compacted(struct zpool *zpool)
> +{
> + return zpool->driver->get_num_compacted ?
> + zpool->driver->get_num_compacted(zpool->pool) : 0;
> +}
> +
> /**
> * zpool_get_total_size() - The total size of the pool
> * @zpool: The zpool to check
> @@ -375,6 +399,18 @@ u64 zpool_get_total_size(struct zpool *zpool)
> return zpool->driver->total_size(zpool->pool);
> }
>
> +/**
> + * zpool_huge_class_size() - get size for the "huge" class
> + * @pool The zpool to check
> + *
> + * Returns: size of the huge class
> + */
> +size_t zpool_huge_class_size(struct zpool *zpool)
> +{
> + return zpool->driver->huge_class_size ?
> + zpool->driver->huge_class_size(zpool->pool) : 0;
> +}
> +
> /**
> * zpool_evictable() - Test if zpool is potentially evictable
> * @zpool: The zpool to test
> --
> 2.20.1
next prev parent reply other threads:[~2019-10-18 11:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 20:04 [PATCH 0/3] Allow ZRAM to use any zpool-compatible backend Vitaly Wool
2019-10-10 20:09 ` [PATCH 1/3] zpool: extend API to match zsmalloc Vitaly Wool
2019-10-18 11:23 ` Dan Streetman [this message]
2019-10-10 20:11 ` [PATCH 2/3] zsmalloc: add compaction and huge class callbacks Vitaly Wool
2019-10-14 10:38 ` Sergey Senozhatsky
2019-10-10 20:20 ` [PATCH 3/3] zram: use common zpool interface Vitaly Wool
2019-10-14 10:47 ` Sergey Senozhatsky
2019-10-14 11:52 ` Vitaly Wool
2019-10-15 2:04 ` Sergey Senozhatsky
2019-10-14 10:33 ` [PATCH 0/3] Allow ZRAM to use any zpool-compatible backend Sergey Senozhatsky
2019-10-14 11:49 ` Vitaly Wool
2019-10-14 16:41 ` Minchan Kim
2019-10-15 7:39 ` Vitaly Wool
2019-10-15 20:00 ` Minchan Kim
2019-10-21 14:21 ` Vitaly Wool
2019-10-30 0:10 ` Minchan Kim
2019-11-13 15:54 ` 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='CALZtONAuO4FfM6z19qRCW8x9PvjocN-RT=0cJ7eRaH3kXDJqrg@mail.gmail.com' \
--to=ddstreet@ieee.org \
--cc=akpm@linux-foundation.org \
--cc=henrywolfeburns@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=shakeelb@google.com \
--cc=tytso@thunk.org \
--cc=vbabka@suse.cz \
--cc=vitalywool@gmail.com \
/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).