From patchwork Sat Jun 8 15:21:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leesoo Ahn X-Patchwork-Id: 13691022 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 781C4C25B76 for ; Sat, 8 Jun 2024 15:21:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D3B46B0088; Sat, 8 Jun 2024 11:21:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 983D86B0089; Sat, 8 Jun 2024 11:21:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FC486B008C; Sat, 8 Jun 2024 11:21:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 622256B0088 for ; Sat, 8 Jun 2024 11:21:37 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 122A3A17F2 for ; Sat, 8 Jun 2024 15:21:37 +0000 (UTC) X-FDA: 82208085834.18.F1BB8F2 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf13.hostedemail.com (Postfix) with ESMTP id 37AD420002 for ; Sat, 8 Jun 2024 15:21:35 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ChB3A+kF; spf=pass (imf13.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717860095; h=from:from:sender: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=g+bAMmPzB9gsmQSRxGIuKdSULelXghzr1XiJuVK629g=; b=l3v40JbGJVNZ03yPe2jWPGkpoEUt35i1u1VBC2twslAmkSY/teHQCUCF0OyYV0LYK47kiC dJmBM6yi2NPH+TjCaNVIc5ngM/LIKIoWGMKr+L2ZR7CxnerQP7Y62FekP693DNVQi4WTGu JrKgU5hixYM8n2JtIQ4L1sKts2POPxc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ChB3A+kF; spf=pass (imf13.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717860095; a=rsa-sha256; cv=none; b=yTHeP0Bz+UNPXsikoYUPbRAz0nndcl1wPaf4NtcOoLzfl2jrqjhE5LhSkxIeWqg5seOaI+ ZGGwBJ0QhBJmDi3cV8Tl4iIEjGgeDUEz0jlqSMojWNH3yrhVrZxxX0lSTyRYPVIRbF3zy4 k2Mq/g9aDrRPbNEqA8TN4nadvybJUDs= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7041082a80aso1259380b3a.1 for ; Sat, 08 Jun 2024 08:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717860094; x=1718464894; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=g+bAMmPzB9gsmQSRxGIuKdSULelXghzr1XiJuVK629g=; b=ChB3A+kFW0PP4tzQaAMxVXVqWdHXBMizczzkG9LDoywynvwXO6wkc1u755iuOcLvDr J/Q5iIx7SRi/ZkNQ4f8MWdVmLa7rfiWH4qboexOPzSO01lo/kq6Jz7y2ByZe0NM87aux jtkFKoXWoIWhuhg4/2gwdZq5p2nQsHRyY5P7k3nr2irITNDkPtMCGq8ibZAPzVAFgz6Q hO3XCcrzfj75PvXjJLDQZPQb2y1hBP9N/y9xoMAxq74sLQ7CdSBq/kAMZANIJPtxQGCE 1Fcda+3uYWZIqd/Ox0WrAltyIASoluzBat0cmvJGGvYqHD3I6R5SOVsoEa7hqW73lxWv fcyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717860094; x=1718464894; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=g+bAMmPzB9gsmQSRxGIuKdSULelXghzr1XiJuVK629g=; b=Mn4l2bWs9khzaSphqdBymmf3lJcJThueTOBRnNzaqGkgqQuf9cpVE2fiPKAK2wWNro Mcs963kRTvu+sdHW4Q4nDmvjb5hHEQquHcVZrDXAXunoAFaI2vvtvRJXsHGkc0l1xxjm drMhiSG6zvbu/MztUIGYTfaPYEPAqlOwKyFuoCyAuOYgjPJb8upGCmUHXDInSf2if4AL /NWG0OKdFH27Sw1AqJp0aCjGURAXw6cCJPOhRui8X2z3Wm4E1aS5vQ/Dm14a/dbyNjcU FGHd7p9zkkFnS1uyu6jm4ZW2SqDv81cuXD80Qnnu1aVK0D5EMDtyWw4p7d+3iy9QeMNr sRhw== X-Forwarded-Encrypted: i=1; AJvYcCUV2bH/jtuj5gLS6/0spyjPk7IIisaBLPHi67fZjlULNMlMoctkX/9zMaZSsANDDqfYt3PZcNeiUm8Fs3qylh6TmS0= X-Gm-Message-State: AOJu0YzGm8c57SFucZOwRjWkx3z5taRADxTOr3ao9bfGsMUvVvCMntDf iTir2fuJ5cge7k9w6kJa9E/E5rkZDVlahguFh5kO9Z6aOyS91CQY X-Google-Smtp-Source: AGHT+IEM4r5VaFC1ZJ2Ks20iVPWPVgVeDAzF815iSNkzOXJ3tTxa0EBMW/xdG2gpEZc/4o8+r8atGw== X-Received: by 2002:a05:6a00:2393:b0:702:4139:7584 with SMTP id d2e1a72fcca58-7040c649c24mr5693476b3a.9.1717860093896; Sat, 08 Jun 2024 08:21:33 -0700 (PDT) Received: from SYSOS.. ([115.178.65.130]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-704207547bbsm1526565b3a.204.2024.06.08.08.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 08:21:33 -0700 (PDT) From: Leesoo Ahn X-Google-Original-From: Leesoo Ahn To: lsahn@ooseel.net Cc: Leesoo Ahn , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: sparse: clarify a variable name and its value Date: Sun, 9 Jun 2024 00:21:14 +0900 Message-Id: <20240608152114.867961-1-lsahn@wewakecorp.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 37AD420002 X-Stat-Signature: iyd5pcsic5khwmwjmgwp5y1bu9xfc9ne X-HE-Tag: 1717860095-604653 X-HE-Meta: U2FsdGVkX18bnYbX8+/VZ6V+LIsU5d2Teg9/QDtLEjlDJvR8H2rSifi5kN9N69EyBgcVUCGPAbSDkXfwSjsMiCc8yZkbtLAN3g+/D6NfXNv3AmZodwNxaAAuCV/ERS3LqmJLuKr9Jku5TKTuzetaIBgk1BhhCWE/cD4eXcAbTJZOTR3ykgyU00qyjLyvHn0ZUSYhGGk9Y91cjaLztsC8fR3MgXA8SqGLQb3K2pTC22W851xpoNgRF5/WpBqCkB3qt4X+g1bzIrP3Y6+0ThbEfM6tayDOzmHYTvBVDPX/4LIAjFJvsyD5vde0JKLrAj7e88q4ZgskSuUvVwKnNt+akz+WW3bPdo3cyxGBXT/YBAZSRUKA9Gmex64190+Cv04DXmwVciYE/1bKedfrcOAzVpDwrW3O6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ogofilter, spamicity=0.002299, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Setting 'limit' variable to 0 might seem like it means "no limit". But in the memblock API, 0 actually means the 'MEMBLOCK_ALLOC_ACCESSIBLE' enum, which limits the physical address range based on 'memblock.current_limit'. This can be confusing. To make things clearer, I suggest renaming the variable to 'limit_or_flag'. This name shows that the variable can either be a number for limits or an enum for a flag. This way, readers will easily understand what kind of value is being passed to the memblock API and how it works without needing to look into the API details. Signed-off-by: Leesoo Ahn --- mm/sparse.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index de40b2c73406..80e50ba26f24 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -333,7 +333,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, unsigned long size) { struct mem_section_usage *usage; - unsigned long goal, limit; + unsigned long goal, limit_or_flag; int nid; /* * A page may contain usemaps for other sections preventing the @@ -346,12 +346,13 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, * this problem. */ goal = pgdat_to_phys(pgdat) & (PAGE_SECTION_MASK << PAGE_SHIFT); - limit = goal + (1UL << PA_SECTION_SHIFT); + limit_or_flag = goal + (1UL << PA_SECTION_SHIFT); nid = early_pfn_to_nid(goal >> PAGE_SHIFT); again: - usage = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, limit, nid); - if (!usage && limit) { - limit = 0; + usage = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, + limit_or_flag, nid); + if (!usage && (limit_or_flag != MEMBLOCK_ALLOC_ACCESSIBLE)) { + limit_or_flag = MEMBLOCK_ALLOC_ACCESSIBLE; goto again; } return usage;