From patchwork Mon Aug 26 08:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13777441 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 5EC4AC5472F for ; Mon, 26 Aug 2024 08:54:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33AC76B02E9; Mon, 26 Aug 2024 04:54:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3166B02EA; Mon, 26 Aug 2024 04:54:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EC466B04E2; Mon, 26 Aug 2024 04:54: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 C85F26B02E9 for ; Mon, 26 Aug 2024 04:54:00 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7D89F40E2D for ; Mon, 26 Aug 2024 08:54:00 +0000 (UTC) X-FDA: 82493784240.02.D355A17 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf29.hostedemail.com (Postfix) with ESMTP id 84F62120004 for ; Mon, 26 Aug 2024 08:53:58 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=quarantine); spf=pass (imf29.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724662419; a=rsa-sha256; cv=none; b=SyZSfX2N2JGXEuQFuM5uBh2CxG1/aCRmYVMQw+VCfvEsircalqkBQpEpI9ERWI8AJl8KaB Bp0k7AziyVbFn3nd2NPU+6Fq7cgsdEjUPifHnP1dWQ6qT+t1yVlM8I57Hc9zTfDuK7Uiwf V2RNJw9QrVCDr+C26ieIWYf5s+yl9wE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=quarantine); spf=pass (imf29.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724662419; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4kEvuNqKI0xTjj6I4wqTHJS1sNMpYcp7Dr6Uq95pto=; b=KqczN9YnToWmbrJ8vKYoBed496f1bDvggQyfBK1pMzp8CgbJDtj7+vog4U373n0SZkXCmN DfGPPJ7dsO4dScFBCoqEQzVNgvs5LQ4XAAybnmj0Dnuyq4BHpqWnDHjQmV8kdG2BHo8O+o kqOWj36gp//NM7oK57INIzSXuzqoLC8= Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a86910caf9cso655227066b.1 for ; Mon, 26 Aug 2024 01:53:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724662437; x=1725267237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4kEvuNqKI0xTjj6I4wqTHJS1sNMpYcp7Dr6Uq95pto=; b=RelhnOKO7CelZcb+jo7ECAxxuGFcx8dvYNaa4HAciH+YTO7+TbsW6V31rAB1Hd3MWA B7L97Wovbn3EkW3Wp+RHOm5bVkaUWGFk5nym9Md2mBkT8Q1jr0emTucjeIgIqV2jIyQV uAOqB7khUWFIs5/IkaxIM3HXP4JWAtPtLVK6MDJGM19lCQMnoK/rzvkJLyDhxq7g0xH0 KMm123BGW3iGJ5b6TQmTzUKwb9qcaQEyBKJHDDA3VydpcbgYecOpzlegfzjd9HS7al83 XhMbZioBUXF8uapY5yCcElZ2CCfK0cPhBfSyQRvcpqVHRqmImi/5aHGW7M0yFZU2Iixg JB0g== X-Forwarded-Encrypted: i=1; AJvYcCVUXr4AvQNKxkl2H+kflfI+JT5HaUiUk2ocwAiAhQQAlAe1KNvTIBG4Va4HyzKoY6qX9bVkv/vr7w==@kvack.org X-Gm-Message-State: AOJu0Yw/ouafxyOC6M0LTx7fRTU0rCh+8m7gn4e4/b4vheEupWzdD6Jl Xqh/aX+7iKw1mb8iViIunqqvyg7TqjUqA7A55teFPD7AokY+Xhb0 X-Google-Smtp-Source: AGHT+IF1fJpfy3mPNIRs30Wnajmd99gCu+0+b/DeTT6aTwMVnETwc04A+X+3AnJTgxAHcIGYmfyZ+g== X-Received: by 2002:a17:907:1c8e:b0:a75:7a8:d70c with SMTP id a640c23a62f3a-a86a2f14394mr1133364766b.4.1724662436552; Mon, 26 Aug 2024 01:53:56 -0700 (PDT) Received: from localhost.localdomain ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f21fe18sm630636866b.29.2024.08.26.01.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 01:53:56 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Christoph Hellwig , Yafang Shao , Kent Overstreet , 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: [PATCH 2/2] mm: drop PF_MEMALLOC_NORECLAIM Date: Mon, 26 Aug 2024 10:47:13 +0200 Message-ID: <20240826085347.1152675-3-mhocko@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240826085347.1152675-1-mhocko@kernel.org> References: <20240826085347.1152675-1-mhocko@kernel.org> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 84F62120004 X-Rspamd-Server: rspam01 X-Stat-Signature: zfyeygtfapm5x5eh8rc8rtpwkeubr5p7 X-Rspam: Yes X-HE-Tag: 1724662438-93498 X-HE-Meta: U2FsdGVkX1+LFgn77LxSYUJUKsrabu7UUqNnRJcsK04Cy0X14hi+DGBYgrRpT39D5fdtmt/yeZsFKJsXzpp0Q5lF9iQu6T3gbR40uRcZ/zuQKMXRSqfLFMZM+B+ATBALeSc6n66y44yqWa7WJwFWYEWo9Q4YDry6T9dMgzfMS2USXNA9y+1fiV15DdO4iDw0bOVRigfzpBCAdgAwlPNEuratjAgSkwCRaUU0z6MsFO9+piA1UZ8Sv4atvS0KzzbZT+in3RfS9sYPGV2QWua3ATPfnr40hmrzncsChBSivElrPhYyrulV1pUXYZVqooFBLOApua7bUt6GRd9Kw7VBayynKFLZOtX2Cu3UUHHnm/Q76dd1Z++ZlLtnkHjCILZXlFDIMUf2GkAPtZJIJBe0ixTd3DX2v5ydXzGscbFsDw8uMZiBYyxjbWuehKRHJIoYMWz6AX42J5RlZd1sTkezfikOmUmic8/poI6YymnOQ4/w7nWrxKfTr3vs+tSTT5ndh3rhvfQWdHfFY9kXdLz0jl00xQMhMMvDSSdxwEyCuJa9XExowuOa9d6g0w6O1Li501TFBnEBoDaYLdh7L3y5cIGVhSfCvKvrQbeC4qzPopXB8scuBrLLXqCGsiQnn4iPnWWGgbdOy3Uom36QMb6pa24PAfVFk2o6Kobn2M/Mb5hnujBXZ1p6UDdCn0NDGCVqNhLTI1Ma1geY6SlrPpV7xwQt34jmk+iRsS2+0men9AKjJqw3MmCirLFJMfp4SPHKYXh6iLsXtc14aPCdt3RRJ0t6tgSvl7zfa92Gpz/rYH1ufLq3YldehlebHIlw0uGHQHi0w5nXG2AKh9U7EvW+ChYEz4B3yaAaH6Z7w384DCIU8jiXZcN6z/psaZyhmwerVLqm8ne/Cf+lRU6Moj42TIkJ6LniiUAQtJqNA6GaQ1WkGjb1grG3taVkd4lfRD65UOJ4iPQ5eBR+Cz11R3V llI0NT2O 6TY5zWzOUF33PzMjNxVmM0o7rbKfi4C1VPPVuEUJdLXcYKd9jNmgpXsAXx+tE9nIc08RMPvQkXJipy/6SL7/iYJchuNp56pmUW46IhIyYxX1fZfu1PhoAm2KsFFYOxDrvTmH3FIUlmFY8BDqAQa8N5fSw3SXw1arjzzI4bFs1fFwapiOm+DckpC5r16GuokZPFC8v92vSVXD5yOKunhtPAXfh2GUeiNLA0EZTOXb1QVQIRu2r1IV5ATUmXVLXhfIQFZ24zTcWOT5LM4CRNR4O5vLmoMBmv3HbZAsOy6L1cSQSvDwqxt6NAGG+7bU/eEOmUjQIrykqn3HZoee0AYX85fo7ijCTbY7rLqNDy+IKSVcTLCfQEqeGyTDEwvxO/D4T8c/SPImZKON7WADI/wWnp4cylWEy6Wa0we0jOq7d2nrBeJsuMWufts5rDXCnPUQrHeGeaxtT6iImeO2nXuO7upoC8AxU9JwwYtxqpI6kgxblqCelwXE/tvh1zsO4mKxwAWSmTCbMCqGeB3XOOD6+h4r+m5m10+kSWJVQLXrvernTGAMGiP0rh70O/sQUgAUX+aAkp4Ki6h8p2uqcjjmOBBwvEmFsMIBmUB4V 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: From: Michal Hocko There is no existing user of the flag and the flag is dangerous because a nested allocation context can use GFP_NOFAIL which could cause unexpected failure. Such a code would be hard to maintain because it could be deeper in the call chain. 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. [1] https://lore.kernel.org/all/ZcM0xtlKbAOFjv5n@tiehlicka/ Signed-off-by: Michal Hocko Signed-off-by: Michal Hocko Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Vlastimil Babka --- include/linux/sched.h | 1 - include/linux/sched/mm.h | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f8d150343d42..72dad3a6317a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1657,7 +1657,6 @@ 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_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 */ diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 91546493c43d..c49f2b24acb9 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -260,16 +260,13 @@ static inline gfp_t current_gfp_context(gfp_t flags) if (unlikely(pflags & (PF_MEMALLOC_NOIO | PF_MEMALLOC_NOFS | - PF_MEMALLOC_NORECLAIM | PF_MEMALLOC_NOWARN | PF_MEMALLOC_PIN))) { /* * Stronger flags before weaker flags: - * NORECLAIM implies NOIO, which in turn implies NOFS + * NOIO implies NOFS */ - if (pflags & PF_MEMALLOC_NORECLAIM) - flags &= ~__GFP_DIRECT_RECLAIM; - else if (pflags & PF_MEMALLOC_NOIO) + if (pflags & PF_MEMALLOC_NOIO) flags &= ~(__GFP_IO | __GFP_FS); else if (pflags & PF_MEMALLOC_NOFS) flags &= ~__GFP_FS;