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 7CEE8C47422 for ; Mon, 29 Jan 2024 10:48:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDB3C6B00A0; Mon, 29 Jan 2024 05:48:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8B8B6B00A1; Mon, 29 Jan 2024 05:48:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B537C6B00A2; Mon, 29 Jan 2024 05:48:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A4DA16B00A0 for ; Mon, 29 Jan 2024 05:48:05 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 772EF1C1344 for ; Mon, 29 Jan 2024 10:48:05 +0000 (UTC) X-FDA: 81732023730.24.BEB4789 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf16.hostedemail.com (Postfix) with ESMTP id 6BEDE18001E for ; Mon, 29 Jan 2024 10:48:03 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="l//A053X"; dkim=pass header.d=suse.com header.s=susede1 header.b="l//A053X"; spf=pass (imf16.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706525283; 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=yUGE04n/BrCyjOEiOdcUDVLlhWmEpLaP9L0p6X7/XUE=; b=R2MPGLxLmuuhSI7ZrfKxAMqyZ6y9x3xOM9i5nu0Unc0N2cLHCOYWX1tdUSx5bMcXuvZjIL HTE+sg2HazWOxcE1tTH0umzdKN3QZJvog806TILbDLz+omk4S1csHdNwYJSUoro9Ictysd tAwQ0hOXjnRFEUi1lVBm1SmFpqvxxiQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706525283; a=rsa-sha256; cv=none; b=5Vojar9OpoicNGYicod3Uxu5iIKsiT2gH1mwPtpgcqhSXuQDRYjL1pxiKLsnqEu1TbQSEt qjyUVJZbI1ZhOT3ocXFrS2n64FP97t2V5M8bgvfb72+aEwWqu23J8l8WryC61VzPRyoFjj KCemtgcHLwuvp9U/LgibiD+KXeMIfa8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="l//A053X"; dkim=pass header.d=suse.com header.s=susede1 header.b="l//A053X"; spf=pass (imf16.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 3EB041F7DF; Mon, 29 Jan 2024 10:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706525281; 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=yUGE04n/BrCyjOEiOdcUDVLlhWmEpLaP9L0p6X7/XUE=; b=l//A053Xxc3mAhCGxUWMPfIiS3uZBxASM7OwduxV16eemNG7YL7SDElcwk83GWeEA0uJxO rDXLwHCQYDb7QITh27+rx3YImsqahIGUFb1hymgwoGdokKV8p8dDkp89CxWJirnZR06CxT X9mHzr/spTGsmePmObRt7mfleKwMZuc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706525281; 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=yUGE04n/BrCyjOEiOdcUDVLlhWmEpLaP9L0p6X7/XUE=; b=l//A053Xxc3mAhCGxUWMPfIiS3uZBxASM7OwduxV16eemNG7YL7SDElcwk83GWeEA0uJxO rDXLwHCQYDb7QITh27+rx3YImsqahIGUFb1hymgwoGdokKV8p8dDkp89CxWJirnZR06CxT X9mHzr/spTGsmePmObRt7mfleKwMZuc= 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 2EAF212FF7; Mon, 29 Jan 2024 10:48:01 +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 MYAVC2GCt2VWAQAAD6G6ig (envelope-from ); Mon, 29 Jan 2024 10:48:01 +0000 Date: Mon, 29 Jan 2024 11:48:00 +0100 From: Michal Hocko To: Kent Overstreet Cc: linux-mm@kvack.org, Vlastimil Babka , Matthew Wilcox , "Darrick J . Wong" Subject: Re: [PATCH 2/2] mm: introduce PF_MEMALLOC_NOWARN Message-ID: References: <20240126220756.395187-1-kent.overstreet@linux.dev> <20240126220756.395187-2-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 6BEDE18001E X-Rspam-User: X-Stat-Signature: cu73itsdskh9radh7srfsifegi5j1suh X-Rspamd-Server: rspam03 X-HE-Tag: 1706525283-918200 X-HE-Meta: U2FsdGVkX19cPdet/tKWjmtv8d1Y6sO2dRgNJOn2VYPE5nAwSACtcS2WsSQgtfmIm5GetSSoahYzT9SbyAfllVNstEsh8T3YJ640eHJ/l3DphTJkepd7ZIuc3Iib304y3cP461Js0PEyiLUMQcMmcxbuoNlEap6QmHxIxpr19gM3uItCjouoFI7SFVc3T2y5b/1E8lNCwZTA/lAp49nYRT6x2VFQBwVgLto5R4RkLnsZXjf8ZdI5/xnX/Xlody9nRrrIuLOStFUpnQ4LEMXBr6uJroAT+6ZwWIo0+y52aTVSU2uGr8C4fIeyEL/aPRqXO/xB3ak2eJJktVIhwzuFWf/4gA8PL4srU4vSPRSOcUCPcKfovp/oJrRETPS8zistMz1LqBTmnzDiqxRuOGbLAUooXtKhvVSnYctH3is+LyjSgB/sFUvS4bXcO5GZX0P7qaHRIEviyhJNqefM6AItpzRMdl9Xzv7jmKxIhWQtC0dltTU4F02MLA8LepvGYqTx7Xw1zvtIY9qsbIXghYY+9Zy8zF2vgMj3otZ+iJWRCRMUEnE18dwottX2v8t1CcNWsPSLkNh6GtdSS+EGH/TGHMBSieDJiPo1COtK2h2JnDB2RnZLvaZTovR5vceS6hDfGAOVtXrPctY9xk/8taVpcJN3tkHY3gfkiV1yhnJXzb+n8ANOhMYNM9lipsNFrpxvmh2jG1eRUOsv5dVjUGUasPjO0XWTdFGJyM0//kvVJH2VRYgnEBhTEkQyC8eMgjKlTQZW/ScRf/WDW7K6YQD7GyJPLQ5lGpfNtYnF2rPY2bvjEBENGo0LkbyYzZm3OHrQQ0rsPNy7Ph/uSO5JTe054kSWfuOP4Fb2+N8+9Ax1URJSmdLZKvLDqdGN2nW13cHAw5Adk3RIiObivjK5/tGMpunjOKVLuVpQ+8/aYrpJOQb1ITTdIYdRUQ== 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 Sun 28-01-24 14:43:16, Kent Overstreet wrote: > On Sun, Jan 28, 2024 at 04:45:32PM +0100, Michal Hocko wrote: > > On Fri 26-01-24 17:07:56, Kent Overstreet wrote: > > > If we're using PF_MEMALLOC, we might have a fallback and might not to > > > warn about a failing allocation - thus we need a PF_* equivalent of > > > __GFP_NOWARN. > > > > Could you be more specific about the user? Is this an allocation from > > the reclaim path or an explicit PF_MEMALLOC one? It would be also really > > helpful to explain why GFP_NOWARN cannot be used directly. > > Explicit PF_MEMALLOC. > > It's for a call to alloc_inode(), which doesn't take gfp flags, and > plumbing it would require modifying a s_ops callback and would touch > every filesystem - OK, I see. This should be part of the changelog. > but we want to get away from gfp flags anyways :) > > More specifically, the code where I'm using it is doing a "try > GFP_NOWAIT first; if that fails drop locks and do GFP_KERNEL" dance; > it's part of a cleanup for some weird lifetime stuff related to > fs/inode.c. > > #define memalloc_flags_do(_flags, _do) \ > ({ \ > unsigned _saved_flags = memalloc_flags_save(_flags); \ > typeof(_do) _ret = _do; \ > memalloc_noreclaim_restore(_saved_flags); \ > _ret; \ > }) > > /* > * Allocate a new inode, dropping/retaking btree locks if necessary: > */ > static struct bch_inode_info *bch2_new_inode(struct btree_trans *trans) > { > struct bch_fs *c = trans->c; > > struct bch_inode_info *inode = > memalloc_flags_do(PF_MEMALLOC|PF_MEMALLOC_NOWARN, to_bch_ei(new_inode(c->vfs_sb))); Is this what you meant by GFP_NOWAIT allocation? You would be right about this allocation not entering the direct reclaim but do you realize this is not an ordinary NOWAIT request beause PF_MEMALLOC will allow to dip into memory reserves without any limits? (Unless the specific allocation down the road is explicitly GFP_NOMEMALLOC) A failure here means that the system is really in a desparate state with all the memory reserves gone which migt break reclaimers who rely on those reserves. Are you sure it is a good idea? Unless I am missing something you are just giving an ordinary user access to those reserves by creating inodes without any bounds. -- Michal Hocko SUSE Labs