Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2420570ybv; Mon, 24 Feb 2020 05:02:40 -0800 (PST) X-Google-Smtp-Source: APXvYqx+PPNhzx3BkiAvPKBYaCMiyIlO2hr7jNIn1vMng1s7TsTa/7FVoE+XI84iz2aIH9Z8mTop X-Received: by 2002:a9d:730e:: with SMTP id e14mr38201664otk.62.1582549360654; Mon, 24 Feb 2020 05:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582549360; cv=none; d=google.com; s=arc-20160816; b=Lphye5X9bbbPCdPrevRatKdMI4ThHbPZRzH1NuG6vrVkoFiHYLUv9bk4pBBunZLTyb pIs22HiyIC1T69Lg9/JG2Xh8cJiY1KrMM62OoFfBycoQafmz2PKJ32eH9LPAnLMGBuKI vzdleHC0BeIlCldbfIPnq1AGJHVYqt1uc2llJZhBgmg/vL72W74fI283Q4gauE95TD1e CD+SsZfbwtTiDLO4gu3edr8MlJ46KH/ZpPonJLKQLhnGOsJNlCw9lVyUCPW0y0DBYVB4 rSAwC3XqEL6LqHrdYUvRTxWy/B0W/pog2xyVIWybEZB52PeLC0/igtfB5jWQGXwSFTr3 xwsw== 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; bh=UNfFHYe5hmNaw+oXgVPGlKZN8KpD9InlhIMjl2ajeE4=; b=RbIv1ZeEJiDLrG4+BLCR5EPgMxIy/0RHsfDofupWQVhyVslCLIXS9Q8x3OmJRJxHxf 6kXZ5sHpz9B/QkhFysXhSTLf9Iv4piRG4PfhIi1zNsMhezPnDC+cs8/YYFBhEvVfs8LC 8nz1k6Xlv2t8q84TS5ivO4ofEp/PX0LbpyaN/JTrW68UfIHFGaNs99hW5i6RI1uItuqd I4v5NYKjj4k3XSTJIZkMYI5bkm1J3JzLlumY048bnMOKuMDMDfvUzyi0yVDFGIHa+M6h 7GFGTCqAwwArBanAj17Y8v5GmR/T9Cf8vwUs2Y+Lr/FVNChZPF50B1N0MnxaY67S2rYe Yr4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 t25si5203361oic.183.2020.02.24.05.02.24; Mon, 24 Feb 2020 05:02:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727495AbgBXNCW (ORCPT + 99 others); Mon, 24 Feb 2020 08:02:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:52530 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbgBXNCV (ORCPT ); Mon, 24 Feb 2020 08:02:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 16CBCAD79; Mon, 24 Feb 2020 13:02:20 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 2FE441E0E33; Mon, 24 Feb 2020 14:02:19 +0100 (CET) Date: Mon, 24 Feb 2020 14:02:19 +0100 From: Jan Kara To: "J. R. Okajima" Cc: Jan Kara , jack@suse.com, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: ext2, possible circular locking dependency detected Message-ID: <20200224130219.GE27857@quack2.suse.cz> References: <4946.1582339996@jrobl> <20200224090846.GB27857@quack2.suse.cz> <24689.1582538536@jrobl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24689.1582538536@jrobl> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 24-02-20 19:02:16, J. R. Okajima wrote: > Jan Kara: > > This is not the right way how memalloc_nofs_save() should be used (you > > could just use GFP_NOFS instead of GFP_KERNEL instead of wrapping the > > allocation inside memalloc_nofs_save/restore()). The > > memalloc_nofs_save/restore() API is created so that you can change the > > allocation context at the place which mandates the new context - i.e., in > > this case when acquiring / dropping xattr_sem. That way you don't have to > > propagate the context information down to function calls and the code is > > also future-proof - if you add new allocation, they will use correct > > allocation context. > > Thanks for the lecture about memalloc_nofs_save/restore(). > Honestly speaking, I didn't know these APIs and I always use GFP_NOFS > flag. Investigating this lockdep warning, I read the comments in gfp.h. > > * %GFP_NOFS will use direct reclaim but will not use any filesystem interfaces. > * Please try to avoid using this flag directly and instead use > * memalloc_nofs_{save,restore} to mark the whole scope which cannot/shouldn't > * recurse into the FS layer with a short explanation why. All allocation > * requests will inherit GFP_NOFS implicitly. > > Actually grep-ping the whole kernel source tree told me there are > several "one-liners" like ...nofs_save(); kmalloc(); ...nofs_restore > sequence. But re-reading the comments and your mail, I understand these > APIs are for much wider region than such one-liner. > > I don't think it a good idea that I send you another patch replaced by > GFP_NOFS. You can fix it simply and you know much more than me about > this matter, and I will be satisfied when this problem is fixed by you. OK, in the end I've decided to go with a different solution because I realized the warning is a false positive one. The patch has passed a fstests run but I'd be grateful if you could verify whether you can no longer trigger the lockdep warning. Thanks! Honza PS: I've posted the patch separately to the list. -- Jan Kara SUSE Labs, CR