From patchwork Fri Jan 26 22:07:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13533386 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 9115CC47422 for ; Fri, 26 Jan 2024 22:08:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D077D6B0095; Fri, 26 Jan 2024 17:08:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CB7856B0096; Fri, 26 Jan 2024 17:08:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6BB6B0098; Fri, 26 Jan 2024 17:08:09 -0500 (EST) 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 A88346B0095 for ; Fri, 26 Jan 2024 17:08:09 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D336880ED1 for ; Fri, 26 Jan 2024 22:08:08 +0000 (UTC) X-FDA: 81722851056.01.B56C8F8 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by imf10.hostedemail.com (Postfix) with ESMTP id 279A0C0016 for ; Fri, 26 Jan 2024 22:08:06 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UZ5p9YY3; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.187 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=1706306887; 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=YczcxWdjrPt2wQaIPeH9YyG5ctLXO/Bap0odgRcP4+A=; b=Yq6pVwr+Opa4aJcK/TmO7cRTigedt0WSAxbkJxUtViOjOSg083mEQGoqwWYxG6rSs14HWw FnSQMgc80JhzfY9mJKnMsu3/5OYD2KnlSAZHSf4VZj+JcQTbrPBAhy/pAj+9zIuHK7Yk5p S4jFYBTSyUAvE+jknwWmN18+msIfpS0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UZ5p9YY3; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.187 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706306887; a=rsa-sha256; cv=none; b=75R8gfG7I2Kz1gMrwreBvq8UyXdONQgVV3BbUJvqm+byFYLvKE/fL8abQEiq1BJIKuv1+G YqX35bn8KF6Q4ZJYrDWzl09/Tgomj77EXZSnUgSqZeTa/xBQs/LyDJIx/IPOuxKmUYNiHw NScOJXR5wow3CeP7zAYVAufRBLjdNhc= 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=1706306885; 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=YczcxWdjrPt2wQaIPeH9YyG5ctLXO/Bap0odgRcP4+A=; b=UZ5p9YY3q52VEkPIHaIq/9xQJPQyflqW0mQGz3B5veLMEWZ2dt/fPEpc+081GeGDRj1+EK uYGxGFByYJUPNq0IRXPl1U4dj/RZk/t5zv9VY9M7bU+2M3BW71ScaDwSaVdzKxBKPckfK4 SbL3I8rYHw5vnAZkkDciTomdeANmRVM= From: Kent Overstreet To: linux-mm@kvack.org Cc: Kent Overstreet , Vlastimil Babka , Matthew Wilcox , Michal Hocko , "Darrick J . Wong" Subject: [PATCH 2/2] mm: introduce PF_MEMALLOC_NOWARN Date: Fri, 26 Jan 2024 17:07:56 -0500 Message-ID: <20240126220756.395187-2-kent.overstreet@linux.dev> In-Reply-To: <20240126220756.395187-1-kent.overstreet@linux.dev> References: <20240126220756.395187-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 279A0C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pnqqiw7zwoww8zo6k564bh9pmmmij9ex X-HE-Tag: 1706306886-712603 X-HE-Meta: U2FsdGVkX18AVIFVr6kqB8fWCskTvUZR/k3rcY0AMOX/Dmowrcr/DMRFqKNcZ8rua+fZF/wCfnEVVT8fmJE2Hnpt7k9I1Ox5zEy7QV4aUo0e+osepZRfroy4rMIlL3Lmm/JlkpUAmPgu+s+nD57IakyQxSR68xPmv94tMJKYmxKuSDaQx3C1Lft52aDJ0ofWOdrYuTUDPNWRr70A3Y7mf9o/oVQTHmhLFfpiMAzoM+yCaDvuiv1HgGFc6kuxYZpTWKkDKrDeJ9Ddkk7BUnzb3VulgIdteQPn4G62WY+BMNUIEJWOFqpQynpLJsp4WzpjPBudPLayYfXbS0JYCX96zmdtm2K7LimAoo32u2wr+9bMXhjWvep+YshNmXE+gNbOF6W3Xit4JtKHNiczu5cjv45B3TTLn08Llfhkio0LrV05lJzPYpBcHQzVtBAWxjijKnFc8mTCmn3Og+WdBbeV96AqcMk/AGV9UnZjpJRzONuUMmQ7gdC9SmXV1EIIitYdsyZNkXTmJ3Te1y+62iSUYi5ptknYrapuQb68VNmoVDv1Ei6YSmUJ5M4LxwTJdV39BCEaSZ1wKP+6fXI9RPEtBdzVaGq3i0t4DCIxsniQdJmB1YEdKSw4PqVqRN0n9zVrSkwLKwwyN2Q8TxtkRuZktOVoAsjMFX5nAgCXnKoX6KsYRq66A8mjUiT9xNcyLixZgDxxsuR2kiz+PKwPpkj9HBx2kpbrxAyf65hZugk9SHMU5IKBHM96CJMX3ogTfezmhOB8gpPR/IS2oKDfeCqfEyv0/gvdwrfnJxfCVkO2ydlIAsWZdk94A/WBqMdQaoWmzBF9o+QdIydh8v34mLWDC1dvKPaTvXNfag50XNctt50G+agv01xmS1EwGNIwvMdAVmfdsDzKo5kEqNDd5IcjM0iwqnfbmcFYBxnD8x+pfIwTfhDh93zDjaE0mydYMmlW13BIWQfXyyNq/ngWtwC acdH9zMp JC7IMEgiG4rkSK0+XT69ZdEpeZCQcob6+Ycc46YwW2ROEA1c9s2XZJ0fTt+TLCavYSQdFamjguUr7E10PseC2q2IJlBAAwhxsul1sQnvD0yH4rY51El0dA2hr3Zn1bIjgmIM6H7SESUjOGWjdliqvzF7pATpITEg0SUjWHMzWXmZkC7iTI2GyGRD1KZv26bu4NSmpWfnzfwSj3xoh/2VpWtlYmdkavC6kYdAAy7q7izKI1IGB8pIHzT2arQ== 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: 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. Signed-off-by: Kent Overstreet Cc: Vlastimil Babka Cc: Matthew Wilcox Cc: Michal Hocko Cc: Darrick J. Wong Signed-off-by: Kent Overstreet --- include/linux/sched.h | 8 ++++---- include/linux/sched/mm.h | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index cdb8ea53c365..36a5046ea3fa 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1632,11 +1632,11 @@ extern struct pid *cad_pid; #define PF_KSWAPD 0x00020000 /* I am kswapd */ #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */ #define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */ -#define PF_LOCAL_THROTTLE 0x00100000 /* Throttle writes only against the bdi I write to, +#define PF_MEMALLOC_NOWARN 0x00100000 /* All allocation requests will inherit __GFP_NOWARN */ +#define PF_LOCAL_THROTTLE 0x00200000 /* Throttle writes only against the bdi I write to, * 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_KTHREAD 0x00400000 /* I am a kernel thread */ +#define PF_RANDOMIZE 0x00800000 /* Randomize virtual address space */ #define PF__HOLE__01000000 0x01000000 #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 f00d7ecc2adf..817f5c1bf3d5 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -236,7 +236,10 @@ 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_NOWARN | + PF_MEMALLOC_PIN))) { /* * NOIO implies both NOIO and NOFS and it is a weaker context * so always make sure it makes precedence @@ -246,6 +249,9 @@ static inline gfp_t current_gfp_context(gfp_t flags) 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; }