From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E7C6C83F16 for ; Thu, 29 Aug 2024 13:22:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3E276B0089; Thu, 29 Aug 2024 09:22:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C6B66B008A; Thu, 29 Aug 2024 09:22:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 866BB6B008C; Thu, 29 Aug 2024 09:22:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 626BA6B0089 for ; Thu, 29 Aug 2024 09:22:35 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2536C120584 for ; Thu, 29 Aug 2024 13:22:35 +0000 (UTC) X-FDA: 82505347470.03.EB6ADF0 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by imf17.hostedemail.com (Postfix) with ESMTP id 0AB1440019 for ; Thu, 29 Aug 2024 13:22:32 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XVPUdueT; spf=pass (imf17.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724937664; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Wj903jW2TKogKU1SK5gHYnTDCZ4LBZZEeqojtBImNhA=; b=FRy5/8wqPRC2o6cmN31+VIia13gEocoF7I+Jf13zOmHCOhzskA2zlTMx7c/lkVogia8zkd 7R+jVM8O3mcVv5ObW/9hS8YVQ4kmeO6xO+DfpH6VXRMv5FPKds8MRdP/5m1b4UNBqIbz89 WONi0oeFs8f7mdyHYepW1zikc0iAR7s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724937664; a=rsa-sha256; cv=none; b=ektpB+UR7KuNuEckVdBgAaMYVs52v140LRnnQI3LiY4Jho0yy1/z5qOwKDX1V10658nvWD xgHCLHJtFibB4R4LkOawIku2tXULUndeb3Mh7+aOX8x3R4YjCRs29auPJ4vyjGDudxmPwM FGrVZjH30u8aIXJZwzLeGxAnYPtVFFs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XVPUdueT; spf=pass (imf17.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Thu, 29 Aug 2024 09:22:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724937750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Wj903jW2TKogKU1SK5gHYnTDCZ4LBZZEeqojtBImNhA=; b=XVPUdueTCc06z491GnDzWivlRjmdKoWWAkMdowwA4gngYbWqqd1X6LEGoWcNjSo64SlLE1 4dnZxSnYvS/GENkr+38UeUoF+3xU8b9ajFn9urUVP+g5kVCiSJU+bTfSQ5Zy5Z6eF/REV3 BFxDTcbSJQKSJ0WCgwmjsWNsSxKtI9I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Dave Chinner Cc: Michal Hocko , Andrew Morton , Christoph Hellwig , Yafang Shao , jack@suse.cz, Christian Brauner , Alexander Viro , Paul Moore , James Morris , "Serge E. Hallyn" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-bcachefs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Hocko Subject: Re: [PATCH 1/2 v2] bcachefs: do not use PF_MEMALLOC_NORECLAIM Message-ID: References: <20240826085347.1152675-2-mhocko@kernel.org> <20240827061543.1235703-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0AB1440019 X-Stat-Signature: dnpcdnpejyemgrfxyh9adf3uygft3qdg X-HE-Tag: 1724937752-136176 X-HE-Meta: U2FsdGVkX1/D2iRZq6HWLA2FEOtKj56/TyUdhMfC72nA3gMEnNQV0TxODCGcdQvjD6Dm/ryF+2T7k/6MlxnHzsH5bTgvPzRPf14tYwlKgtFn0pM/PlxKujfkaPHx8tiYvqspn5vh2qeIJEs/RJKQdc8zvM6Ocw+buvvqP0AeneaSqgJ82WwN569hcRAJwcq3zBYIWFzB5y6JWp+FG/m121xg+Hht7zOwbjKs+/4rCOrwJCA0snP1jzXxVuSSZ/rr6NbziceSY1CzZVdK03AImQQhvD0Jk/qGnDHuTfr/EZImOLbIyI865bIRQ8bN+t5lZ6qSz52rjt3EXnvihEixXF3k7xeioUEby0BOQFq9u6NQAntYhtF8tbq3Oe8h5NxHD30Ee2JUfA5EoJZktLHwWiGJ35fjYuZVz2DN1Sp7WLQsJN5xHCTVOPYaySCRFqUYz9fgDwqpKWyVDLXt8Tkvz04QAodPCo6c7aT+el+nDAbQiIeAxRY6OcpyxtMkMDxCnry+TpNulD9FVJJDX5DZCf1vNTtegduatnsW57eZI5JYd/YKHETp/YBC9W0SE6X/L/vvhf94SQRl3kmg2yrBtIMR/voDhnN8yHANPSVX43gBkxQmk5tC9UwAtkp6IwFfeEQNiMwvF/G4m6bYZkWWVnU/mQ8TtEp/ERfzncX/PLDemXON7JPVY2bPDHUICDMe6noW67DYIpmjMq5QrGn3WtZJs9tlKsfBuowvtoMuU4TJcA7Lc0I66A9oBrizi7GDVhvzjHzBOQ562gsf3N9S989ixJjvYRkxsA36sM/cnfjqlE607dsW/U/DX+YRcaQWvhK2zE1+DJCzPvek/g8MIJn63Q0a+sHkQ25m7Nvo5PI8J2of/tPhNPY2UFE7pat8Zd7HLvLo/8e8v5NbBFBhko4w4/S+j2/DAHoTCUZYlzKegxnRc7cgIdSP8IfGU4/CiKjIfxhEGZxNFJKt0At Km5E8+Cj dhjqXtDMvgV3zo/i6EQYz3DNQuWDF9KsFPUuJ4cIdcAkH2y7sr9/RJn++Ejh9hHCkI+km2Y8Nl+UJdjARsd34y9kThD2NxW8xErHfRBFPd5bnl2r2tEEjzdJrw7WlS5rkwuBGaFAbMWRggW64nUc/KDARMdmcL9b0jm7x4NZXbdBeEmpb81ld9UXeRe6XhEi61bPxU/WLBRN7gDmSzEClLRMH7KuYintHsNLQqH6rFSAlhhipoPHtdSe6ez6WkLk6/xc7/dWB+anE9H7Tw2IjU36II/ZGN718Sabcd8SzPNZMgjNxvFHiimMnDVUXUdQU2tosz+weD/sjodTAtVlTRmMUQND38OdPTHZw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Aug 29, 2024 at 11:12:18PM GMT, Dave Chinner wrote: > On Thu, Aug 29, 2024 at 06:02:32AM -0400, Kent Overstreet wrote: > > On Wed, Aug 28, 2024 at 02:09:57PM GMT, Dave Chinner wrote: > > > On Tue, Aug 27, 2024 at 08:15:43AM +0200, Michal Hocko wrote: > > > > From: Michal Hocko > > > > > > > > bch2_new_inode relies on PF_MEMALLOC_NORECLAIM to try to allocate a new > > > > inode to achieve GFP_NOWAIT semantic while holding locks. If this > > > > allocation fails it will drop locks and use GFP_NOFS allocation context. > > > > > > > > We would like to drop PF_MEMALLOC_NORECLAIM because it is really > > > > dangerous to use if the caller doesn't control the full call chain with > > > > this flag set. E.g. if any of the function down the chain needed > > > > GFP_NOFAIL request the PF_MEMALLOC_NORECLAIM would override this and > > > > cause unexpected failure. > > > > > > > > While this is not the case in this particular case using the scoped gfp > > > > semantic is not really needed bacause we can easily pus the allocation > > > > context down the chain without too much clutter. > > > > > > > > Acked-by: Christoph Hellwig > > > > Signed-off-by: Michal Hocko > > > > > > Looks good to me. > > > > > > Reviewed-by: Dave Chinner > > > > Reposting what I wrote in the other thread: > > I've read the thread. I've heard what you have had to say. Like > several other people, I think your position is just not practical or > reasonable. > > I don't care about the purity or the safety of the API - the > practical result of PF_MEMALLOC_NORECLAIM is that __GFP_NOFAIL > allocation can now fail and that will cause unexpected kernel > crashes. Keeping existing code and API semantics working correctly > (i.e. regression free) takes precedence over new functionality or > API features that people want to introduce. > > That's all there is to it. This is not a hill you need to die on. If you use GFP_NOFAIL in a context where you're not allowed to sleep, that's a bug, same as any other bug where you get the gfp flags wrong (e.g. GFP_KERNEL in non sleepable context). This isn't going to affect you unless you start going around inserting PF_MEMALLOC_NORECLAIM where it doesn't need to be. Why would you do that? But the lack of gfp flags for pte allocation means that this actually is a serious gap we need to be fixing.