Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933441AbbHXJcY (ORCPT ); Mon, 24 Aug 2015 05:32:24 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:43762 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754185AbbHXJcT (ORCPT ); Mon, 24 Aug 2015 05:32:19 -0400 X-AuditID: cbfee61a-f79a06d000005c6f-d3-55dae4a00eff From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <1439593751-21879-1-git-send-email-jaegeuk@kernel.org> <01b801d0db27$e8b9e9d0$ba2dbd70$@samsung.com> <20150820155727.GB42028@jaegeuk-mac02.mot-mobility.com> <021601d0dc10$003a90d0$00afb270$@samsung.com> <20150824045337.GA2837@jaegeuk-mac02.mot-mobility.com> In-reply-to: <20150824045337.GA2837@jaegeuk-mac02.mot-mobility.com> Subject: RE: [f2fs-dev] [PATCH 1/2] f2fs: handle failed bio allocation Date: Mon, 24 Aug 2015 17:31:30 +0800 Message-id: <001601d0de4f$c3ac5c60$4b051520$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQFaoAjn54AsIe0uJja8pok+3EhfDgJWNZZVAYD6ZX4DAPXwJgJoLiOvnr1adZA= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRmVeSWpSXmKPExsVy+t9jQd0FT26FGtxYYGHxZP0sZotLi9wt 9uw9yWJxedccNgcWj02rOtk8di/4zOTxeZNcAHMUl01Kak5mWWqRvl0CV8brbTOYCw7JVVxf dYexgfGreBcjJ4eEgInErp1nmSFsMYkL99azdTFycQgJzGKUOL9zDQuE84pR4s/jg+wgVWwC KhLLO/4zgdgiAmoSvfumgNnMApkSE/pfsEM0TGWSONBwAWgsBwengLPE/w96IDXCAm4SL1pO sIHYLAKqElc//wSbyStgKbHv53ZmCFtQ4sfkeywQM7Uk1u88DjVfXmLzmrdQlypI7Dj7mhHi Bj+JPQebWSFqxCU2HrnFMoFRaBaSUbOQjJqFZNQsJC0LGFlWMUqkFiQXFCel5xrmpZbrFSfm Fpfmpesl5+duYgRHwDOpHYwHd7kfYhTgYFTi4WWwvBUqxJpYVlyZe4hRgoNZSYRX6eXNUCHe lMTKqtSi/Pii0pzU4kOM0hwsSuK8shs2hwoJpCeWpGanphakFsFkmTg4pRoYLQsnXts4bePV 24lzXG7teX/60vTWL4zLj75sfLz5BtuXFS3/+nbzTAp/FJi01zhrfZveeZYtmvn/z0/uUFV0 uf1uiZS6+eYsxbWFdzleuU0SPuA097fygxyXAJVt0pMOvJ20bF/LvMTpzUrdyo86c+bKKwS2 6jGU1TvsTV7ELmbgoP2kLfW4gRJLcUaioRZzUXEiANFjq8l8AgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4045 Lines: 111 Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Monday, August 24, 2015 12:54 PM > To: Chao Yu > Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: handle failed bio allocation > > Hi Chao, > > [snip] > > > > > > > > > > > - /* No failure on bio allocation */ > > > > > - bio = bio_alloc(GFP_NOIO, npages); > > > > > > > > How about using __GFP_NOFAIL flag to avoid failing in bio_alloc instead > > > > of adding opencode endless loop in code? > > > > > > > > We can see the reason in this commit 647757197cd3 > > > > ("mm: clarify __GFP_NOFAIL deprecation status ") > > > > > > > > "__GFP_NOFAIL is documented as a deprecated flag since commit > > > > 478352e789f5 ("mm: add comment about deprecation of __GFP_NOFAIL"). > > > > > > > > This has discouraged people from using it but in some cases an opencoded > > > > endless loop around allocator has been used instead. So the allocator > > > > is not aware of the de facto __GFP_NOFAIL allocation because this > > > > information was not communicated properly. > > > > > > > > Let's make clear that if the allocation context really cannot afford > > > > failure because there is no good failure policy then using __GFP_NOFAIL > > > > is preferable to opencoding the loop outside of the allocator." > > > > > > > > BTW, I found that f2fs_kmem_cache_alloc also could be replaced, we could > > > > fix them together. > > > > > > Agreed. I think that can be another patch like this. > > > > > > From 1579e0d1ada96994c4ec6619fb5b5d9386e77ab3 Mon Sep 17 00:00:00 2001 > > > From: Jaegeuk Kim > > > Date: Thu, 20 Aug 2015 08:51:56 -0700 > > > Subject: [PATCH] f2fs: use __GFP_NOFAIL to avoid infinite loop > > > > > > __GFP_NOFAIL can avoid retrying the whole path of kmem_cache_alloc and > > > bio_alloc. > > > > > > Suggested-by: Chao Yu > > > Signed-off-by: Jaegeuk Kim > > > --- > > > fs/f2fs/f2fs.h | 16 +++++----------- > > > 1 file changed, 5 insertions(+), 11 deletions(-) > > > > > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > > > index 00591f7..c78b599 100644 > > > --- a/fs/f2fs/f2fs.h > > > +++ b/fs/f2fs/f2fs.h > > > @@ -1244,13 +1244,10 @@ static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep, > > > gfp_t flags) > > > { > > > void *entry; > > > -retry: > > > - entry = kmem_cache_alloc(cachep, flags); > > > - if (!entry) { > > > - cond_resched(); > > > - goto retry; > > > - } > > > > > > + entry = kmem_cache_alloc(cachep, flags); > > > + if (!entry) > > > + entry = kmem_cache_alloc(cachep, flags | __GFP_NOFAIL); > > > > The fast + slow path model looks good to me, expect one thing: > > In several paths of checkpoint, caller will grab slab cache with GFP_ATOMIC, > > so in slow path, our flags will be GFP_ATOMIC | __GFP_NOFAIL, I'm not sure > > that the two flags can be used together. > > > > Should we replace GFP_ATOMIC with GFP_NOFS in flags if caller passed > > GFP_ATOMIC? > > Indeed, we need to avoid GFP_ATOMIC as much as possible to mitigate memory > pressure at this moment. Too much abused. > > I wrote a patch like this. > > From a9209556d024cdce490695586ecee3164efda49c Mon Sep 17 00:00:00 2001 > From: Jaegeuk Kim > Date: Thu, 20 Aug 2015 08:51:56 -0700 > Subject: [PATCH] f2fs: use __GFP_NOFAIL to avoid infinite loop > > __GFP_NOFAIL can avoid retrying the whole path of kmem_cache_alloc and > bio_alloc. > And, it also fixes the use cases of GFP_ATOMIC correctly. Looks good to me! > > Suggested-by: Chao Yu > Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu Thanks, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/