linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Horner <ds2horner@gmail.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linux-MM <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Jerome Marchand <jmarchan@redhat.com>,
	juno.choi@lge.com, seungho1.park@lge.com,
	Luigi Semenzato <semenzato@google.com>,
	Nitin Gupta <ngupta@vflare.org>,
	Seth Jennings <sjennings@variantweb.net>,
	Dan Streetman <ddstreet@ieee.org>
Subject: Re: [PATCH v5 2/4] zsmalloc: change return value unit of zs_get_total_size_bytes
Date: Mon, 25 Aug 2014 00:08:51 -0400	[thread overview]
Message-ID: <CAFdhcLR=Hfvpq5rCozAbym8uhxE1sOyuDz0J1NOzyaURUoY2qw@mail.gmail.com> (raw)
In-Reply-To: <1408925156-11733-3-git-send-email-minchan@kernel.org>

On Sun, Aug 24, 2014 at 8:05 PM, Minchan Kim <minchan@kernel.org> wrote:
> zs_get_total_size_bytes returns a amount of memory zsmalloc
> consumed with *byte unit* but zsmalloc operates *page unit*
> rather than byte unit so let's change the API so benefit
> we could get is that reduce unnecessary overhead
> (ie, change page unit with byte unit) in zsmalloc.
>
> Since return type is pages, "zs_get_total_pages" is better than
> "zs_get_total_size_bytes".
>
> Reviewed-by: Dan Streetman <ddstreet@ieee.org>
Reviewed-by: David Horner <ds2horner@gmail.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
>  drivers/block/zram/zram_drv.c | 4 ++--
>  include/linux/zsmalloc.h      | 2 +-
>  mm/zsmalloc.c                 | 9 ++++-----
>  3 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index d00831c3d731..f0b8b30a7128 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -103,10 +103,10 @@ static ssize_t mem_used_total_show(struct device *dev,
>
>         down_read(&zram->init_lock);
>         if (init_done(zram))
> -               val = zs_get_total_size_bytes(meta->mem_pool);
> +               val = zs_get_total_pages(meta->mem_pool);
>         up_read(&zram->init_lock);
>
> -       return scnprintf(buf, PAGE_SIZE, "%llu\n", val);
> +       return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT);
>  }
>
>  static ssize_t max_comp_streams_show(struct device *dev,
> diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h
> index e44d634e7fb7..05c214760977 100644
> --- a/include/linux/zsmalloc.h
> +++ b/include/linux/zsmalloc.h
> @@ -46,6 +46,6 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
>                         enum zs_mapmode mm);
>  void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
>
> -u64 zs_get_total_size_bytes(struct zs_pool *pool);
> +unsigned long zs_get_total_pages(struct zs_pool *pool);
>
>  #endif
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 2a4acf400846..c4a91578dc96 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -297,7 +297,7 @@ static void zs_zpool_unmap(void *pool, unsigned long handle)
>
>  static u64 zs_zpool_total_size(void *pool)
>  {
> -       return zs_get_total_size_bytes(pool);
> +       return zs_get_total_pages(pool) << PAGE_SHIFT;
>  }
>
>  static struct zpool_driver zs_zpool_driver = {
> @@ -1181,12 +1181,11 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle)
>  }
>  EXPORT_SYMBOL_GPL(zs_unmap_object);
>
> -u64 zs_get_total_size_bytes(struct zs_pool *pool)
> +unsigned long zs_get_total_pages(struct zs_pool *pool)
>  {
> -       u64 npages = atomic_long_read(&pool->pages_allocated);
> -       return npages << PAGE_SHIFT;
> +       return atomic_long_read(&pool->pages_allocated);
>  }
> -EXPORT_SYMBOL_GPL(zs_get_total_size_bytes);
> +EXPORT_SYMBOL_GPL(zs_get_total_pages);
>
>  module_init(zs_init);
>  module_exit(zs_exit);
> --
> 2.0.0
>

--
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>

  reply	other threads:[~2014-08-25  4:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25  0:05 [PATCH v5 0/4] zram memory control enhance Minchan Kim
2014-08-25  0:05 ` [PATCH v5 1/4] zsmalloc: move pages_allocated to zs_pool Minchan Kim
2014-08-25  0:05 ` [PATCH v5 2/4] zsmalloc: change return value unit of zs_get_total_size_bytes Minchan Kim
2014-08-25  4:08   ` David Horner [this message]
2014-08-25  0:05 ` [PATCH v5 3/4] zram: zram memory size limitation Minchan Kim
2014-08-25 11:09   ` Sergey Senozhatsky
2014-08-26  4:52     ` Minchan Kim
2014-08-26  7:37   ` Joonsoo Kim
2014-08-26  7:55     ` Minchan Kim
2014-08-26 12:22       ` David Horner
2014-08-27  1:26         ` Joonsoo Kim
2014-08-27  2:51           ` Minchan Kim
2014-08-27  5:04             ` Joonsoo Kim
2014-08-27  7:28               ` Minchan Kim
2014-08-28  8:21                 ` Joonsoo Kim
2014-08-27 14:03             ` Dan Streetman
2014-08-27 14:44               ` David Horner
2014-08-27 15:14                 ` Dan Streetman
2014-08-27 15:35                   ` David Horner
2014-08-27 16:29                     ` Dan Streetman
2014-08-27 16:59                       ` David Horner
2014-08-27 19:04                         ` Dan Streetman
2014-08-28  3:04                           ` Minchan Kim
2014-08-28  2:59                       ` Minchan Kim
2014-08-28  2:52               ` Minchan Kim
2014-08-25  0:05 ` [PATCH v5 4/4] zram: report maximum used memory Minchan Kim
2014-08-25  4:05   ` David Horner

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='CAFdhcLR=Hfvpq5rCozAbym8uhxE1sOyuDz0J1NOzyaURUoY2qw@mail.gmail.com' \
    --to=ds2horner@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ddstreet@ieee.org \
    --cc=jmarchan@redhat.com \
    --cc=juno.choi@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=semenzato@google.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=seungho1.park@lge.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