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 8AFF9C4345F for ; Wed, 1 May 2024 08:06:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E4506B008C; Wed, 1 May 2024 04:06:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16C666B0096; Wed, 1 May 2024 04:06:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27F26B0099; Wed, 1 May 2024 04:06:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CE2B26B008C for ; Wed, 1 May 2024 04:06:48 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 44684140C4A for ; Wed, 1 May 2024 08:06:48 +0000 (UTC) X-FDA: 82069095696.15.6FC0509 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf22.hostedemail.com (Postfix) with ESMTP id B38EBC001D for ; Wed, 1 May 2024 08:06:45 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nu7HUQhJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Em25h0cX; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nu7HUQhJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Em25h0cX; spf=pass (imf22.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714550806; 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=ZvOa1RRKhsRXbnRKhGTHJSYYjtSxKx+Tc+58iQcDqlo=; b=tIMTmvrDRPpQBag3CRygySyZALiJ7XFjXsVTibkF9B8CSj+Vk1/gnyf9/zslM7siPBYFmG szJAoO18UdDpQ9nXkwHanSz4kt94v62P+FMCvrgXlLxg4jiT/4FWRBv18EGyTzV/ac7Dxm vBOLHsg6DXlK3vXPb6Zxzw6IPCQqaGU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nu7HUQhJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Em25h0cX; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nu7HUQhJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Em25h0cX; spf=pass (imf22.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714550806; a=rsa-sha256; cv=none; b=h1RGQ1n23pb4aoPnzp0/oJB/EpuprDmt1cATO/m6FUkh0ymYM7F1ZKChTvQjaBL8zO7g1e N3fMiClkaBWubhhqmO2GVZrLoJ8F6ieXE4zHbwvYe6baZ0vXVEaGisNTATffuizrs6vIou VGZq7F1dWnph/QG5HKmtj18lGq1n3rY= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0427E1F83D; Wed, 1 May 2024 08:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714550804; h=from:from:reply-to: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=ZvOa1RRKhsRXbnRKhGTHJSYYjtSxKx+Tc+58iQcDqlo=; b=nu7HUQhJsfl1GUr4gFVkN1JBYwlYjUU4ztPQQ8PTk7s4b+r1zEMnRFWLrodXnJf/jSUYNm yms/7TpxMHMtxi16W8hI8LEMsUCa3uwiNCJvMUwm5detBCDsP0vV42R9TiStgC5kOd8zQw ScOyDECXMnuMssYw0akplBYf5fSxvH8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714550804; h=from:from:reply-to: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=ZvOa1RRKhsRXbnRKhGTHJSYYjtSxKx+Tc+58iQcDqlo=; b=Em25h0cXEswYzYaCAYPV2Mt/UYPPZnyIfY4CNMt7C325a14533cu48bTlKA7MAYn5yZjtm 1raCi2FZx7s5t1AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714550804; h=from:from:reply-to: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=ZvOa1RRKhsRXbnRKhGTHJSYYjtSxKx+Tc+58iQcDqlo=; b=nu7HUQhJsfl1GUr4gFVkN1JBYwlYjUU4ztPQQ8PTk7s4b+r1zEMnRFWLrodXnJf/jSUYNm yms/7TpxMHMtxi16W8hI8LEMsUCa3uwiNCJvMUwm5detBCDsP0vV42R9TiStgC5kOd8zQw ScOyDECXMnuMssYw0akplBYf5fSxvH8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714550804; h=from:from:reply-to: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=ZvOa1RRKhsRXbnRKhGTHJSYYjtSxKx+Tc+58iQcDqlo=; b=Em25h0cXEswYzYaCAYPV2Mt/UYPPZnyIfY4CNMt7C325a14533cu48bTlKA7MAYn5yZjtm 1raCi2FZx7s5t1AQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7D15713942; Wed, 1 May 2024 08:06:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PTv4GxP4MWYQZwAAD6G6ig (envelope-from ); Wed, 01 May 2024 08:06:43 +0000 Date: Wed, 1 May 2024 10:06:41 +0200 From: Oscar Salvador To: Dave Chinner Cc: linux-mm@kvack.org, linux-xfs@vger.kernel.org, akpm@linux-foundation.org, hch@lst.de, elver@google.com, vbabka@suse.cz, andreyknvl@gmail.com Subject: Re: [PATCH 0/3] mm: fix nested allocation context filtering Message-ID: References: <20240430054604.4169568-1-david@fromorbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240430054604.4169568-1-david@fromorbit.com> X-Stat-Signature: f9crt4xmj13dxdk3sh1czh6em7o77sjf X-Rspamd-Queue-Id: B38EBC001D X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714550805-60025 X-HE-Meta: U2FsdGVkX1+ukh/CcpiAts5CbhXd0rcv8B8yBh9u8HpBcuQglWpndM4C8QHFRfBr97TOpR7ldPNn1X32gufKQS832jBl5GllSmWDsCPzVLydvQ9uHkvXsbl517wH5qr4f4oysLyjcfjolQTUexhSdos1BfSyAQQ+961gNxHVUTaZab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ilter, 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 Tue, Apr 30, 2024 at 03:28:22PM +1000, Dave Chinner wrote: > This patchset is the followup to the comment I made earlier today: > > https://lore.kernel.org/linux-xfs/ZjAyIWUzDipofHFJ@dread.disaster.area/ > > Tl;dr: Memory allocations that are done inside the public memory > allocation API need to obey the reclaim recursion constraints placed > on the allocation by the original caller, including the "don't track > recursion for this allocation" case defined by __GFP_NOLOCKDEP. > > These nested allocations are generally in debug code that is > tracking something about the allocation (kmemleak, KASAN, etc) and > so are allocating private kernel objects that only that debug system > will use. > > Neither the page-owner code nor the stack depot code get this right. > They also also clear GFP_ZONEMASK as a separate operation, which is > completely redundant because the constraint filter applied > immediately after guarantees that GFP_ZONEMASK bits are cleared. > > kmemleak gets this filtering right. It preserves the allocation > constraints for deadlock prevention and clears all other context > flags whilst also ensuring that the nested allocation will fail > quickly, silently and without depleting emergency kernel reserves if > there is no memory available. > > This can be made much more robust, immune to whack-a-mole games and > the code greatly simplified by lifting gfp_kmemleak_mask() to > include/linux/gfp.h and using that everywhere. Also document it so > that there is no excuse for not knowing about it when writing new > debug code that nests allocations. > > Tested with lockdep, KASAN + page_owner=on and kmemleak=on over > multiple fstests runs with XFS. Reviewed-by: Oscar Salvador Thanks! -- Oscar Salvador SUSE Labs