From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753171AbbKXGMA (ORCPT ); Tue, 24 Nov 2015 01:12:00 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36625 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbbKXGL7 (ORCPT ); Tue, 24 Nov 2015 01:11:59 -0500 Date: Tue, 24 Nov 2015 15:12:58 +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: <20151124061258.GJ705@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448337696-10689-1-git-send-email-minchan@kernel.org> 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 [..] > 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 zstrm->zstrm->private = comp->backend->create(); ^^^ kzalloc() and vmalloc() fallback ?? zstrm->buffer = (void *)__get_free_pages(GFP_NOIO | __GFP_ZERO, 1); ^^^ can fail here again. can you please comment on this? and I'd prefer it to be a bit different -- use likely path first and avoid an assignment in unlikely path. ... and add GFP_NOIO to both kzalloc() and __vmalloc(). and there is no __GFP_HIGHMEM in __vmalloc() call? something like this: --- ret = kzalloc(LZ4_MEM_COMPRESS, GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC); if (ret) return ret; return __vmalloc(LZ4_MEM_COMPRESS, GFP_NOIO | __GFP_NOWARN | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); -ss