From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jerome Marchand <jmarchan@redhat.com>,
Nitin Gupta <ngupta@vflare.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCHv7 5/7] zram: enable multi stream compression support in zram
Date: Wed, 26 Feb 2014 13:35:45 +0900 [thread overview]
Message-ID: <20140226043545.GD4606@bbox> (raw)
In-Reply-To: <1393328073-12313-6-git-send-email-sergey.senozhatsky@gmail.com>
On Tue, Feb 25, 2014 at 02:34:31PM +0300, Sergey Senozhatsky wrote:
> 1) Introduce zram device attribute max_comp_streams to show and store
> current zcomp's max number of zcomp streams (num_strm).
>
> 2) Extend zcomp zcomp_create() with `num_strm' parameter. `num_strm'
> limits the number of zcomp_strm structs in compression backend's idle
> list (max_comp_streams).
>
> max_comp_streams used during initialisation as follows:
> -- passing to zcomp_create() num_strm equals to 1 will initialise zcomp
> using single compression stream zcomp_strm_single (mutex-based locking).
> -- passing to zcomp_create() num_strm greater than 1 will initialise zcomp
> using multi compression stream zcomp_strm_multi (spinlock-based locking).
>
> default max_comp_streams value is 1, meaning that zram with single stream
> will be initialised.
>
> Later patch will introduce configuration knob to change max_comp_streams
> on already initialised and used zcomp.
>
> iozone -t 3 -R -r 16K -s 60M -I +Z
>
> test base 1 strm (mutex) 3 strm (spinlock)
> -----------------------------------------------------------------------
> Initial write 589286.78 583518.39 718011.05
> Rewrite 604837.97 596776.38 1515125.72
> Random write 584120.11 595714.58 1388850.25
> Pwrite 535731.17 541117.38 739295.27
> Fwrite 1418083.88 1478612.72 1484927.06
>
> Usage example:
> set max_comp_streams to 4
> echo 4 > /sys/block/zram0/max_comp_streams
>
> show current max_comp_streams (default value is 1).
> cat /sys/block/zram0/max_comp_streams
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> ---
> drivers/block/zram/zcomp.c | 9 +++++++--
> drivers/block/zram/zcomp.h | 2 +-
> drivers/block/zram/zram_drv.c | 42 +++++++++++++++++++++++++++++++++++++++++-
> drivers/block/zram/zram_drv.h | 2 +-
> 4 files changed, 50 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> index 6f238f5..1bcb70e 100644
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -258,8 +258,9 @@ void zcomp_destroy(struct zcomp *comp)
> * if requested algorithm is not supported or in case
> * of init error
> */
> -struct zcomp *zcomp_create(const char *compress)
> +struct zcomp *zcomp_create(const char *compress, int num_strm)
Let's use max_strm.
> {
> + int ret;
No need.
> struct zcomp *comp;
> struct zcomp_backend *backend;
>
> @@ -272,7 +273,11 @@ struct zcomp *zcomp_create(const char *compress)
> return NULL;
>
> comp->backend = backend;
> - if (zcomp_strm_single_create(comp) != 0) {
> + if (num_strm > 1)
> + ret = zcomp_strm_multi_create(comp, num_strm);
> + else
> + ret = zcomp_strm_single_create(comp);
> + if (ret != 0) {
> zcomp_destroy(comp);
> return NULL;
> }
> diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h
> index 861e04d..5514509 100644
> --- a/drivers/block/zram/zcomp.h
> +++ b/drivers/block/zram/zcomp.h
> @@ -42,7 +42,7 @@ struct zcomp {
> void (*destroy)(struct zcomp *comp);
> };
>
> -struct zcomp *zcomp_create(const char *comp);
> +struct zcomp *zcomp_create(const char *comp, int num_strm);
> void zcomp_destroy(struct zcomp *comp);
>
> struct zcomp_strm *zcomp_strm_get(struct zcomp *comp);
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 569ff58..42b9c7f 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -108,6 +108,40 @@ static ssize_t mem_used_total_show(struct device *dev,
> return sprintf(buf, "%llu\n", val);
> }
>
> +static ssize_t max_comp_streams_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + int val;
> + struct zram *zram = dev_to_zram(dev);
> +
> + down_read(&zram->init_lock);
> + val = zram->max_comp_streams;
> + up_read(&zram->init_lock);
> +
> + return sprintf(buf, "%d\n", val);
> +}
> +
> +static ssize_t max_comp_streams_store(struct device *dev,
> + struct device_attribute *attr, const char *buf, size_t len)
> +{
> + int num;
> + struct zram *zram = dev_to_zram(dev);
> +
> + if (kstrtoint(buf, 0, &num))
> + return -EINVAL;
> + if (num < 1)
> + return -EINVAL;
> + down_write(&zram->init_lock);
> + if (init_done(zram)) {
> + up_write(&zram->init_lock);
> + pr_info("Can't set max_comp_streams for initialized device\n");
> + return -EBUSY;
> + }
> + zram->max_comp_streams = num;
> + up_write(&zram->init_lock);
> + return len;
> +}
> +
> /* flag operations needs meta->tb_lock */
> static int zram_test_flag(struct zram_meta *meta, u32 index,
> enum zram_pageflags flag)
> @@ -502,6 +536,8 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
> }
>
> zcomp_destroy(zram->comp);
> + zram->max_comp_streams = 1;
> +
> zram_meta_free(zram->meta);
> zram->meta = NULL;
> /* Reset stats */
> @@ -530,7 +566,7 @@ static ssize_t disksize_store(struct device *dev,
> return -EBUSY;
> }
>
> - zram->comp = zcomp_create(default_compressor);
> + zram->comp = zcomp_create(default_compressor, zram->max_comp_streams);
> if (!zram->comp) {
> up_write(&zram->init_lock);
> pr_info("Cannot initialise %s compressing backend\n",
> @@ -693,6 +729,8 @@ static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL);
> static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store);
> static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL);
> static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL);
> +static DEVICE_ATTR(max_comp_streams, S_IRUGO | S_IWUSR,
> + max_comp_streams_show, max_comp_streams_store);
>
> ZRAM_ATTR_RO(num_reads);
> ZRAM_ATTR_RO(num_writes);
> @@ -717,6 +755,7 @@ static struct attribute *zram_disk_attrs[] = {
> &dev_attr_orig_data_size.attr,
> &dev_attr_compr_data_size.attr,
> &dev_attr_mem_used_total.attr,
> + &dev_attr_max_comp_streams.attr,
> NULL,
> };
>
> @@ -779,6 +818,7 @@ static int create_device(struct zram *zram, int device_id)
> }
>
> zram->meta = NULL;
> + zram->max_comp_streams = 1;
> return 0;
>
> out_free_disk:
> diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
> index 45e04f7..ccf36d1 100644
> --- a/drivers/block/zram/zram_drv.h
> +++ b/drivers/block/zram/zram_drv.h
> @@ -99,7 +99,7 @@ struct zram {
> * we can store in a disk.
> */
> u64 disksize; /* bytes */
> -
> + int max_comp_streams;
> struct zram_stats stats;
> };
> #endif
> --
> 1.9.0.291.g027825b
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Kind regards,
Minchan Kim
next prev parent reply other threads:[~2014-02-26 4:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-25 11:34 [PATCHv7 0/7] add compressing abstraction and multi stream support Sergey Senozhatsky
2014-02-25 11:34 ` [PATCHv7 1/7] zram: introduce compressing backend abstraction Sergey Senozhatsky
2014-02-25 11:34 ` [PATCHv7 2/7] zram: use zcomp compressing backends Sergey Senozhatsky
2014-02-25 11:34 ` [PATCHv7 3/7] zram: factor out single stream compression Sergey Senozhatsky
2014-02-26 4:34 ` Minchan Kim
2014-02-26 11:32 ` Sergey Senozhatsky
2014-02-25 11:34 ` [PATCHv7 4/7] zram: add multi stream functionality Sergey Senozhatsky
2014-02-26 4:35 ` Minchan Kim
2014-02-25 11:34 ` [PATCHv7 5/7] zram: enable multi stream compression support in zram Sergey Senozhatsky
2014-02-26 4:35 ` Minchan Kim [this message]
2014-02-25 11:34 ` [PATCHv7 6/7] zram: add set_max_streams knob Sergey Senozhatsky
2014-02-26 4:35 ` Minchan Kim
2014-02-25 11:34 ` [PATCHv7 7/7] zram: document max_comp_streams Sergey Senozhatsky
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=20140226043545.GD4606@bbox \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=jmarchan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ngupta@vflare.org \
--cc=sergey.senozhatsky@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.