From patchwork Thu Sep 5 10:48:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucien Wang X-Patchwork-Id: 13792147 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 1B7A4CD5BA6 for ; Thu, 5 Sep 2024 10:48:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E1D66B0349; Thu, 5 Sep 2024 06:48:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 993276B034B; Thu, 5 Sep 2024 06:48:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E2736B0346; Thu, 5 Sep 2024 06:48:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B7B36B0342 for ; Thu, 5 Sep 2024 06:48:20 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F0F5E1C5D0C for ; Thu, 5 Sep 2024 10:48:19 +0000 (UTC) X-FDA: 82530360318.08.85AB32B Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf09.hostedemail.com (Postfix) with ESMTP id 14103140002 for ; Thu, 5 Sep 2024 10:48:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ks+AIT+N; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of lcnwed@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=lcnwed@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725533273; a=rsa-sha256; cv=none; b=PJOz503dqndtiHq12S5Rtg9C0CQWZjGKnaM9t9RuYz0oviaWwALwa7+p8i/RhL62YElAVV 7hafO1Am1VmuHh6+F0kHpSE2YivNqBXQtsBYvsXWyvS3YWILgYtkUezp5U1tMPvK5TVXI+ UJC/NUtkYrV84F0UvsHpKw3uZYtSxhs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ks+AIT+N; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of lcnwed@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=lcnwed@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725533273; 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=j5JosH/TSZ+3z0V86f0XRHzDYZAZDYK98WtJ6SVh/pU=; b=MjwtV2+AqqFsJ1FhHQhbV0cKyRTPZTAZusFOsPQ6Bej+3baZhxMa1n5DbXsSewyijfu3H9 0PaBPf+nexSCLRa/BAsU31lI/wXNU9gvXTWeUZ9ATtrj2XQOotHHa58/0CEQQLbuh5p5Og 1cpwOrZAQ6IUyv4En/Iy2BeH4fY+5Rg= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-7179129a13cso276437b3a.3 for ; Thu, 05 Sep 2024 03:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725533297; x=1726138097; 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=j5JosH/TSZ+3z0V86f0XRHzDYZAZDYK98WtJ6SVh/pU=; b=Ks+AIT+N8YcMR6gYOj4Y7161RrCThcbeF/7doSvFPP0f8UuvjboMnBXbti1HHgj4Eh aJ82GCY+MbUXm268SDYLEtSOkKJUBt8cfC9ifiG2VzvAya0hwrpxY/LJn1mVhLyII4Gb IoYpE1yAMk3R3KJqieKR2OISL+XYJwTSeoam/Tzu79pcEWeejCWCM2TM8u4BtbS59eJH gXhavlbQCzdOPksHahtFRFD1h53WSRFOrEP89qihfVUQKopVMyRrOIn/LlciilweRDl1 XIbu/UW2Tz/eRz32FOtmYrZ5/dtRpKJTsb/xuptg6trabvtiSfJHcE5+ciY4VNTmwbkv UoPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725533297; x=1726138097; 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=j5JosH/TSZ+3z0V86f0XRHzDYZAZDYK98WtJ6SVh/pU=; b=Ozkq95a04AluMAcq+ebTIaSvMv012mZAnnTzzdcChCtNpM3BRkRLA48lvHSC5Pgdg5 cpJia46WmUTP+O5d0Pq7P7AbWfbEL42p6c0DwHPCgFeT7rTlzrV7iWE1g3UCRxhwbLMt UeIRIRCp1H+GUnKjbaNU9qjhXiFe/kphtrzJUD+r9gcsX7l32j9CFImBO7LE+qVb3Uuf E0n8wRRiE1bVhw1BXUPGcEG8w25WIDJ93XslbCMkZZaxjmOuNYfhAOjO2wd5PmVeITcY HCG/WHntZZUiHWp5lMrw9B0LLrSTLpDG9IuYR2lBajJdLYpalup+cN6Cn3TA/r1QQiiM CDyA== X-Forwarded-Encrypted: i=1; AJvYcCW3bXNNNmnwSqet0+dJ2yE2vDd7zRQUtvpQhKxmAQF4rtbPsbRW84+6EjsD5Vb4bn+g8+415lvMAA==@kvack.org X-Gm-Message-State: AOJu0YwOXrc+rilpB1NAJxgtUnVm0L1LMj2DkHLWlbsmp/zY0PR35ocJ 6Bz7ZAep+DAso9Nhse8dcUuidwvqouEooe1r646Cn1fu7R7jZNuZ X-Google-Smtp-Source: AGHT+IGYmeg+4H/omJ8PsGV3QMhUTQ+JAfAHbF0G5LI1fc+8R87Zg42A5ahkw0md8zVte5a/+X5vJw== X-Received: by 2002:a05:6a21:6802:b0:1cc:da14:316a with SMTP id adf61e73a8af0-1cce1011e17mr24686188637.20.1725533296751; Thu, 05 Sep 2024 03:48:16 -0700 (PDT) Received: from localhost.localdomain ([123.124.208.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7177858be84sm2976947b3a.110.2024.09.05.03.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 03:48:16 -0700 (PDT) From: Wang Yibo X-Google-Original-From: Wang Yibo To: david@redhat.com Cc: akpm@linux-foundation.org, lcnwed@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, trivial@kernel.org, wangyibo@uniontech.com Subject: [PATCH v2 1/1] mm: move bad zone checking in gfp_zone() Date: Thu, 5 Sep 2024 18:48:08 +0800 Message-Id: <20240905104808.27528-1-wangyibo@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <50595531-87b0-4420-9624-948810066a6e@redhat.com> References: <50595531-87b0-4420-9624-948810066a6e@redhat.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 14103140002 X-Rspamd-Server: rspam01 X-Stat-Signature: gsh1bytdqpm19nrw47pgyd31ataibari X-HE-Tag: 1725533297-840054 X-HE-Meta: U2FsdGVkX18wOlxjnyTDpRE+PMfHrXTVkCJTryblRhcvZEoNQQDOjzWYB+xwM/X0dhUxYNTh8VQrwQ9uS4UPtvIr6aGx0E8TftyrjCNKPO8/QlyAx5fv5VArCguDfU6hUvW2SC+ipIZmhPSX5YLJxogL0fM1tLQ05yf6lXGdBG+I3FZgi/pu8LN8syQL7e/C6inZ2bMM1+P+nhSFOcwrX0JAKkqkMaZEFliOWQAa4s4f9pQVjUaa6yYCbbxB6Wj24Tp3XCoOSMlKTlWr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fQV/xPcX7Xb+bT6Dzu4IW1ddcQvQGTc7Y9n3kVI1DAf/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.034462, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When flags in gfp_zone() has an error combination, VM_BUG_ON() should first know it before use it. Signed-off-by: Wang Yibo --- include/linux/gfp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index f53f76e0b17e..ca61b2440ab3 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -133,10 +133,11 @@ static inline enum zone_type gfp_zone(gfp_t flags) { enum zone_type z; int bit = (__force int) (flags & GFP_ZONEMASK); + VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1); z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) & ((1 << GFP_ZONES_SHIFT) - 1); - VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1); + return z; }