From patchwork Wed Jul 24 08:55:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13740696 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 648E2C3DA63 for ; Wed, 24 Jul 2024 08:56:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 966CF6B0095; Wed, 24 Jul 2024 04:56:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9157F6B0096; Wed, 24 Jul 2024 04:56:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78FF56B0098; Wed, 24 Jul 2024 04:56:33 -0400 (EDT) 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 5B4766B0095 for ; Wed, 24 Jul 2024 04:56:33 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0350B80785 for ; Wed, 24 Jul 2024 08:56:33 +0000 (UTC) X-FDA: 82374040266.21.42DE0BB Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf02.hostedemail.com (Postfix) with ESMTP id 2F56C80003 for ; Wed, 24 Jul 2024 08:56:30 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ilSn1cGE; spf=pass (imf02.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721811368; 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=WaowiqzVj3yQOimauedr/ghucF3yzQBuOx7BoVz5+GM=; b=CpZ1porjEf95BUXII+4jSVpIqevnIG2uvkdpVwyqf5FqiuZvB6sXXCw/q1Cqwu9Z3mlgM5 rbPK834iLgVgmJ5QzvWzPHF9YgmsU5eNHXqMoAekC6gel/7ZjjNuEVAvT2JDUJdRPEYEf8 UsgNkrINqycXoskthq9DRcEPMHW9hFw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ilSn1cGE; spf=pass (imf02.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721811368; a=rsa-sha256; cv=none; b=SpAlJ2dXcVQzYcxfy0t4dDIcjka1ZtiUAPQOk0c7LT11MCXN04hKsCpFtf7XlUAKaOvAUv U6W1NAjujTA4ZCEwzqcBrR+Ob/EZmhDQueZHazqxxPl+czEIZnh+mZDFiRIKphu+GGNDzC E1SQL08vSkmiMvBgdPAEA9myqEtDeVs= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1fc587361b6so6868945ad.2 for ; Wed, 24 Jul 2024 01:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721811390; x=1722416190; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WaowiqzVj3yQOimauedr/ghucF3yzQBuOx7BoVz5+GM=; b=ilSn1cGEAu9aWk2dOIS+pWucVybPT8smPh/RMFgdfZ0QuyxaDunmA36kKhj4qma5Rc wM1BmiT7oDnwHy6wd4RGTj9naJieskEMqI7rUx2iRhm/CdxsUASlG2kPj69wtnOJ9fJt Mu7ovO5SG1Q3ufKowVIIdtyjE2ucUofE0q72s+lHIDJnH1twN9oA6EuauDbaelev0fS4 3BgKzDrJfi5JlnSdBtmZKAH82isUuzN+9looFWPaXZ5r3sCYX1/xYhsfeAWLxltwGpWH YOq4wJ4Mi/UWNjxR1zJ9VtaQkb/mVprolUtaJyKdrJilnvLRd4dmglf2h6tLgGf59f00 8KEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721811390; x=1722416190; 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=WaowiqzVj3yQOimauedr/ghucF3yzQBuOx7BoVz5+GM=; b=oFrtmayYZB0+yv0NnS34G6/ouPu5ftisPNblJRai4k9/ViLMT7S2XlHDekDXiFJXWB 9CFJcBmy9WVjpVWeBJFEPxcWLlbAcMB0fsBhullz9glX98g0heFTud0s+OkBKstRtpyL BKOLUDmzhgZOZV8QJXDF+J69aJ6b8WXzdycIpd51zNzgOWrj9umvOE07LVpzMjUegqoA KS0iBR674F8Gby47CADkJq+1C3dXIom704cyfWyZCIEXq8q2g8xI0p+cB+M1gkhZUYaC eMo7pZ+jD2LcumPfVsJbrSPp2sccylQZu+EEogKluts/ngDo9Ldu7KCoGEkeCyrE3eZh NDKg== X-Forwarded-Encrypted: i=1; AJvYcCXHuFoLnq8ONKdNqXQMgkB8o4/j1K3y3Pyqx+6QbpQneTw84ZU+ZIjPbtl1jc+yKvvPFsGEm1LmA2jMlAsWxY5bmYA= X-Gm-Message-State: AOJu0YzDXSFasLDow93tG2KjGlAUe+tcIFEzaI6ywQWkUGp1qGBoCDB8 qS9yHuZMAm+EVBeY4O6iCEd4wfqevDVaLprCT9dX7LdUxpwSrqbM X-Google-Smtp-Source: AGHT+IHBaN5zWjD+QYzelALbqfDtXFJwLgPdUHQr2nxg27JIeStuZsN5ZALjv5EKQtcBJytZ84SsXg== X-Received: by 2002:a17:902:c40b:b0:1fd:d6d8:1355 with SMTP id d9443c01a7336-1fdd6d8198amr11561625ad.17.1721811389918; Wed, 24 Jul 2024 01:56:29 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd6f31855fsm89021895ad.156.2024.07.24.01.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 01:56:29 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: 42.hyeyoo@gmail.com, cl@linux.com, hch@infradead.org, iamjoonsoo.kim@lge.com, lstoakes@gmail.com, mhocko@suse.com, penberg@kernel.org, rientjes@google.com, roman.gushchin@linux.dev, urezki@gmail.com, v-songbaohua@oppo.com, vbabka@suse.cz, virtualization@lists.linux.dev, hailong.liu@oppo.com, torvalds@linux-foundation.org Subject: [PATCH 4/5] mm: Introduce GFP_NOFAIL with the inclusion of __GFP_RECLAIM Date: Wed, 24 Jul 2024 20:55:43 +1200 Message-Id: <20240724085544.299090-5-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724085544.299090-1-21cnbao@gmail.com> References: <20240724085544.299090-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2F56C80003 X-Stat-Signature: bf7gt8st1g8xkc5ktoi7bjk1hsfip7ez X-HE-Tag: 1721811390-869995 X-HE-Meta: U2FsdGVkX1+fK3fQMNAFYNeR7/Vla1Nmj5cLlGtFzYY942KYgfbyvuSMUx8ithIexucwdN+L7B/GgdWGRxTCSgVAbZVxz5DJwZ4AQZZ3MR0RfUf2L7IjGvT7rPF9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UNJli3WhgZP2Vb3vj9snM1OHmNAVr43d8OWqcktJk3vyN5dHJ/wdd0LcDV1Nb7IRUC1BKgwCPtbk7/Vd1iXS5R04pAIrVM6mnveNOnbOknoDn8T/vNcg/gM/rN1x8LL1oJM/S+o+RKmYN+pnMC8g+hQlGYzbn8VeWx3/h1hbpsQ+IyidNgQ1+TyGuTXCl9YO8Rcg/hSTy91R9h6CHlcN+1e8Vj2Snpc6hCNhZmgfV957/KtALDFpYHK3add6YrFLt6RqbmRgY3iLoFL+51i016lVuvYexINz9U3F6Rlcoppns4Q0WDBr/gbDMvxLgveH2E0OSc/rVpClZsKmCoRMCJ0pA= 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: Barry Song Introducing GFP_NOFAIL and gradually increasing enforcement to prevent direct use of __GFP_NOFAIL which might be misused within non-sleepable contexts with GFP_ATOMIC and GFP_NOWAIT. Signed-off-by: Barry Song --- include/linux/gfp_types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h index 0dad2c7914be..1666db74f25c 100644 --- a/include/linux/gfp_types.h +++ b/include/linux/gfp_types.h @@ -339,6 +339,10 @@ enum { * recurse into the FS layer with a short explanation why. All allocation * requests will inherit GFP_NOFS implicitly. * + * %GFP_NOFAIL employs direct memory reclaim and continuously retries until + * successful memory allocation. It should never be used in contexts where + * sleeping is not allowed. + * * %GFP_USER is for userspace allocations that also need to be directly * accessibly by the kernel or hardware. It is typically used by hardware * for buffers that are mapped to userspace (e.g. graphics) that hardware @@ -378,6 +382,7 @@ enum { #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM | __GFP_NOWARN) #define GFP_NOIO (__GFP_RECLAIM) #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO) +#define GFP_NOFAIL (__GFP_RECLAIM | __GFP_NOFAIL) #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL) #define GFP_DMA __GFP_DMA #define GFP_DMA32 __GFP_DMA32