public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH] zram: move comp allocation out of init_lock
Date: Thu, 6 Mar 2014 17:26:53 +0900	[thread overview]
Message-ID: <20140306082653.GC14287@bbox> (raw)
In-Reply-To: <1393927856-23434-1-git-send-email-sergey.senozhatsky@gmail.com>

Hello Sergey,

On Tue, Mar 04, 2014 at 01:10:56PM +0300, Sergey Senozhatsky wrote:
> While fixing lockdep spew of ->init_lock reported by Sasha Levin [1], Minchan
> Kim noted [2] that it's better to move compression backend allocation (using
> GPF_KERNEL) out of the ->init_lock lock, same way as with zram_meta_alloc(),
> in order to prevent the same lockdep spew.
> 
> [1] https://lkml.org/lkml/2014/2/27/337
> [2] https://lkml.org/lkml/2014/3/3/32
> 
> Cc: Sasha Levin <sasha.levin@oracle.com>
> Reported-by: Minchan Kim <minchan@kernel.org>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

Thanks for looking.

> ---
>  drivers/block/zram/zram_drv.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 15d46f2..e4d536b 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -580,9 +580,10 @@ static ssize_t disksize_store(struct device *dev,
>  		struct device_attribute *attr, const char *buf, size_t len)
>  {
>  	u64 disksize;
> +	struct zcomp *comp;
>  	struct zram_meta *meta;
>  	struct zram *zram = dev_to_zram(dev);
> -	int err;
> +	int err = -EINVAL;
>  
>  	disksize = memparse(buf, NULL);
>  	if (!disksize)
> @@ -593,30 +594,32 @@ static ssize_t disksize_store(struct device *dev,
>  	if (!meta)
>  		return -ENOMEM;
>  
> +	comp = zcomp_create(zram->compressor, zram->max_comp_streams);
> +	if (!comp) {
> +		pr_info("Cannot initialise %s compressing backend\n",
> +				zram->compressor);

-ENOMEM?

Otherwise,
Acked-by: Minchan Kim <minchan@kernel.org>


> +		goto out_cleanup;
> +	}
> +
>  	down_write(&zram->init_lock);
>  	if (init_done(zram)) {
> +		up_write(&zram->init_lock);
>  		pr_info("Cannot change disksize for initialized device\n");
>  		err = -EBUSY;
> -		goto out_free_meta;
> -	}
> -
> -	zram->comp = zcomp_create(zram->compressor, zram->max_comp_streams);
> -	if (!zram->comp) {
> -		pr_info("Cannot initialise %s compressing backend\n",
> -				zram->compressor);
> -		err = -EINVAL;
> -		goto out_free_meta;
> +		goto out_cleanup;
>  	}
>  
>  	zram->meta = meta;
> +	zram->comp = comp;
>  	zram->disksize = disksize;
>  	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
>  	up_write(&zram->init_lock);
>  
>  	return len;
>  
> -out_free_meta:
> -	up_write(&zram->init_lock);
> +out_cleanup:
> +	if (comp)
> +		zcomp_destroy(comp);
>  	zram_meta_free(meta);
>  	return err;
>  }
> -- 
> 1.9.0.382.g7f3562c
> 
> --
> 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

  parent reply	other threads:[~2014-03-06  8:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 10:10 [PATCH] zram: move comp allocation out of init_lock Sergey Senozhatsky
2014-03-05 14:57 ` Jerome Marchand
2014-03-05 19:20   ` Sergey Senozhatsky
2014-03-06  8:26 ` Minchan Kim [this message]
2014-03-06 11:31   ` 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=20140306082653.GC14287@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=sasha.levin@oracle.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox