Received: by 10.223.176.5 with SMTP id f5csp2899908wra; Mon, 29 Jan 2018 05:57:11 -0800 (PST) X-Google-Smtp-Source: AH8x225fyv4bUbu3pkBw8mO9pYjOYwQJ/pS2BvaolPMlhG8MDXnvQQBGapQEkS6oSeN4oeOcdLw7 X-Received: by 10.98.26.143 with SMTP id a137mr27540306pfa.100.1517234231046; Mon, 29 Jan 2018 05:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517234230; cv=none; d=google.com; s=arc-20160816; b=LATbydqSIA6dtZaXftkL9bnP1OcEUPKvRfEU8yiKv/eKyG4+UchuAa18mWkQPwX/CV pLqjjz842iXG2Uh9RcC194CgSpqr8cLHrAj86L3Bgtel6GxxxTLarvZmJS/QES8Zw2Yz bosvnz6lMkIfb/jWqgTEa0kSrmA6nat/BFkYrOfKm3V1sABAlEXlfNovT2qGFMEiKwyG GF6pKedbP+PQBwmC9dFjM/Uwa0n/CHpjubPwf4/mX2WhsIY4Yasdu2NyT3ii7BdFwfhG t/ciTd65tgr+gLmoNTksLUthBuAgei9ZBG6crCIcJF66Z1oiR/iMN7S4/3m0NQLlqcq+ kQhA== 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=068GFS5y2OCeMYjKuMzoqz77VHKjvTxG+Hvxr7uV1vg=; b=vo2G5wFzQvcY2BZUMZxNgS92eQgiuoF+222BYQukLqY5VIcwdLKGRjieLQni/Fxt0n V1/v75yOxNwGwjEbEH6Aus1jSP3dSyuuQdAT9t4iSSOpqdZ84ArehLJ+tMqZ8XqpdmZs sb1Sc+XOwAKT2x3Brx2f4Z1AlCR670BqdTwhd9h1NFSVedplehECvNNeyayB8szXDSf3 zbLvcLjAWQZLmbYU26+/pdSPIMq6yOU92Q6+Yhm0IlAeSoisMuIxBDPgxByhMiNAKooQ /PaSCBphZowf+kTiO7p3O6wyZNBrCA37Vtg9tRVRHBh06l+MaqZcgD3JQQNEe7bEZr8t fYIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lknyPpgX; 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 c10si7432799pga.270.2018.01.29.05.56.55; Mon, 29 Jan 2018 05:57:10 -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=bombadil.20170209 header.b=lknyPpgX; 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 S1751934AbeA2Nz6 (ORCPT + 99 others); Mon, 29 Jan 2018 08:55:58 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:34941 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbeA2Nz4 (ORCPT ); Mon, 29 Jan 2018 08:55:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=068GFS5y2OCeMYjKuMzoqz77VHKjvTxG+Hvxr7uV1vg=; b=lknyPpgX9+dHMHx43Hcclvbu3 IEfSzFuXUpyPOcyk9/J07+GW24wt68rSw7+J3/69Cg/CkCnYBAKqwu6Ko5YxHR1oPkumPqJFgEF31 ZJI8nq0Ma9BVwaThbVnfRRCkhM5OmOEGha89x0H7uF9oi63XA8xY0XrN8P/NhKhj8+ZUCfXsOoIei HuOAarAFKcqdFqAecdmzEDumYWJo2a2jOZq8jrWWBiddca/uDDpIRn7GAmnpASqTznQBJptlABY0a oW8kZ5ytZghd0l09tFURU7lrl8FOoJObFmkCXML7qEUIqy5ajfUKDxBuvM3dL1x62SFFbShWrB6Bf nhbtINl2Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eg9uY-00060D-Hi; Mon, 29 Jan 2018 13:55:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6BDE520298BA7; Mon, 29 Jan 2018 14:55:47 +0100 (CET) Date: Mon, 29 Jan 2018 14:55:47 +0100 From: Peter Zijlstra To: Tetsuo Handa Cc: torvalds@linux-foundation.org, davej@codemonkey.org.uk, npiggin@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, mhocko@kernel.org Subject: Re: [4.15-rc9] fs_reclaim lockdep trace Message-ID: <20180129135547.GR2269@hirez.programming.kicks-ass.net> References: <7771dd55-2655-d3a9-80ee-24c9ada7dbbe@I-love.SAKURA.ne.jp> <8f1c776d-b791-e0b9-1e5c-62b03dcd1d74@I-love.SAKURA.ne.jp> <20180129102746.GQ2269@hirez.programming.kicks-ass.net> <201801292047.EHC05241.OHSQOJOVtFMFLF@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201801292047.EHC05241.OHSQOJOVtFMFLF@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 Mon, Jan 29, 2018 at 08:47:20PM +0900, Tetsuo Handa wrote: > Peter Zijlstra wrote: > > 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. > > d92a8cfcb37ecd13 replaced lockdep_set_current_reclaim_state() with > fs_reclaim_acquire(), and removed current->lockdep_recursion handling. > > ---------- > # git show d92a8cfcb37ecd13 | grep recursion > -# define INIT_LOCKDEP .lockdep_recursion = 0, .lockdep_reclaim_gfp = 0, > +# define INIT_LOCKDEP .lockdep_recursion = 0, > unsigned int lockdep_recursion; > - if (unlikely(current->lockdep_recursion)) > - current->lockdep_recursion = 1; > - current->lockdep_recursion = 0; > - * context checking code. This tests GFP_FS recursion (a lock taken > ---------- That should not matter at all. The only case that would matter for is if lockdep itself would ever call into lockdep again. Not something that happens here. > > The new code has it in fs_reclaim_acquire/release to the same effect, if > > __GFP_NOMEMALLOC, we'll not acquire/release the lock. > > Excuse me, but I can't catch. > We currently acquire/release __fs_reclaim_map if __GFP_NOMEMALLOC. Right, got the case inverted, same difference though. Before we'd do mark_held_lock(), now we do acquire/release under the same conditions. > > > 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. > > __GFP_NOMEMALLOC negates PF_MEMALLOC regarding what watermark that allocation > request should use. Right. > But at the same time, PF_MEMALLOC negates __GFP_DIRECT_RECLAIM. Ah indeed. > Then, how can fs_reclaim contribute to deadlock? Not sure it can. But if we're going to allow this, it needs to come with a clear description on why. Not a few clues to a puzzle. Now, even if its not strictly a deadlock, there is something to be said for flagging GFP_FS allocs that lead to nested GFP_FS allocs, do we ever want to allow that?