From patchwork Fri Aug 16 08:17:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13765674 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 31E72C3DA4A for ; Fri, 16 Aug 2024 08:18:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DDEB6B02DD; Fri, 16 Aug 2024 04:18:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68DB16B02DE; Fri, 16 Aug 2024 04:18:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52E0B6B02DF; Fri, 16 Aug 2024 04:18:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 350FE6B02DD for ; Fri, 16 Aug 2024 04:18:00 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C3009121A17 for ; Fri, 16 Aug 2024 08:17:59 +0000 (UTC) X-FDA: 82457405478.20.6D7BD99 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf23.hostedemail.com (Postfix) with ESMTP id BB38F140008 for ; Fri, 16 Aug 2024 08:17:57 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=U0nCJF5X; spf=pass (imf23.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.53 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=1723796264; 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=BU1tkV8X5i7PiBXUSXfeBM0LeURMRevsmU6tlpXfkvU=; b=3WSnh8EDSYJ446NiOTmZkidDkBzuoG+elHrDX07f4+pHeHWwQbYkSmyugVg+oF81gfncm2 IiWQ8/JH8DANqyLNXLGDI0qi9fe3Tk431hBvHauojBDwz3cm7KoMdVIysKuRn9V/wLesiU Pp90+2rtyut09Nyh61giitGZlhqcokY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=U0nCJF5X; spf=pass (imf23.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723796264; a=rsa-sha256; cv=none; b=2fJBugDZCHjXXIIxV/pCBKrjO1oSpIyjWV6UEtd8NlmfXOvtlNivbB7YRo3rM+CVncEuP6 NfyqKwiPRyLX3Tv5/WrkQn98Y3LDIpYO25tAthK+Gp1xhL46G15+ohJsE9BxbrNdXbIHs5 r+Ft4H2yTTOWSUofmHlEyWGtyEZhi/Y= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4280c55e488so8825705e9.0 for ; Fri, 16 Aug 2024 01:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1723796276; x=1724401076; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BU1tkV8X5i7PiBXUSXfeBM0LeURMRevsmU6tlpXfkvU=; b=U0nCJF5XMrMvJDDs2Yh/kmGwvsHPXf7lVT9JmC7nMZD3YFceG0/N/+pvrpf8BZNvfO iT7sCFBuG+JAk1Of6y0JOWgAJMCkh5/ygB9r1AqyVEt09THuPikT5YyOu5gkVMrf9FX2 WajZ61tXbQeDvOaQy1sTdEvCL3vC7LuBV1U6+bUPc7BnzsfTAmKcOKQMQoopzTnX/N4Q SEWRXdYGTygRi0tWUL2I4qO0JBvAGs6WelR0z7+COZmlhrE7OJG/uTuTKEE3+/s5QSJy SH2cEyt40H1gyt181APA3H9yD65EEEsHuxkHvPw5CWG3wtIICY6nedlt10C/W7zYpaBK gg2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796276; x=1724401076; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BU1tkV8X5i7PiBXUSXfeBM0LeURMRevsmU6tlpXfkvU=; b=ezmxSHW3W9C+XfEQurU7NOWNmTkj1lDBWdJl5mwNXeb0w7Rr3sVOIrQdgt56F5xeA6 JnMYmOPLN9Vfxy2uh2seBROW2TKHQAcs9QFoDi5xmBJl1KSIqisVUPYcCxxi4zEZr6cH SS9UQz7WJZzPbgleXquAJbZoIghas9yvXAFYXwAmsL5eIv2+fTKMXtzABIIWAGUrj+4V tWsEycM4h0MlJ9seYixZimHa9LSe1rLlQ71hw8EMZRXvexouzceyZhNDlIWUJLCKL5wF rG6CZaJYvJZw6j2FrUfQf3wPxydBobzFK1M1XGWasenGJVusWkdd0R4hywvLLEAIzGLm PVkQ== X-Forwarded-Encrypted: i=1; AJvYcCVH+0uj4QvFdugtbcbagMRQDwaDq36gV892mPu4FXsxNgCw2idiVTYwxUyJz09ltxcN9J45mUx+6BD2vSAj8A1zUtM= X-Gm-Message-State: AOJu0YwkPnGhgJIaLAnhe3Y7UkDo/x0WYm6BWxe9vA+3sjShcGH6ZWtv GRXE1sevDq0aJRRizqPyq8Hr/mMFatRV3Na6t3sxJE79j1bLMmgO+ghEQCWe66s= X-Google-Smtp-Source: AGHT+IGBiSeKP399RCWUTeuQdD9KB6Ykee9ZDfpSvw2v4GqqALRmzPxInSnplvOqg+obpaH39BKWIw== X-Received: by 2002:a05:600c:5124:b0:426:6327:5a16 with SMTP id 5b1f17b1804b1-429eda33161mr11472425e9.18.1723796276006; Fri, 16 Aug 2024 01:17:56 -0700 (PDT) Received: from localhost (109-81-92-77.rct.o2.cz. [109.81.92.77]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ed658651sm16281245e9.26.2024.08.16.01.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:17:55 -0700 (PDT) Date: Fri, 16 Aug 2024 10:17:54 +0200 From: Michal Hocko To: Yafang Shao , Andrew Morton Cc: Christoph Hellwig , akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH] mm: document risk of PF_MEMALLOC_NORECLAIM Message-ID: References: <20240812090525.80299-2-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Stat-Signature: ejabsbiqxaejq9xb43e5naponuohyh61 X-Rspamd-Queue-Id: BB38F140008 X-Rspamd-Server: rspam11 X-HE-Tag: 1723796277-434542 X-HE-Meta: U2FsdGVkX1+Cnn4a5poma+2ImB8S3WVimeOWQ4fU1QDJOz/eFjF9plu/j/0AowfoH9c76haRmnhkhDf0SOkP7YZZPL4b7IZrhmNnczGrnVIbo97LGUprVIz8d6DTfALUKokW8R/UfkrE7XowDTsysVB/lAny5NM6bJToVBAZQfBo9LzfG+VPehhNc/1GWG6+kVOCCHwdce5XrDgt5D5r10X8GY78uBu5VU/SMayv06BoMRO8n771aGLo3MsL1vy26mwgmXQJeXXUSb7VHeoV/sJ47iNatMxFa65Wdjb+4iPaGePmFeb8UtAuudtV50Sxj/wETa6FlFtq8dXXmJ1ShXmbT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MOwgLNMmrPErk/9fdPRGws+dHHLlA221HRpaOWCL6rtM7PVcltbf+54pwLfZD/u0Hz51Rh1/L460kZWnADNJlCZYltomlxqm+wxoz/U08APdcP3Xv9w4iE0sU5PO6Pw3kNG6k14WdNgZxUCJw96TY9WrlsLiGKISGoL+ 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: Andrew, could you merge the following before PF_MEMALLOC_NORECLAIM can be removed from the tree altogether please? For the full context the email thread starts here: https://lore.kernel.org/all/20240812090525.80299-1-laoar.shao@gmail.com/T/#u Acked-by: Yafang Shao Acked-by: Christoph Hellwig --- From f17d36975ec343d9388aa6dbf9ca8d1b58ed09ce Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Fri, 16 Aug 2024 10:10:00 +0200 Subject: [PATCH] mm: document risk of PF_MEMALLOC_NORECLAIM PF_MEMALLOC_NORECLAIM has been added even when it was pointed out [1] that such a allocation contex is inherently unsafe if the context doesn't fully control all allocations called from this context. Any potential __GFP_NOFAIL request from withing PF_MEMALLOC_NORECLAIM context would BUG_ON if the allocation would fail. [1] https://lore.kernel.org/all/ZcM0xtlKbAOFjv5n@tiehlicka/ Signed-off-by: Michal Hocko --- include/linux/sched.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f8d150343d42..0c9061d2a8bd 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1657,7 +1657,12 @@ extern struct pid *cad_pid; * I am cleaning dirty pages from some other bdi. */ #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */ -#define PF_MEMALLOC_NORECLAIM 0x00800000 /* All allocation requests will clear __GFP_DIRECT_RECLAIM */ +#define PF_MEMALLOC_NORECLAIM 0x00800000 /* All allocation requests will clear __GFP_DIRECT_RECLAIM. + * This is inherently unsafe unless the context fully controls + * all allocations used. Any potential __GFP_NOFAIL nested allocation + * could BUG_ON as the page allocator doesn't support non-sleeping + * __GFP_NOFAIL requests. + */ #define PF_MEMALLOC_NOWARN 0x01000000 /* All allocation requests will inherit __GFP_NOWARN */ #define PF__HOLE__02000000 0x02000000 #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */