From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752317AbbKXGlv (ORCPT ); Tue, 24 Nov 2015 01:41:51 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34675 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbbKXGlu (ORCPT ); Tue, 24 Nov 2015 01:41:50 -0500 Date: Tue, 24 Nov 2015 15:42:49 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Andrew Morton , linux-kernel@vger.kernel.org, Kyeongdon Kim , Sergey Senozhatsky , Sergey Senozhatsky Subject: Re: [PATCH 2/3] zram: try vmalloc() after kmalloc() Message-ID: <20151124064249.GK705@swordfish> References: <1448337696-10689-1-git-send-email-minchan@kernel.org> <20151124061258.GJ705@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151124061258.GJ705@swordfish> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...): --- 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)