From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754376AbbKWXSP (ORCPT ); Mon, 23 Nov 2015 18:18:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56979 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753500AbbKWXSN (ORCPT ); Mon, 23 Nov 2015 18:18:13 -0500 Date: Mon, 23 Nov 2015 15:18:12 -0800 From: Andrew Morton To: Sergey Senozhatsky Cc: Minchan Kim , linux-kernel@vger.kernel.org, sergey.senozhatsky.work@gmail.com Subject: Re: [PATCH] zram/zcomp: use GFP_NOIO to allocate streams Message-Id: <20151123151812.a335f9a52abd74d7017ecd85@linux-foundation.org> In-Reply-To: <1448285279-4013-1-git-send-email-sergey.senozhatsky@gmail.com> References: <1448285279-4013-1-git-send-email-sergey.senozhatsky@gmail.com> 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 Mon, 23 Nov 2015 22:27:59 +0900 Sergey Senozhatsky 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)?