Return-Path: Received: from mx2.suse.de ([195.135.220.15]:42258 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349AbeBSOY6 (ORCPT ); Mon, 19 Feb 2018 09:24:58 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 66841AAEF for ; Mon, 19 Feb 2018 14:24:57 +0000 (UTC) Date: Mon, 19 Feb 2018 15:24:57 +0100 From: Michal Hocko To: Goldwyn Rodrigues Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: Re: [PATCH 01/10] fs: buffer - Use memalloc_nofs API to allocate pages Message-ID: <20180219142457.GO21134@dhcp22.suse.cz> References: <20180219140230.5077-1-rgoldwyn@suse.de> <20180219140230.5077-2-rgoldwyn@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180219140230.5077-2-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon 19-02-18 08:02:21, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > I am pretty sure we really need a changelog here. > Signed-off-by: Goldwyn Rodrigues > --- > fs/buffer.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/buffer.c b/fs/buffer.c > index 9a73924db22f..1787b29f3fb3 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -45,6 +45,7 @@ > #include > #include > #include > +#include > #include > > static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); > @@ -836,7 +837,8 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, > bool retry) > { > struct buffer_head *bh, *head; > - gfp_t gfp = GFP_NOFS; > + gfp_t gfp = GFP_KERNEL; > + unsigned int nofs_flags; > long offset; > > if (retry) > @@ -844,6 +846,7 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, > > head = NULL; > offset = PAGE_SIZE; > + nofs_flags = memalloc_nofs_save(); OK, so what is the actual scope here. What kind of context is recursion problematic? This is a helper function and as such it is the caller who knows the fs context. So this is quite opposite to what how the scope API should be used. It is not about pure GFP_NOFS replacement. We really want to document those scopes. > while ((offset -= size) >= 0) { > bh = alloc_buffer_head(gfp); > if (!bh) > @@ -858,11 +861,13 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, > /* Link the buffer to its page */ > set_bh_page(bh, page, offset); > } > + memalloc_nofs_restore(nofs_flags); > return head; > /* > * In case anything failed, we just free everything we got. > */ > no_grow: > + memalloc_nofs_restore(nofs_flags); > if (head) { > do { > bh = head; > -- > 2.16.1 -- Michal Hocko SUSE Labs