Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276092

Re: [PATCH 2/3] zram: try vmalloc() after kmalloc()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Minchan Kim <minchan@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] zram: try vmalloc() after kmalloc()
Date Tue, 24 Nov 2015 08:10:01 +0100
Message-ID <qyfTH-4UT-1@gated-at.bofh.it> (permalink)
References <qyd5v-33y-3@gated-at.bofh.it> <qyf7k-4lL-3@gated-at.bofh.it> <qyfAl-4yw-7@gated-at.bofh.it>
X-Original-To Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=ADq1Z2b+RUvVKhtH7n5yFvdVGaRQOal+0AuvVEVpktM=; b=Xnf6kJ0rzQCYMvFJWRyE2Ws3wcN4yMRma5N95OSZ0HH0D6Ekmq0Zcm2mU+6bLUQ0BW t3BZcy55/FN0JReqwoaX28Gj5fiyk/GgKasb1m2AmaCf6My5DmGp+cGOswvgLlLC7yNQ tf/Lzc1lYE4m6Y/BVJ3VhGf0LFdbNnf928OJZDO1LYRw3qTYnyHjPctIiYFLesbfxQuF sRnetFy5w3bPEL6ACNxGjBkgxKFyMsBdN6cy/ZQR99QlaMYFOfv1+kfEzQ/NmyBNyTMt 48OiCn4ZMUGkrBfK36UWATnIbWNljujWcT89Jw0EP09wuUVsg7Y9Ovu/oyrOxaIGz6nf Hu+g==
X-Received by 10.68.69.111 with SMTP id d15mr31690992pbu.104.1448348902004; Mon, 23 Nov 2015 23:08:22 -0800 (PST)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 119
Organization linux.* mail to news gateway
X-Original-Cc Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, Kyeongdon Kim <kyeongdon.kim@lge.com>, Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
X-Original-Date Tue, 24 Nov 2015 16:08:14 +0900
X-Original-Message-ID <20151124070814.GC7708@blaptop>
X-Original-References <1448337696-10689-1-git-send-email-minchan@kernel.org> <20151124061258.GJ705@swordfish> <20151124064249.GK705@swordfish>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1276092

Show key headers only | View raw


On Tue, Nov 24, 2015 at 03:42:49PM +0900, Sergey Senozhatsky wrote:
> On (11/24/15 15:12), Sergey Senozhatsky wrote:
> > [..]
> > >  static void *zcomp_lz4_create(void)
> > >  {
> > > -       return kzalloc(LZ4_MEM_COMPRESS, GFP_KERNEL);
> > > +       void *ret;
> > > +
> > > +       /*
> > > +        * This function could be called in swapout/fs write path
> > > +        * so we couldn't use GFP_FS|IO. And it assumes we already
> > > +        * have at least one stream in zram initialization so we
> > > +        * don't do best effort to allocate more stream in here.
> > > +        * A default stream will work well without further multiple
> > > +        * stream. That's why we use  __GFP_NORETRY|NOWARN|NOMEMALLOC.
> > > +        */
> > > +       ret = kzalloc(LZ4_MEM_COMPRESS,
> > > +                       __GFP_NORETRY|__GFP_NOWARN|__GFP_NOMEMALLOC);
> > > +       if (!ret)
> > > +               ret = __vmalloc(LZ4_MEM_COMPRESS,
> > > +                                       __GFP_NORETRY|__GFP_NOWARN|
> > > +                                       __GFP_NOMEMALLOC|__GFP_ZERO,
> > > +                                       PAGE_KERNEL);
> > > +       return ret;
> > >  }
> > [..]
> > 
> > so this change is still questionable. is there a real value in having
> > a vmalloc() fallback in the middle of allocations sequence:
> > 
> > 	zstrm = kmalloc(sizeof(*zstrm), GFP_NOIO);
> > 		^^^ ok, can fail here
> > 
> 
> oh, and by the way, we still can get a warning from this guy. so NOWARN in
> ->create() only is not enough, should be propogated to zstrm alloc too.
> so is __get_free_pages() (that was not in the original patch).
> 
> so pass nowarn everywhere.
> 
> perhaps something like (__GFP_NORETRY... hm...):

Yep. zcomp_strm_alloc has several allocation side and they have used
different flags so in our discussion, there are a few time mistakes to
miss so I want to pass gfp_t from client to zcomp_strm_alloc and
all of allocation sites in zcomp_strm_alloc use the flag consistenly
like my [3/3].

Thanks.

> 
> ---
> 
>  drivers/block/zram/zcomp.c     | 6 ++++--
>  drivers/block/zram/zcomp_lz4.c | 3 ++-
>  drivers/block/zram/zcomp_lzo.c | 3 ++-
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> index c536177..c0d02d5 100644
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -76,7 +76,8 @@ 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_NOIO);
> +	struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_NOIO |
> +			__GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC);
>  	if (!zstrm)
>  		return NULL;
>  
> @@ -85,7 +86,8 @@ 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_NOIO | __GFP_ZERO, 1);
> +	zstrm->buffer = (void *)__get_free_pages(GFP_NOIO | __GFP_NOWARN |
> +			__GFP_ZERO, 1);
>  	if (!zstrm->private || !zstrm->buffer) {
>  		zcomp_strm_free(comp, zstrm);
>  		zstrm = NULL;
> diff --git a/drivers/block/zram/zcomp_lz4.c b/drivers/block/zram/zcomp_lz4.c
> index ee44b51..dbeee93 100644
> --- a/drivers/block/zram/zcomp_lz4.c
> +++ b/drivers/block/zram/zcomp_lz4.c
> @@ -15,7 +15,8 @@
>  
>  static void *zcomp_lz4_create(void)
>  {
> -	return kzalloc(LZ4_MEM_COMPRESS, GFP_NOIO);
> +	return kzalloc(LZ4_MEM_COMPRESS, GFP_NOIO | __GFP_NORETRY |
> +			__GFP_NOWARN | __GFP_NOMEMALLOC);
>  }
>  
>  static void zcomp_lz4_destroy(void *private)
> diff --git a/drivers/block/zram/zcomp_lzo.c b/drivers/block/zram/zcomp_lzo.c
> index 683ce04..19c0857 100644
> --- a/drivers/block/zram/zcomp_lzo.c
> +++ b/drivers/block/zram/zcomp_lzo.c
> @@ -15,7 +15,8 @@
>  
>  static void *lzo_create(void)
>  {
> -	return kzalloc(LZO1X_MEM_COMPRESS, GFP_NOIO);
> +	return kzalloc(LZO1X_MEM_COMPRESS, GFP_NOIO | __GFP_NORETRY |
> +			__GFP_NOWARN | __GFP_NOMEMALLOC);
>  }
>  
>  static void lzo_destroy(void *private)

-- 
Kind regards,
Minchan Kim
--
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/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] zram/zcomp: use GFP_NOIO to allocate streams Minchan Kim <minchan@kernel.org> - 2015-11-24 05:10 +0100
  [RFC 3/3] zram: pass gfp from zcomp frontend to backend Minchan Kim <minchan@kernel.org> - 2015-11-24 05:10 +0100
  [PATCH 2/3] zram: try vmalloc() after kmalloc() Minchan Kim <minchan@kernel.org> - 2015-11-24 05:10 +0100
  Re: [PATCH 1/3] zram/zcomp: use GFP_NOIO to allocate streams Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-24 07:00 +0100
    Re: [PATCH 1/3] zram/zcomp: use GFP_NOIO to allocate streams Minchan Kim <minchan@kernel.org> - 2015-11-24 08:20 +0100
  Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-24 07:20 +0100
    Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-24 07:50 +0100
      Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Minchan Kim <minchan@kernel.org> - 2015-11-24 08:10 +0100
    Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Minchan Kim <minchan@kernel.org> - 2015-11-24 08:10 +0100
      Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-24 08:40 +0100
        Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Minchan Kim <minchan@kernel.org> - 2015-11-24 09:00 +0100
          Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-24 09:10 +0100
            Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Minchan Kim <minchan@kernel.org> - 2015-11-24 09:20 +0100

csiph-web