From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752531AbbKXArn (ORCPT ); Mon, 23 Nov 2015 19:47:43 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57718 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752453AbbKXArl (ORCPT ); Mon, 23 Nov 2015 19:47:41 -0500 Date: Mon, 23 Nov 2015 16:47:40 -0800 From: Andrew Morton To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Minchan Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH] zram/zcomp: use GFP_NOIO to allocate streams Message-Id: <20151123164740.495e5067d9d45a7f98b5ace3@linux-foundation.org> In-Reply-To: <20151124003027.GA705@swordfish> References: <1448285279-4013-1-git-send-email-sergey.senozhatsky@gmail.com> <20151123151812.a335f9a52abd74d7017ecd85@linux-foundation.org> <20151124003027.GA705@swordfish> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Nov 2015 09:30:27 +0900 Sergey Senozhatsky wrote: > On (11/23/15 15:18), Andrew Morton wrote: > [..] > > > --- 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. > > __GFP_NORETRY > > we are guaranteed to have at least one compression stream, so sooner or > later every IO operation will be served. any IO that has failed in > zcomp_lz4_create() or zcomp_lzo_create() will simply wait for already > available compression stream to become idle. so this allocation is not > so dramatically important - we just increase the level of parallelism > (N idle streams let N IO operations to execute concurrently). apart from > that we are in a low memory condition (or whatever was the reason the > kernel failed to allocate LZ4_MEM_COMPRESS or LZO1X_MEM_COMPRESS) and > we can avoid pressuring the kernel furher. > > for the same reason __GFP_NOMEMALLOC is used -- we don't want to waste > an emergency memory for compression streams. > Doesn't make a lot of sense to me. We use a weakened gfp for the kmalloc and if that fails, fall into vmalloc() using the stronger gfp anyway. Perhaps it makes sense for higher-order allocations: we don't want to thrash around trying to create an order-2 page - we'd prefer to give up and fall into vmalloc to do a bunch of order-0 allocations. But this argument holds for 1000 other kmalloc->vmalloc allocation attempts - what's special about this one? And whatever is the reason for this peculiar setup, a) where's the proof that the change is actually beneficial? b) let's get a good code comment in place so that future readers are not similarly puzzled.