linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-kernel@vger.kernel.org, mhocko@kernel.org,
	vbabka.lkml@gmail.com, linux-mm@kvack.org, mingo@redhat.com
Subject: Re: [PATCH v3] lockdep: Teach lockdep about memalloc_noio_save
Date: Wed, 1 Mar 2017 16:46:59 +0100	[thread overview]
Message-ID: <20170301154659.GL6515@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1488367797-27278-1-git-send-email-nborisov@suse.com>

On Wed, Mar 01, 2017 at 01:29:57PM +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 was further extended in Fixes: 934f3072c17c ("mm: clear 
> __GFP_FS when PF_MEMALLOC_NOIO is set"). memalloc_noio_* functions prevent 
> allocation paths recursing back into the filesystem without explicitly 
> changing the flags for every allocation site. However, lockdep hasn't been 
> keeping up with the changes and it entirely misses handling the memalloc_noio
> adjustments. Instead, it is left to the callers of __lockdep_trace_alloc to 
> call the functino after they have shaven the respective GFP flags. 
> 
> Let's fix this by making lockdep explicitly do the shaving of respective
> GFP flags. 

I edited that to look like the below, then my compiler said:

../kernel/locking/lockdep.c: In function ‘lockdep_set_current_reclaim_state’:
../kernel/locking/lockdep.c:3866:33: error: implicit declaration of function ‘memalloc_noio_flags’ [-Werror=implicit-function-declaration]
  current->lockdep_reclaim_gfp = memalloc_noio_flags(gfp_mask);
                                 ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
../scripts/Makefile.build:294: recipe for target 'kernel/locking/lockdep.o' failed



---
Subject: lockdep: Teach lockdep about memalloc_noio_save
From: Nikolay Borisov <nborisov@suse.com>
Date: Wed, 1 Mar 2017 13:29:57 +0200

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 was further extended in commit: 934f3072c17c ("mm: clear __GFP_FS
when PF_MEMALLOC_NOIO is set"). memalloc_noio_* functions prevent
allocation paths recursing back into the filesystem without explicitly
changing the flags for every allocation site.

However, people forgot to update lockdep with the changes and it
entirely misses handling the memalloc_noio adjustments. Instead, it is
left to the callers of __lockdep_trace_alloc to call the function
after they have shaven the respective GFP flags.

Fixes: 934f3072c17c ("mm: clear __GFP_FS when PF_MEMALLOC_NOIO is set")
Cc: vbabka.lkml@gmail.com
Cc: mingo@redhat.com
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1488367797-27278-1-git-send-email-nborisov@suse.com
---
 kernel/locking/lockdep.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Changes since v2: 
	* Incorporate Michal's suggestion of using memalloc_noio_flags explicitly. 
	* Tune the commit message to make the problem statement a bit more
	descriptive. 

--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2861,6 +2861,8 @@ static void __lockdep_trace_alloc(gfp_t
 	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;
@@ -3852,7 +3854,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)

  parent reply	other threads:[~2017-03-01 16:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 11:29 [PATCH v3] lockdep: Teach lockdep about memalloc_noio_save Nikolay Borisov
2017-03-01 12:09 ` Michal Hocko
2017-03-01 15:46 ` Peter Zijlstra [this message]
2017-03-01 16:01   ` Peter Zijlstra
2017-03-01 16:05   ` Michal Hocko
2017-03-01 16:12     ` Peter Zijlstra
2017-03-01 16:18       ` Michal Hocko
2017-03-03  8:04         ` Michal Hocko
2017-03-03  8:22           ` Peter Zijlstra
2017-03-03  8:31             ` Michal Hocko
2017-03-03  8:37               ` Michal Hocko
2017-03-03  8:50                 ` Peter Zijlstra
2017-03-03  6:50   ` Mike Galbraith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170301154659.GL6515@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nborisov@suse.com \
    --cc=vbabka.lkml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).