From patchwork Tue Apr 16 01:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13631010 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 2E093C4345F for ; Tue, 16 Apr 2024 01:26:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 617906B0082; Mon, 15 Apr 2024 21:26:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C7766B0083; Mon, 15 Apr 2024 21:26:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48F666B0085; Mon, 15 Apr 2024 21:26:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 218706B0082 for ; Mon, 15 Apr 2024 21:26:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BA880A077F for ; Tue, 16 Apr 2024 01:26:10 +0000 (UTC) X-FDA: 82013654100.14.A9ED093 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf13.hostedemail.com (Postfix) with ESMTP id 267AA2000D for ; Tue, 16 Apr 2024 01:26:07 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NAHLlFJ4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713230768; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=dsoSpXtMSBSipwOHRNxt0X9WH7pQGeUcyNwYKgEZLAs=; b=qYNzjpsY6seR2Syop8yX7l3ZD2uBvaj0d/3eRpGnD+ImnZ/UR7IhlM4ff8IOs9NL/AYslm kepk7/2O4Cj3DVif45qtXoMl10SC+M6QZD3b9AbG+t0ghEWktzKKa5hpMzmW7QKObP90ZA y+J/aPzsE8wNngjpQqccr/bMN484Ykk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NAHLlFJ4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713230768; a=rsa-sha256; cv=none; b=l166u4WZCdfLfzk3DP9ZdARq/BL7ZmemOJud+dNGQbaA4cUm5mI3St3ACipJR+830bUZbw FW7lg7hdJ1w0u1+8TYhHzVbBexdQFvHp+Zv/dDYbKxxe1AWD3iCiKVH+nqlTqjknPVTHUq kt5alfZg3OOd0VzWoKAeWVn/NBMJbj8= Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a52582ecde4so241046966b.0 for ; Mon, 15 Apr 2024 18:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713230766; x=1713835566; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dsoSpXtMSBSipwOHRNxt0X9WH7pQGeUcyNwYKgEZLAs=; b=NAHLlFJ4oJkz8ITWQDt8vyWSSE7RI3F+b6ugk+eCxIUBqqbRw+IWCs2UC2cquHSVPO S6u8aIcjhb/pfXBGb8FPwOtitaX4PPMiShiqBeXNoDSf6xR6tX+bLq6joY940XiFeCkI TmQsKVZcXWSvRfBdGbPZbAxt43Tc0P0yh/QCIag9/pVQxBxS4/+PqMDrNMOOyIjWf4AC WIjmXPMH7mM3hgfxkZOKsoPRa67hHgvBbFKIPVzycPDUAa3vUf9g15beijfLdCbx5H6V p+PX5b39ZlBwN9r5bKwqqSG7fL+aFQ+cCaJsvK5993McysdA46KIKDzsD8ECTJrvEgjR PhPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713230766; x=1713835566; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dsoSpXtMSBSipwOHRNxt0X9WH7pQGeUcyNwYKgEZLAs=; b=m1OcefOlSQg0WfZyqc2DsQb4Gc6rBwNyQGpUZ0umV+DGg3I3fEFPGd5g2WIbDUKLAz 4MSCU4OR0VDpX8SBi/OHQEov7f7F/w2QWCIdz0wDlLks6IaqqRlkosD1dV/QBWem0yC3 irZ8QJDVSY3lQP/cgacV0Wn7OFHElIsz1RjhJ1uYQXd8FeDuntOCj/ku7IU06doO3iQu cXy2ghDMDNWIYTTHfKYiACh8O9Y5sgGwLfxj1/6HnPuL6nq0KnaRv6+EzZbsOW4a0B89 ZBjZA2/pP7zYJgYuKpG0RZmV/5sSvjelZ8nuhyNGUKFEqVGkLiNF1Eu4vrFVPOVT864K YG1w== X-Gm-Message-State: AOJu0YwoYN51v5dRmm20Qa9usbmwTJ98OcGWpMTfoQ3NTfcIfYlQ2XUN rtPlcjh2qb1yvOnOLq1KdfGODW8XKRxpq6aQRnoPr+EWXVCMY0qr X-Google-Smtp-Source: AGHT+IHci+aG+RwytIZpTW8nb8o7dQDILtBVwKLVODWi24QrzsAw1BHsyBUGyAB3QMIXvi/fHdyYsQ== X-Received: by 2002:a17:906:f249:b0:a52:4266:8f99 with SMTP id gy9-20020a170906f24900b00a5242668f99mr5629355ejb.56.1713230766316; Mon, 15 Apr 2024 18:26:06 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id qy34-20020a17090768a200b00a51d408d446sm6203144ejc.26.2024.04.15.18.26.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 18:26:05 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang , Pavel Tatashin Subject: [PATCH] mm/sparse: guard the size of mem_section is power of 2 Date: Tue, 16 Apr 2024 01:25:59 +0000 Message-Id: <20240416012559.4536-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 267AA2000D X-Stat-Signature: meb6w9xf9oqwyjcutkojre9z5du159d7 X-HE-Tag: 1713230767-360562 X-HE-Meta: U2FsdGVkX18/eavUQYpTej5byPa0kxeYjvpyw2tLXwy2moQQX6IzqqsEuON3fL+rJYahBg6dSPMKf2ym+PVjltUQaKDypS6UMJ5SrVDSitoKMGRm3ThosaXjPGlRGRlp3TEhsjZ3e46tJPS1UFV/NFzokF9KVWO2Vruu6421SZoxeV2fR6VGQnG3QwXgzIHfrUZCuplFAFCsCOf+tVFLCXRroVBt1wGerT6AstgyfAfgOylYb/1WYsdm7sYVib7/0wik1VeoZ7K0FuxppY4USUjXv34FYGIWfWOs1NJx8AngvkO1LB3HOs8DDvbHjxedPShuHQ+45Hc+kBlaOaVVFKbh1sXoTHRvwKmCNA7oOxuRSqK0DTgbP6H1J/+OuZHq1bVXk56EozkIzSNTkgDm6AUSYIIe1tZAfz9uQbkShli9wp8RO9vaX09+CSYJCrA1x1pJhPjAVHtB4xRyPZhNUGIkOuUV3UtSkYVbYps8ettEmpwcsRa2Q4a/b5hJVJcOy/uUm0SvjsZPDUm9kTtYwCNzy1OaYwg+RzN5bmGVxF2EW4L8jwl/DIuEebiEV5peIGNk4rJ19zw8QmDeMZGkiisL1fGx+imK7wMqtMuP59N33zd3urqa514XuBAnceWuzqqW9Ouxy1/3qnb7pQvc/Im759OVe1s0ZqJRs6YPOfVU5rW8Ppm7+wUgUB9WfJtymtiSzUjALJ6mw4y9qwsHK5fRVP6fenNNVIAvtFRRF8YSJlYTxMsh4yJJlP9+Z5JOLH8vn4chCjgLBUAKkpuUdKtcOLPQ6Ia5PrCRzjOi8gh8uQ6rjGLL5f9XqtCvEdAlz0ur81RlLfWDZFHYF45AW6UmYGnJNxGt/gQ+mhltkLVcfQ5hZsD1YIA+Z9o+gTZqpgV6eazDMKUfGlvaQgrUzr20phkDZXeQUpZ3DxqHseutpbwtFdawzbxl1swL+ODkmJq+BfDbN1KyBXI17+s yNCqb3fA oMtjsp6vMY0IPGXsDUBPb/M5LamdDaiKGKPeWsnMuYGCNXLHtJapjggN4nsqS5tIuojA+k6X6G3xG1mNwEoIDELGlDXXsrAFexel5BtWxEnOviCiv0Zb5xNdOzWLLo1Q0y8LXUlgfHEC+lEQFESO4vCTcTpr2CtwX+e2iNXKdYUxpcIZitX+ReiHiU7AvVB15161TiaYEtVaeys/JmMQzocMshbxLAs56YW7d 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: We usually have this check, while commit 2a3cb8baef71 ("mm/sparse: delete old sparse_init and enable new one") missed to take it. Signed-off-by: Wei Yang CC: Pavel Tatashin Acked-by: Oscar Salvador Reviewed-by: Pasha Tatashin --- mm/sparse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/sparse.c b/mm/sparse.c index aed0951b87fa..a7d92fe7be19 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -560,6 +560,8 @@ void __init sparse_init(void) unsigned long pnum_end, pnum_begin, map_count = 1; int nid_begin; + /* see include/linux/mmzone.h 'struct mem_section' definition */ + BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section))); memblocks_present(); pnum_begin = first_present_section_nr();