mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>,
	linux-kernel@vger.kernel.org, sergey.senozhatsky.work@gmail.com
Subject: Re: [PATCH] zram/zcomp: use GFP_NOIO to allocate streams
Date: Mon, 23 Nov 2015 15:18:12 -0800	[thread overview]
Message-ID: <20151123151812.a335f9a52abd74d7017ecd85@linux-foundation.org> (raw)
In-Reply-To: <1448285279-4013-1-git-send-email-sergey.senozhatsky@gmail.com>

On Mon, 23 Nov 2015 22:27:59 +0900 Sergey Senozhatsky <sergey.senozhatsky@gmail.com> wrote:

> We can end up allocating a new compression stream with GFP_KERNEL
> from within the IO path, which may result is nested (recursive) IO
> operations. That can introduce problems if the IO path in question
> is a reclaimer, holding some locks that will deadlock nested IOs.
> 
> Allocate streams and working memory using GFP_NOIO flag, forbidding
> recursive IO and FS operations.
> 
> ...
>
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -76,7 +76,7 @@ static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
>   */
>  static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
>  {
> -	struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_KERNEL);
> +	struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_NOIO);
>  	if (!zstrm)
>  		return NULL;
>  
> @@ -85,7 +85,7 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
>  	 * allocate 2 pages. 1 for compressed data, plus 1 extra for the
>  	 * case when compressed size is larger than the original one
>  	 */
> -	zstrm->buffer = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
> +	zstrm->buffer = (void *)__get_free_pages(GFP_NOIO | __GFP_ZERO, 1);

OK.

> --- a/drivers/block/zram/zcomp_lz4.c
> +++ b/drivers/block/zram/zcomp_lz4.c
> @@ -20,10 +20,13 @@ static void *zcomp_lz4_create(void)
>  	void *ret;
>  
>  	ret = kzalloc(LZ4_MEM_COMPRESS,
> -			__GFP_NORETRY|__GFP_NOWARN|__GFP_NOMEMALLOC);
> -	if (!ret)
> -		ret = vzalloc(LZ4_MEM_COMPRESS);
> -	return ret;
> +			__GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC);

But here we've still lost __GFP_RECLAIM, unnecessarily.  And it's quite
unclear why __GFP_NORETRY and __GFP_NOMEMALLOC are being used.

IOW, why not simply use (GFP_NOIO|__GFP_NOWARN)?



  reply	other threads:[~2015-11-23 23:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 13:27 Sergey Senozhatsky
2015-11-23 23:18 ` Andrew Morton [this message]
2015-11-24  0:30   ` Sergey Senozhatsky
2015-11-24  0:47     ` Andrew Morton
2015-11-24  1:29       ` Sergey Senozhatsky
2015-11-24  4:13         ` Minchan Kim
2015-11-24  4:41           ` Sergey Senozhatsky
2015-11-23 23:23 ` Minchan Kim

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=20151123151812.a335f9a52abd74d7017ecd85@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=sergey.senozhatsky.work@gmail.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

all inboxes | Powered by JetHome®