From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752792AbdCAK5Z (ORCPT ); Wed, 1 Mar 2017 05:57:25 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36676 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639AbdCAK5W (ORCPT ); Wed, 1 Mar 2017 05:57:22 -0500 Subject: Re: [PATCH] lockdep: Teach lockdep about memalloc_noio_save To: Nikolay Borisov , peterz@infradead.org References: <1488354506-23774-1-git-send-email-nborisov@suse.com> Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Michal Hocko From: Vlastimil Babka Message-ID: Date: Wed, 1 Mar 2017 11:22:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <1488354506-23774-1-git-send-email-nborisov@suse.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 */ >