lkml.org 
[lkml]   [2015]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 0/2] btrfs: fortification for GFP_NOFS allocations
From
Date
On 08/19/2015 08:17 PM, Chris Mason wrote:
> On Wed, Aug 19, 2015 at 02:17:39PM +0200, mhocko@kernel.org wrote:
>> Hi,
>> these two patches were sent as a part of a larger RFC which aims at
>> allowing GFP_NOFS allocations to fail to help sort out memory reclaim
>> issues bound to the current behavior
>> (http://marc.info/?l=linux-mm&m=143876830616538&w=2).
>>
>> It is clear that move to the GFP_NOFS behavior change is a long term
>> plan but these patches should be good enough even with that change in
>> place. It also seems that Chris wasn't opposed and would be willing to
>> take them http://marc.info/?l=linux-mm&m=143991792427165&w=2 so here we
>> come. I have rephrased the changeslogs to not refer to the patch which
>> changes the NOFS behavior.
>>
>> Just to clarify. These two patches allowed my particular testcase
>> (mentioned in the cover referenced above) to survive it doesn't mean
>> that the failing GFP_NOFS are OK now. I have seen some other places
>> where GFP_NOFS allocation is followed by BUG_ON(ALLOC_FAILED). I have
>> not encountered them though.
>>
>> Let me know if you would prefer other changes.
>
> My plan is to start with these two and take more as required.

I've previously noticed in __set_extent_bit() things like:

if (!prealloc && (mask & __GFP_WAIT)) {
prealloc = alloc_extent_state(mask);
BUG_ON(!prealloc);
}

and later:

prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);

which internally does:

if (!prealloc)
prealloc = alloc_extent_state(GFP_ATOMIC);

The first one could be fixable by adding __GFP_NOFAIL. In fact we've got
an internal bug report for that one already. Even without GFP_NOFS being
allowed to fail, allocation can already fail when the thread is marked
for oom kill, which is likely what happened in that case.

The second case is problematic though, because GFP_ATOMIC | __GFP_NOFAIL
is not allowed. GFP_ATOMIC will give you access to memory reserves,
which reduces the chance of hitting the BUG_ON(), but it's not a
bulletproof solution.

> -chris
> --
> 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/
>



\
 
 \ /
  Last update: 2015-09-09 18:41    [W:0.070 / U:3.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site