Received: by 10.223.176.5 with SMTP id f5csp2697408wra; Mon, 29 Jan 2018 02:28:49 -0800 (PST) X-Google-Smtp-Source: AH8x225F+Qo8NK58pfu5QO4EjpFl5sVtnc1Dx6khkIpWaWxJCO7AVZtlqHORZFnAjbKokzVmLoL5 X-Received: by 2002:a17:902:c01:: with SMTP id 1-v6mr20678148pls.55.1517221729500; Mon, 29 Jan 2018 02:28:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517221729; cv=none; d=google.com; s=arc-20160816; b=V9FRGTsMge4pDJSwon3DpYfn6PPYJF35zURrPfxslwmHj/U51s2PhEvpbq1npza8J2 /hW5x95uKHp69ah1x+5iSyBeT4/bsib7iY3FucaldHxNds6ALUrYM2kfvmth3+KU3AlL 4Ocqjhqr48RCZiQQdiY8848iv31qie6cifJjeTPizexCYl85jwQK1ls9IlcD4jbY/LjJ iyF1T8WMqUxNbuO6mpsaZBHlgQSzjLqW+COjDlRyQsN8pF0PP7+ajRbLQVpkKZQj0WcC Or9/wacUXfbAcix0Vx5ioHlfZ9UcPtpkRNKlgNXXwfmGsuyEGTS0m89MPX2pZNN7JACC QjUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=hFvfR4P7fJZx0gtjbMtuVqHYDMm6odC9UgaS5VlBHcY=; b=r/BeDFwc5YNLbXFuY3c5NjnuZz/jofCUsFsXSV47hfYufLwSxnd5ZFGThvdsuyS8Mw lyA/CXeQHAodjY9M9ti8aC3RZ1fUZghZa9+vSO9NIJKzfjjIO7cM91t6l0J/SsfxTAdn L7PM6L7McNPp4UO0cgrsD59BBRtckeaHYKpxo9wEffWOGby7V1OMfdNM8Kbi8h/CyiB1 TYX1hqfeWpczuHtkl++LuZJ/49Y83O16T0zXcHA6N2CPPCuVabg9qeKP12QSVzJOzol4 Yo2Opysj/hMD2QjM5B8c5FcxoGrexfzO2ovHH00WB4udqiAFELfYiYRNJkwoj5ocsRr8 z42A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=mywRaqd9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si4824807plb.529.2018.01.29.02.28.35; Mon, 29 Jan 2018 02:28:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=mywRaqd9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbeA2K2E (ORCPT + 99 others); Mon, 29 Jan 2018 05:28:04 -0500 Received: from merlin.infradead.org ([205.233.59.134]:54898 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbeA2K2C (ORCPT ); Mon, 29 Jan 2018 05:28:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hFvfR4P7fJZx0gtjbMtuVqHYDMm6odC9UgaS5VlBHcY=; b=mywRaqd9zN5jdCla75cxIKwtL LIzFqaW1UpHXVk5cN5pfosWC/ZJ2vgiraxlzO0ZyRW1UREKoMBVnty0QzI4wktEAalhEs7OafFlHX 9cUj4qGfZwJugUSYrOnEh/jolCZQMqLn/mRTLO0yNflewqGK6RT6w9lI27xFGV97kYkUgjxWdlQXR RNouPMxoLPfmx0vjwcnpQdgab/b4ioJwMHW/iLoNOvjUh2E5hAsajW8EfvN42+NtinGvqSa40n7O+ WZt+VvkDUz05UfdfYykyYGS9yM4kk8kXHOuFOQ0n5sCii1MQdM5X3xKplkHzuz/gxE2U9UY2jMf48 kbiYSuQLg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eg6fG-0001Mi-VM; Mon, 29 Jan 2018 10:27:51 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D9A6F2025C299; Mon, 29 Jan 2018 11:27:46 +0100 (CET) Date: Mon, 29 Jan 2018 11:27:46 +0100 From: Peter Zijlstra To: Tetsuo Handa Cc: Linus Torvalds , Dave Jones , Nick Piggin , Linux Kernel , linux-mm , Network Development , mhocko@kernel.org Subject: Re: [4.15-rc9] fs_reclaim lockdep trace Message-ID: <20180129102746.GQ2269@hirez.programming.kicks-ass.net> References: <20180124013651.GA1718@codemonkey.org.uk> <20180127222433.GA24097@codemonkey.org.uk> <7771dd55-2655-d3a9-80ee-24c9ada7dbbe@I-love.SAKURA.ne.jp> <8f1c776d-b791-e0b9-1e5c-62b03dcd1d74@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f1c776d-b791-e0b9-1e5c-62b03dcd1d74@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 28, 2018 at 02:55:28PM +0900, Tetsuo Handa wrote: > This warning seems to be caused by commit d92a8cfcb37ecd13 > ("locking/lockdep: Rework FS_RECLAIM annotation") which moved the > location of > > /* this guy won't enter reclaim */ > if ((current->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) > return false; > > check added by commit cf40bd16fdad42c0 ("lockdep: annotate reclaim context > (__GFP_NOFS)"). I'm not entirly sure I get what you mean here. How did I move it? It was part of lockdep_trace_alloc(), if __GFP_NOMEMALLOC was set, it would not mark the lock as held. The new code has it in fs_reclaim_acquire/release to the same effect, if __GFP_NOMEMALLOC, we'll not acquire/release the lock. > Since __kmalloc_reserve() from __alloc_skb() adds > __GFP_NOMEMALLOC | __GFP_NOWARN to gfp_mask, __need_fs_reclaim() is > failing to return false despite PF_MEMALLOC context (and resulted in > lockdep warning). But that's correct right, __GFP_NOMEMALLOC should negate PF_MEMALLOC. That's what the name says. > Since there was no PF_MEMALLOC safeguard as of cf40bd16fdad42c0, checking > __GFP_NOMEMALLOC might make sense. But since this safeguard was added by > commit 341ce06f69abfafa ("page allocator: calculate the alloc_flags for > allocation only once"), checking __GFP_NOMEMALLOC no longer makes sense. > Thus, let's remove __GFP_NOMEMALLOC check and allow __need_fs_reclaim() to > return false. This does not in fact explain what's going on, it just points to 'random' patches. Are you talking about this: + /* Avoid recursion of direct reclaim */ + if (p->flags & PF_MEMALLOC) + goto nopage; bit? > Reported-by: Dave Jones > Signed-off-by: Tetsuo Handa > Cc: Peter Zijlstra > Cc: Nick Piggin > --- > mm/page_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 76c9688..7804b0e 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3583,7 +3583,7 @@ static bool __need_fs_reclaim(gfp_t gfp_mask) > return false; > > /* this guy won't enter reclaim */ > - if ((current->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) > + if (current->flags & PF_MEMALLOC) > return false; I'm _really_ uncomfortable doing that. Esp. without a solid explanation of how this raelly can't possibly lead to trouble. Which the above semi incoherent rambling is not. Your backtrace shows the btrfs shrinker doing an allocation, that's the exact kind of thing we need to be extremely careful with.