All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lockdep: Teach lockdep about memalloc_noio_save
@ 2017-03-01  7:48 Nikolay Borisov
  2017-03-01  7:59 ` [PATCH v2] " Nikolay Borisov
  2017-03-01 10:22 ` [PATCH] " Vlastimil Babka
  0 siblings, 2 replies; 9+ messages in thread
From: Nikolay Borisov @ 2017-03-01  7:48 UTC (permalink / raw)
  To: peterz; +Cc: mingo, linux-kernel, Nikolay Borisov

Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
during memory allocation") added the memalloc_noio_(save|restore) functions
to enable people to modify the MM behavior by disbaling I/O during memory
allocation. This prevents allocation paths recursing back into the filesystem
without explicitly changing the flags for every allocation site. Yet, lockdep
not being aware of that is prone to showing false positives. Fix this
by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
going to issue any I/O

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 kernel/locking/lockdep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 9812e5dd409e..5715fdcede28 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
 		return;
 
 	/* this guy won't enter reclaim */
-	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
+	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
+			curr->flags & PF_MEMALLOC_NOIO)
 		return;
 
 	/* We're only interested __GFP_FS allocations for now */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01  7:48 [PATCH] lockdep: Teach lockdep about memalloc_noio_save Nikolay Borisov
@ 2017-03-01  7:59 ` Nikolay Borisov
  2017-03-01  9:46   ` Peter Zijlstra
  2017-03-01 10:22 ` [PATCH] " Vlastimil Babka
  1 sibling, 1 reply; 9+ messages in thread
From: Nikolay Borisov @ 2017-03-01  7:59 UTC (permalink / raw)
  To: peterz; +Cc: mingo, linux-kernel, Nikolay Borisov

Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
during memory allocation") added the memalloc_noio_(save|restore) functions
to enable people to modify the MM behavior by disbaling I/O during memory
allocation. This prevents allocation paths recursing back into the filesystem
without explicitly changing the flags for every allocation site. Yet, lockdep
not being aware of that is prone to showing false positives. Fix this
by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
going to issue any I/O

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 kernel/locking/lockdep.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


 Turned out there was another place where RELCAIM_FS was being set, fix it 
 by using the memalloc_noio_flags when setting ->lockdep_reclaim_gfp flags.

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 9812e5dd409e..87cf9910e66f 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
 		return;
 
 	/* this guy won't enter reclaim */
-	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
+	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
+			curr->flags & PF_MEMALLOC_NOIO)
 		return;
 
 	/* We're only interested __GFP_FS allocations for now */
@@ -3852,7 +3853,7 @@ EXPORT_SYMBOL_GPL(lock_unpin_lock);
 
 void lockdep_set_current_reclaim_state(gfp_t gfp_mask)
 {
-	current->lockdep_reclaim_gfp = gfp_mask;
+	current->lockdep_reclaim_gfp = memalloc_noio_flags(gfp_mask);
 }
 
 void lockdep_clear_current_reclaim_state(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01  7:59 ` [PATCH v2] " Nikolay Borisov
@ 2017-03-01  9:46   ` Peter Zijlstra
  2017-03-01  9:57     ` Nikolay Borisov
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2017-03-01  9:46 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: mingo, linux-kernel, ming.lei, minchan, mel

On Wed, Mar 01, 2017 at 09:59:00AM +0200, Nikolay Borisov wrote:
> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
> during memory allocation") added the memalloc_noio_(save|restore) functions
> to enable people to modify the MM behavior by disbaling I/O during memory
> allocation. This prevents allocation paths recursing back into the filesystem
> without explicitly changing the flags for every allocation site. Yet, lockdep
> not being aware of that is prone to showing false positives. Fix this
> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
> going to issue any I/O

I'm not up to date on the specific, but GFP_IO is separate from GFP_FS.

And MEMALLOC_NOIO only clears GFP_IO but leaves GFP_FS set.

Therefore I think your change is wrong, but I might have overlooked a
detail. Added original authors to Cc to clarify.


> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  kernel/locking/lockdep.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> 
>  Turned out there was another place where RELCAIM_FS was being set, fix it 
>  by using the memalloc_noio_flags when setting ->lockdep_reclaim_gfp flags.
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 9812e5dd409e..87cf9910e66f 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
>  		return;
>  
>  	/* this guy won't enter reclaim */
> -	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
> +	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
> +			curr->flags & PF_MEMALLOC_NOIO)
>  		return;
>  
>  	/* We're only interested __GFP_FS allocations for now */
> @@ -3852,7 +3853,7 @@ EXPORT_SYMBOL_GPL(lock_unpin_lock);
>  
>  void lockdep_set_current_reclaim_state(gfp_t gfp_mask)
>  {
> -	current->lockdep_reclaim_gfp = gfp_mask;
> +	current->lockdep_reclaim_gfp = memalloc_noio_flags(gfp_mask);
>  }
>  
>  void lockdep_clear_current_reclaim_state(void)
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01  9:46   ` Peter Zijlstra
@ 2017-03-01  9:57     ` Nikolay Borisov
  2017-03-01 10:03       ` Peter Zijlstra
  0 siblings, 1 reply; 9+ messages in thread
From: Nikolay Borisov @ 2017-03-01  9:57 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel, ming.lei, minchan, mel



On  1.03.2017 11:46, Peter Zijlstra wrote:
> On Wed, Mar 01, 2017 at 09:59:00AM +0200, Nikolay Borisov wrote:
>> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
>> during memory allocation") added the memalloc_noio_(save|restore) functions
>> to enable people to modify the MM behavior by disbaling I/O during memory
>> allocation. This prevents allocation paths recursing back into the filesystem
>> without explicitly changing the flags for every allocation site. Yet, lockdep
>> not being aware of that is prone to showing false positives. Fix this
>> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
>> going to issue any I/O
> 
> I'm not up to date on the specific, but GFP_IO is separate from GFP_FS.
> 
> And MEMALLOC_NOIO only clears GFP_IO but leaves GFP_FS set.

static inline gfp_t memalloc_noio_flags(gfp_t flags)                            
{                                                                               
    if (unlikely(current->flags & PF_MEMALLOC_NOIO))                            
        flags &= ~(__GFP_IO | __GFP_FS);                                        
    return flags;                                                               
}


> 
> Therefore I think your change is wrong, but I might have overlooked a
> detail. Added original authors to Cc to clarify.
> 
> 
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>>  kernel/locking/lockdep.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>>
>>  Turned out there was another place where RELCAIM_FS was being set, fix it 
>>  by using the memalloc_noio_flags when setting ->lockdep_reclaim_gfp flags.
>>
>> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
>> index 9812e5dd409e..87cf9910e66f 100644
>> --- a/kernel/locking/lockdep.c
>> +++ b/kernel/locking/lockdep.c
>> @@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
>>  		return;
>>  
>>  	/* this guy won't enter reclaim */
>> -	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
>> +	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
>> +			curr->flags & PF_MEMALLOC_NOIO)
>>  		return;
>>  
>>  	/* We're only interested __GFP_FS allocations for now */
>> @@ -3852,7 +3853,7 @@ EXPORT_SYMBOL_GPL(lock_unpin_lock);
>>  
>>  void lockdep_set_current_reclaim_state(gfp_t gfp_mask)
>>  {
>> -	current->lockdep_reclaim_gfp = gfp_mask;
>> +	current->lockdep_reclaim_gfp = memalloc_noio_flags(gfp_mask);
>>  }
>>  
>>  void lockdep_clear_current_reclaim_state(void)
>> -- 
>> 2.7.4
>>
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01  9:57     ` Nikolay Borisov
@ 2017-03-01 10:03       ` Peter Zijlstra
  2017-03-01 10:23         ` Vlastimil Babka
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2017-03-01 10:03 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: mingo, linux-kernel, ming.lei, minchan, mel, junxiao.bi

On Wed, Mar 01, 2017 at 11:57:13AM +0200, Nikolay Borisov wrote:
> 
> 
> On  1.03.2017 11:46, Peter Zijlstra wrote:
> > On Wed, Mar 01, 2017 at 09:59:00AM +0200, Nikolay Borisov wrote:
> >> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
> >> during memory allocation") added the memalloc_noio_(save|restore) functions
> >> to enable people to modify the MM behavior by disbaling I/O during memory
> >> allocation. This prevents allocation paths recursing back into the filesystem
> >> without explicitly changing the flags for every allocation site. Yet, lockdep
> >> not being aware of that is prone to showing false positives. Fix this
> >> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
> >> going to issue any I/O
> > 
> > I'm not up to date on the specific, but GFP_IO is separate from GFP_FS.
> > 
> > And MEMALLOC_NOIO only clears GFP_IO but leaves GFP_FS set.
> 
> static inline gfp_t memalloc_noio_flags(gfp_t flags)                            
> {                                                                               
>     if (unlikely(current->flags & PF_MEMALLOC_NOIO))                            
>         flags &= ~(__GFP_IO | __GFP_FS);                                        
>     return flags;                                                               
> }
> 

Ah, so in the initial patch you referenced there was:

+static inline gfp_t memalloc_noio_flags(gfp_t flags)
+{
+       if (unlikely(current->flags & PF_MEMALLOC_NOIO))
+               flags &= ~__GFP_IO;
+       return flags;
+}

OK, so then this commit needs something like:

Fixes: 934f3072c17c ("mm: clear __GFP_FS when PF_MEMALLOC_NOIO is set")

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01  7:48 [PATCH] lockdep: Teach lockdep about memalloc_noio_save Nikolay Borisov
  2017-03-01  7:59 ` [PATCH v2] " Nikolay Borisov
@ 2017-03-01 10:22 ` Vlastimil Babka
  2017-03-01 10:31   ` Michal Hocko
  1 sibling, 1 reply; 9+ messages in thread
From: Vlastimil Babka @ 2017-03-01 10:22 UTC (permalink / raw)
  To: Nikolay Borisov, peterz; +Cc: mingo, linux-kernel, Michal Hocko

On 03/01/2017 08:48 AM, Nikolay Borisov wrote:
> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
> during memory allocation") added the memalloc_noio_(save|restore) functions
> to enable people to modify the MM behavior by disbaling I/O during memory
> allocation. This prevents allocation paths recursing back into the filesystem
> without explicitly changing the flags for every allocation site. Yet, lockdep
> not being aware of that is prone to showing false positives. Fix this
> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
> going to issue any I/O
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  kernel/locking/lockdep.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 9812e5dd409e..5715fdcede28 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
>  		return;
>  
>  	/* this guy won't enter reclaim */
> -	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
> +	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
> +			curr->flags & PF_MEMALLOC_NOIO)

It would be slightly better to use memalloc_noio_flags() here. Michal is
planning to convert it to take also a new PF_MEMALLOC_NOFS flag into
account, and there would be less chance of forgetting to update this place.

The function uses "current" though, which __lockdep_trace_alloc()
aliases to "curr" for some reason.

>  		return;
>  
>  	/* We're only interested __GFP_FS allocations for now */
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01 10:03       ` Peter Zijlstra
@ 2017-03-01 10:23         ` Vlastimil Babka
  0 siblings, 0 replies; 9+ messages in thread
From: Vlastimil Babka @ 2017-03-01 10:23 UTC (permalink / raw)
  To: Peter Zijlstra, Nikolay Borisov
  Cc: mingo, linux-kernel, ming.lei, minchan, mel, junxiao.bi

On 03/01/2017 11:03 AM, Peter Zijlstra wrote:
> On Wed, Mar 01, 2017 at 11:57:13AM +0200, Nikolay Borisov wrote:
>>
>>
>> On  1.03.2017 11:46, Peter Zijlstra wrote:
>>> On Wed, Mar 01, 2017 at 09:59:00AM +0200, Nikolay Borisov wrote:
>>>> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
>>>> during memory allocation") added the memalloc_noio_(save|restore) functions
>>>> to enable people to modify the MM behavior by disbaling I/O during memory
>>>> allocation. This prevents allocation paths recursing back into the filesystem
>>>> without explicitly changing the flags for every allocation site. Yet, lockdep
>>>> not being aware of that is prone to showing false positives. Fix this
>>>> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
>>>> going to issue any I/O
>>>
>>> I'm not up to date on the specific, but GFP_IO is separate from GFP_FS.
>>>
>>> And MEMALLOC_NOIO only clears GFP_IO but leaves GFP_FS set.
>>
>> static inline gfp_t memalloc_noio_flags(gfp_t flags)                            
>> {                                                                               
>>     if (unlikely(current->flags & PF_MEMALLOC_NOIO))                            
>>         flags &= ~(__GFP_IO | __GFP_FS);                                        
>>     return flags;                                                               
>> }
>>
> 
> Ah, so in the initial patch you referenced there was:
> 
> +static inline gfp_t memalloc_noio_flags(gfp_t flags)
> +{
> +       if (unlikely(current->flags & PF_MEMALLOC_NOIO))
> +               flags &= ~__GFP_IO;
> +       return flags;
> +}
> 
> OK, so then this commit needs something like:
> 
> Fixes: 934f3072c17c ("mm: clear __GFP_FS when PF_MEMALLOC_NOIO is set")

Agree.

I wonder why this didn't come up much sooner.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01 10:22 ` [PATCH] " Vlastimil Babka
@ 2017-03-01 10:31   ` Michal Hocko
  2017-03-01 11:07     ` Nikolay Borisov
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Hocko @ 2017-03-01 10:31 UTC (permalink / raw)
  To: Vlastimil Babka; +Cc: Nikolay Borisov, peterz, mingo, linux-kernel

On Wed 01-03-17 11:22:51, Vlastimil Babka wrote:
> On 03/01/2017 08:48 AM, Nikolay Borisov wrote:
> > Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
> > during memory allocation") added the memalloc_noio_(save|restore) functions
> > to enable people to modify the MM behavior by disbaling I/O during memory
> > allocation. This prevents allocation paths recursing back into the filesystem
> > without explicitly changing the flags for every allocation site. Yet, lockdep
> > not being aware of that is prone to showing false positives. Fix this
> > by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
> > going to issue any I/O
> > 
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> > ---
> >  kernel/locking/lockdep.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > index 9812e5dd409e..5715fdcede28 100644
> > --- a/kernel/locking/lockdep.c
> > +++ b/kernel/locking/lockdep.c
> > @@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
> >  		return;
> >  
> >  	/* this guy won't enter reclaim */
> > -	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
> > +	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
> > +			curr->flags & PF_MEMALLOC_NOIO)
> 
> It would be slightly better to use memalloc_noio_flags() here. Michal is
> planning to convert it to take also a new PF_MEMALLOC_NOFS flag into
> account, and there would be less chance of forgetting to update this place.

Yes, you are right. The following should do the trick. I am really
surprised we haven't noticed this before. I thought we were shaving the
gfp_mask before the allocator goes the lockdep_trace_alloc way. But it
is not and what is worse SLAB tracks this as well so we cannot rely on
the proper gfp mask. The positive thing is that the recursion avoidance
works because we always clear GFP_IO and GFP_FS when doing reclaim.

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 7c38f8f3d97b..0c70b26849ce 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2861,6 +2861,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
 	if (unlikely(!debug_locks))
 		return;
 
+	gfp_mask = memalloc_noio_flags(gfp_mask);
+
 	/* no reclaim without waiting on it */
 	if (!(gfp_mask & __GFP_DIRECT_RECLAIM))
 		return;
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] lockdep: Teach lockdep about memalloc_noio_save
  2017-03-01 10:31   ` Michal Hocko
@ 2017-03-01 11:07     ` Nikolay Borisov
  0 siblings, 0 replies; 9+ messages in thread
From: Nikolay Borisov @ 2017-03-01 11:07 UTC (permalink / raw)
  To: Michal Hocko, Vlastimil Babka; +Cc: peterz, mingo, linux-kernel



On  1.03.2017 12:31, Michal Hocko wrote:
> On Wed 01-03-17 11:22:51, Vlastimil Babka wrote:
>> On 03/01/2017 08:48 AM, Nikolay Borisov wrote:
>>> Commit 21caf2fc1931 ("mm: teach mm by current context info to not do I/O
>>> during memory allocation") added the memalloc_noio_(save|restore) functions
>>> to enable people to modify the MM behavior by disbaling I/O during memory
>>> allocation. This prevents allocation paths recursing back into the filesystem
>>> without explicitly changing the flags for every allocation site. Yet, lockdep
>>> not being aware of that is prone to showing false positives. Fix this
>>> by teaching it that the presence of PF_MEMALLOC_NOIO flag mean we are not
>>> going to issue any I/O
>>>
>>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>>> ---
>>>  kernel/locking/lockdep.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
>>> index 9812e5dd409e..5715fdcede28 100644
>>> --- a/kernel/locking/lockdep.c
>>> +++ b/kernel/locking/lockdep.c
>>> @@ -2866,7 +2866,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
>>>  		return;
>>>  
>>>  	/* this guy won't enter reclaim */
>>> -	if ((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
>>> +	if (((curr->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) ||
>>> +			curr->flags & PF_MEMALLOC_NOIO)
>>
>> It would be slightly better to use memalloc_noio_flags() here. Michal is
>> planning to convert it to take also a new PF_MEMALLOC_NOFS flag into
>> account, and there would be less chance of forgetting to update this place.
> 
> Yes, you are right. The following should do the trick. I am really
> surprised we haven't noticed this before. I thought we were shaving the
> gfp_mask before the allocator goes the lockdep_trace_alloc way. But it
> is not and what is worse SLAB tracks this as well so we cannot rely on
> the proper gfp mask. The positive thing is that the recursion avoidance
> works because we always clear GFP_IO and GFP_FS when doing reclaim.

Okay I will send a revised patch, doing it the way you suggested.

> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 7c38f8f3d97b..0c70b26849ce 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2861,6 +2861,8 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
>  	if (unlikely(!debug_locks))
>  		return;
>  
> +	gfp_mask = memalloc_noio_flags(gfp_mask);
> +
>  	/* no reclaim without waiting on it */
>  	if (!(gfp_mask & __GFP_DIRECT_RECLAIM))
>  		return;
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-01 11:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01  7:48 [PATCH] lockdep: Teach lockdep about memalloc_noio_save Nikolay Borisov
2017-03-01  7:59 ` [PATCH v2] " Nikolay Borisov
2017-03-01  9:46   ` Peter Zijlstra
2017-03-01  9:57     ` Nikolay Borisov
2017-03-01 10:03       ` Peter Zijlstra
2017-03-01 10:23         ` Vlastimil Babka
2017-03-01 10:22 ` [PATCH] " Vlastimil Babka
2017-03-01 10:31   ` Michal Hocko
2017-03-01 11:07     ` Nikolay Borisov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.