From patchwork Thu Sep 5 09:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucien Wang X-Patchwork-Id: 13792072 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 65030CD5BA1 for ; Thu, 5 Sep 2024 09:52:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B0DA8D0008; Thu, 5 Sep 2024 05:52:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 738298D0002; Thu, 5 Sep 2024 05:52:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9068D0008; Thu, 5 Sep 2024 05:52:54 -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 3313D8D0002 for ; Thu, 5 Sep 2024 05:52:54 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 984B1AA04C for ; Thu, 5 Sep 2024 09:52:53 +0000 (UTC) X-FDA: 82530220626.29.40331AC Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf30.hostedemail.com (Postfix) with ESMTP id D39C480010 for ; Thu, 5 Sep 2024 09:52:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c8bvJPcP; spf=pass (imf30.hostedemail.com: domain of lcnwed@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=lcnwed@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725529922; a=rsa-sha256; cv=none; b=fmKCrqZjdRue/2JWSRxX31ZX2tNu1i5tJ9AzGcxqxsrWA7kS/jdbZgkU35+ZaD5NPr+IN4 1JX5yvn2nviDbXHnDEg0q2hBBOexRWIoSl+f32nCyQEYWFM2s9f+sksNeVPF7qmtNbMG7n s0f1MVSpJFL56vKpD5B2GuTvdv4Z5fI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c8bvJPcP; spf=pass (imf30.hostedemail.com: domain of lcnwed@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=lcnwed@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=1725529922; 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:references:dkim-signature; bh=02/uy/7+25tcFKpRbeJa3Z8eQolu7MZ4cB3OwstXuO8=; b=0tvBdp1+P/lNcoGsSdPD4jngNtZnoQmkw2A3Y+1PMrkJ5z1kATbdMd5Z7f27N8WdwlWf47 QGV/NAkhgiKSV3Lhc9GVGjNOp2FVqCybqzUJ0ccbCluPTm3L2podpm01lB6Pnnoorold3u oRqLgyPNAKRLVCizeYbjhmgcFZE3V5E= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7b8884631c4so268853a12.2 for ; Thu, 05 Sep 2024 02:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725529970; x=1726134770; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=02/uy/7+25tcFKpRbeJa3Z8eQolu7MZ4cB3OwstXuO8=; b=c8bvJPcPtkrz3RnpBG3xiL6yC4YLp2vcH9uoqI9TDyjrLxOCGoJ23I+xm6l5BJHja+ KwYV1ysmfuVcTC/Myz7Z2mwwKAuglAchc7zWAlLVykEbw7OqyRNC4SwnpSCpvzEmSFqS 9w94+abKnwjDH9fHlM8ur1yjqMuPRXQh0L8DAkqiMnCWiItjNpmrOXzWmySoiKZSH4oK RTpkmXprYbLT8HHQxfUs0/VSgjijnmaB6H/d3wqMBR7MpKptKlu4S/WugegiYMQXu0sB LRV0wV7kXg77VOzBFJihtXz8s6OLaswr0llvRkOa9BxJfaE/3+2l1vSBFHWV8xGIcWMQ zCsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725529970; x=1726134770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=02/uy/7+25tcFKpRbeJa3Z8eQolu7MZ4cB3OwstXuO8=; b=I0qjTJoM9MkRhG5x/WISX6WIoX6yZFErRjchziJOILwnWo2TSClg47mzCtGs8lzoXx 0GHLTpmEJ9hcdgqEnSfNw/VOLPBVKSaxfhJoz5PiElMjjk+ARM0BeMxHpjolwdbprd3R dysQE3DlEpVRUf+ALZiTfDmUAtLo+kmg9JJp7yIpzpkdV8TDlXs9hpYwOw7dn9YLvYHB uIdzrh+B4U+xbb2VIh1wQj//55p3xa6BH2diih9dM6styaQhBZh4FYn8urccSg6WNt90 DnVlR7lgWc+B3PBtTOP4MHVK2WBrxNXeWtBw2cHU8VXXTUdpmVpCNn2juqGX29gOjcb5 FJrA== X-Gm-Message-State: AOJu0YwAyOwzbvNeU+cDhG1rtRZ/GIYF79KtzpCg8wF2c43ktOkYT9+4 KnDYmRDLGTZo+cMIq5udXuZrQckApA1zfqdyZGooA52OtfCBuUMp X-Google-Smtp-Source: AGHT+IF1TQGvQ9Uw4JQocrRBj7ITBar+56VGGpVhL/etHwEFalxxKCYcL/geA5TzhpYyWBlN2mI1Gw== X-Received: by 2002:a17:902:f690:b0:206:a239:de67 with SMTP id d9443c01a7336-206a239fb32mr71910745ad.18.1725529970181; Thu, 05 Sep 2024 02:52:50 -0700 (PDT) Received: from localhost.localdomain ([123.124.208.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea556f8sm25578455ad.198.2024.09.05.02.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 02:52:49 -0700 (PDT) From: Wang Yibo X-Google-Original-From: Wang Yibo To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, trivial@kernel.org, Wang Yibo Subject: [PATCH] mm: move bad zone checking before getting it Date: Thu, 5 Sep 2024 17:52:16 +0800 Message-Id: <20240905095216.7888-1-wangyibo@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Stat-Signature: f1nne9w3g1h7nxhctpgffu4k3itgkojb X-Rspamd-Queue-Id: D39C480010 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725529971-588505 X-HE-Meta: U2FsdGVkX18tjZdK3xZt0/8ObbLSQuLlplISX8WUetDZRcguW9bBvGLdHtdj0pmGAhQt9nar8nh728CeUHt2rSf2wY3DoM2Lh0ykE7dJyws5/FWnwIOCuEkGhWRgxHoaPKFuf5ekl4M+jj6AKDANeEAhU0Cno3O7ZITAaEYrTGe9OSbPCP43bcCf2xeh0GMtLWv55/4oOGI6uRtXBXetnogvvmluNYlWFHyFoaOC47phkio89YFbbgW0Yl8ZSRxPd6P+gOvkH80B+xPFMS/rFMravOxt6zFCbFCYi+6tz2zOZ/YHaIenrHFYyiulYJitd9MxtyTzWshCcB+a+jb8as854rRGlH+72vugpAhCJo+ERSm+h4gl1vCeEhl/ME6TnGr6O3ZQif1dz6y/Ab3CkhoLRFznFO6hzakLZKklN7zevwiqu/3zAwKthTSIcEBAHkicAl2BBz8JvON5TABPNOvrImF3ljO0blTQ7h0sEK6QwnLrvbTCp2YlQR6l9jQXsn1aMCE5Nx4wreT9aEfyGfak8sWjrOBFFUZZ0atEvrBxZX1YhiH0iSB6j2tSOohqp0omoEWDDgxU9h20AGnYqHUBe11b1iWtCwQbnwwkLFU/JbUaEk1OydLL//U8QkqnFcU9mB9O/i8oZenifzoVHnHLycwJpM1OAh65KnkEpr6cK6gqg2EV/jCPV0K4W+rHqki63RD/tvOtDCxTOsaP1POjNmX648KuhSIP/Xx/lEZjzaCAJvqYU0N0jMafXOXosVvjYNUiYh/yB6jM9Oa0vnvuABD7f6LogeMmM5pT1ifH5yp2lqpuKhxeHHJomNkeDkqKcebjj089Z3bNV4nI60LU51qDX2JUSjDl1xk3jqULXZxD9OwsMm6W0Z+5rYP7s/e2hDscFdw+qOWfW/mO9wF2TOJhsovfPd8c5lAga0GeGU6sA853kwHqChGQFAmVFb3nDlwxAI0eEMWcmjX UtMR/8lR 7LSkd/R+P5ofrzhjpnbDFyrHlgev2mOL8r0gx+9u0jzSJcyQ6B52ebHb9Q/983CaBltWOROEiW2w+39GqkNND21ZuQIAJ8/8gtcmpItYl+j75+YRWYt6AcJDZ0VZURHUOIPdekQo4X6RBaF4zvdfE9FX3/sXTK41R7LmGW82R1lHzCwhHWMaXtuGxptsb2ptMBNQOwjeaBbDn17eTshNwM6Qo6mSuGvS0i1xxuUtLLBevLelVEUG1ePpgZKGY7m74lNx5Iq74bg9OGtquRZT/+ItKvU76kAXykHq1P8iCvQ1ooiQvagboL5melFqg590dnw1B4FGJwJH4hzukspaH1t6iiZ+TfQxbaMtnVnDzeLA/yA3LVbR5f1CxuA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.002416, 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 from gfp_zone() has an error combination, VM_BUG_ON() should firt 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; }