From patchwork Tue Feb 6 21:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13547800 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 CE459C4828D for ; Tue, 6 Feb 2024 21:50:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8BB76B007D; Tue, 6 Feb 2024 16:50:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B9E6E8D0001; Tue, 6 Feb 2024 16:50:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A09A6B007E; Tue, 6 Feb 2024 16:50:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 863816B0078 for ; Tue, 6 Feb 2024 16:50:37 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 59CA51C1499 for ; Tue, 6 Feb 2024 21:50:37 +0000 (UTC) X-FDA: 81762723714.01.F304EC9 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf28.hostedemail.com (Postfix) with ESMTP id 9371EC0010 for ; Tue, 6 Feb 2024 21:50:35 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tk4aRtnU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707256235; 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:dkim-signature; bh=+KzZqwbQeNdV0pmvYQSEwIojyt3c9wDtFh98zm28exM=; b=nIu+lApiwOpmQISN0GKXcUsJt86wMrf+yaAPE4oUd4v2m2O+w1vX7ntR+XCYuJaqf2v65v luve5dlK5URDNKVo9qQoyFYoukunoPpwxb/SlP1+JUEt4XtXmAQpJaG2CzWOwqdZBP/pX0 YF4BDj4VbcqxjjQ7d+CegLBKqbNT1RQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=tk4aRtnU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707256235; a=rsa-sha256; cv=none; b=RJAFIPy+sNE5y6sDy0p4BHAIGN09bSWHGlNRO9tUHM7qBEdftGkJeAcItxxq8jE23LkqKw YqCrSpf/LU7ESovD9gAgYKsJMZWe5Qu+V79mDhs3iaNf7QwH6hDnoHggQ35aLdA4KedCsn cf6i+9FILidz6h6FA4JXDQhLnJsRoME= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707256234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+KzZqwbQeNdV0pmvYQSEwIojyt3c9wDtFh98zm28exM=; b=tk4aRtnUs9D7/a8Awzi/3OrDatNqSqVL1UJmReDHOs4OtWheTZ/h945zMwvR6FehTmO0uX GZFY+7X5vsUH/z9OWSb7WaMHZVHSwQL6Bpmw10ClU2wqRPHHOeoxMR6PXX99zHEkiRv+T5 hlgGPU80j9BwnG+bEiHQF9tx/esusY0= From: Kent Overstreet To: linux-mm@kvack.org Cc: Kent Overstreet , Vlastimil Babka , Matthew Wilcox , Michal Hocko , "Darrick J . Wong" Subject: [PATCH 2/3] mm: introduce PF_MEMALLOC_NORECLAIM, PF_MEMALLOC_NOWARN Date: Tue, 6 Feb 2024 16:50:15 -0500 Message-ID: <20240206215016.961253-3-kent.overstreet@linux.dev> In-Reply-To: <20240206215016.961253-1-kent.overstreet@linux.dev> References: <20240206215016.961253-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 9371EC0010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: j38u8gm5u75137dhtrj4ijfiub8rq6h4 X-HE-Tag: 1707256235-6930 X-HE-Meta: U2FsdGVkX19hpIdJtuQuYqLCOXxILwbKf9FFxwXKuNNGsHIk+lX0zK9+0AEB1JfMi59hsL3Qo1VvrK3nK8FGe4VCj68xCIEFMV5KhQGeWzM/BbYwoXmyTNKlJukXf2Jq5R9ywHQFvtUGdOos7Lmo/yy8Cq/QDIwcV5KZhyq89Nw/He0BmxK6tTEM+vb5qdPKFJ49eeUowGG+y2tAoTb+6KVHLvbyTvc/+uGQnm82PhA3R5ITgso36p4fIPBO4tOEjSvwImLmuN3pEQAe5X/TmgNTk+GG0PskvpZ+Md2mBX30brkPPHsBBS/hgFpvhTr0tg4QFKndwu7klNu94EmLmkcX4g6hrqAVDud1qSnKUSfo7mGUpoPuiPqYkCcoYpA9JTnUBVnEfgPK0Vq82uyPffRioWVXcS3xnQHi1QuoZp1I/Mo0Tj66zR4idpMEc4bKW6EyGJ2d0BrMBg/bT4/0Bpq/YQLI1nrSusDOyQHa9zvLPvAvbPok2bnWuNLVJz/9zzXo9cercWV+lXvGeKErLdpPEx2yrnvlQx9973qLsQinOLOUm5lJ32EqD4cQzvxm8wxoye1rnLE+7Y2z3TsIC2ISIpxnSXhqK4/VJAdcROy+qurNQY6hUyj7skwY40KVbWrlbX+OQsMZHmlUZiY/PfQPYIq/jedkBZPkwic2n6VmQ/1LIiWkSr7KB44r+nwNzLQUsFZOI/nRPdJcBWzwYM4D/mhQKMuA5Rj/VA1gT5dKiiSJyOPvyRFsrpEPF75c8U3sWE9WCKeCu96IDOHIf11ZiDAtDVoRNcVTk7LN76mXMuTW3Rv2Dgtl0Sn1a/V8+YbeyxQ+7/q0aJFDg9DRT+6UXmGcdiUzXPFniJwgR81ydcx14u/UzJepCkFb2t2keXtOHhjJh1X2W0tDNGI1YAbtMt+s+dAEYXb6yWb6DH5DyesVyap4I45UnYDXrkuVF/0UD1I4c3i1891Od3f K1aD6F1B VxkJ4QtnZEVjvFsFROfinyxxDr4xLp3wp8D9Ulrocuwvn/VF7vwjnh6msQ6rO8mqPzagntjiCTgme7rrSBtnsYVkOt1b/Y1+R8qMg47T5LR2ZhYoaCjimisPMSRhDoZ4IVcbaxshfYay8am2nuuJupBKkXF3AbcQFyJBVTfvaQ+8h4LGKSFvIODeqZcjyZmhAxI1Fl3o4A1hUf4Cn6/FuJXz7kCrs1RQ8xeHAoEHBZ02JIQ0v0xZCVeSX2JdiW3Df7u8pbp0wWZiSM52PW9BWYddLddiJp8lJfwFZT1hxPsbjxng= 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: Introduce PF_MEMALLOC_* equivalents of some GFP_ flags: PF_MEMALLOC_NORECLAIM -> GFP_NOWAIT PF_MEMALLOC_NOWARN -> __GFP_NOWARN Cc: Vlastimil Babka Cc: Matthew Wilcox Cc: Michal Hocko Cc: Darrick J. Wong Cc: linux-mm@kvack.org Signed-off-by: Kent Overstreet --- include/linux/sched.h | 4 ++-- include/linux/sched/mm.h | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 292c31697248..ca08d92b20ac 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1755,8 +1755,8 @@ 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__HOLE__00800000 0x00800000 -#define PF__HOLE__01000000 0x01000000 +#define PF_MEMALLOC_NORECLAIM 0x00800000 /* All allocation requests will inherit __GFP_NOWARN */ +#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 */ #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index f00d7ecc2adf..c29059a76052 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -236,16 +236,25 @@ static inline gfp_t current_gfp_context(gfp_t flags) { unsigned int pflags = READ_ONCE(current->flags); - if (unlikely(pflags & (PF_MEMALLOC_NOIO | PF_MEMALLOC_NOFS | PF_MEMALLOC_PIN))) { + if (unlikely(pflags & (PF_MEMALLOC_NOIO | + PF_MEMALLOC_NOFS | + PF_MEMALLOC_NORECLAIM | + PF_MEMALLOC_NOWARN | + PF_MEMALLOC_PIN))) { /* - * NOIO implies both NOIO and NOFS and it is a weaker context - * so always make sure it makes precedence + * Stronger flags before weaker flags: + * NORECLAIM implies NOIO, which in turn implies NOFS */ - if (pflags & PF_MEMALLOC_NOIO) + if (pflags & PF_MEMALLOC_NORECLAIM) + flags &= ~__GFP_DIRECT_RECLAIM; + else if (pflags & PF_MEMALLOC_NOIO) flags &= ~(__GFP_IO | __GFP_FS); else if (pflags & PF_MEMALLOC_NOFS) flags &= ~__GFP_FS; + if (pflags & PF_MEMALLOC_NOWARN) + flags |= __GFP_NOWARN; + if (pflags & PF_MEMALLOC_PIN) flags &= ~__GFP_MOVABLE; }