From patchwork Sun Jul 7 09:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13725990 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 AA4E1C30653 for ; Sun, 7 Jul 2024 09:50:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E78656B0089; Sun, 7 Jul 2024 05:50:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E27116B008A; Sun, 7 Jul 2024 05:50:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEEC16B008C; Sun, 7 Jul 2024 05:50:38 -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 AEC7E6B0089 for ; Sun, 7 Jul 2024 05:50:38 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2C77380D17 for ; Sun, 7 Jul 2024 09:50:38 +0000 (UTC) X-FDA: 82312486956.04.7B0EA91 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf06.hostedemail.com (Postfix) with ESMTP id 5C325180007 for ; Sun, 7 Jul 2024 09:50:36 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LoXgOXCq; spf=pass (imf06.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=laoar.shao@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=1720345822; 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=eHY9t9f2nXb+wivtFSZFhOpolrGiFvEp4lIjiX9vV38=; b=rd7YKAt5ktNF7yfdDT/Ji6zXlijhUVFx1nIL08qci4AdXM50ajkD7DeaH1bMwoVLoxtCYk FAxwvwLcY0hgfUnYVJnxKbKkn/qEZceawpiOkyIa84k/P31kQA8UfXnGBZW0H3OLwJKU9u qgigC2Dj4VCqcnBToaFopZ3BC9aDVOg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LoXgOXCq; spf=pass (imf06.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720345822; a=rsa-sha256; cv=none; b=3vrHtTPW7Jt19j1n5kMPqNiS96PNTxIacEsMEfiJY40H4UTSVWFP1Ne8R0ir9MuU3dGq2p JAYEu0QPrA3pcBe6T+0m2wCa5z783TvP34B/rBy4+0QnrX2c9pIgBWLSCBX/O8BPAaufty nmxGlAdd+bvwN0WrN51AmYR3iTB5Wis= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-70b31272a04so11337b3a.1 for ; Sun, 07 Jul 2024 02:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720345835; x=1720950635; 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=eHY9t9f2nXb+wivtFSZFhOpolrGiFvEp4lIjiX9vV38=; b=LoXgOXCq51JWrJdKQgc7MnsIIRj1MJ6Bt7iyrNB5tI7jO0YjTT2DPrq2Bwpv5GEbF0 NuR5vW7UEjMG77uybH2nFVEh8aGU+Xy9Y8sKuPq+NBdi4LqhvS1zEVx8c0+Oci+8xcZj OuwtVUq7zd96a6Vels2STD1D6J/9z9RywaCspIMJq0FZL1uvmoCSspG5ikpfysWPTmQ4 auk58o/tuAU3qHlnf18Ks5HTt8lftekAIIWrfv3fmPIp4qfhNP4VUA/JEhhqiEs3M9aC pWNG/IgWedRoXpPnsO9S4K0eqW50OQRPHH2exyLYkLAy+OvepaDyTEA/ltbl0QAxq6K+ wjIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720345835; x=1720950635; 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=eHY9t9f2nXb+wivtFSZFhOpolrGiFvEp4lIjiX9vV38=; b=qn6HxXXcrioSILXKP2jrW5Dkb7Axl6nxRvnBEJ03lX4JjVq/WjtgTWx74d7y+IOkFp DExirrAVAX/Ets+WnyMusm1XYieAW+yRpsKOdbRHQeGnNu8EomrjoodOAnluBATq6Pe9 3cgndrhWO2+vSNKWubkIhK+AUnw02pRIOub1a5MNkTF/gREps5S8tQLtER8VoU8JMLvu WrcTAH62++Yp19UQEUdcgqFjrvMMl05NOj6gCDoFs0qokxqXCXSCTF6wNsZCE7SRZ8of TX/+3arACKGogwV6MW4jKBw3TezPfzKMhXE0OwCkPGjG33c3T4yRasF80G4d0IIKyR5W ByqQ== X-Forwarded-Encrypted: i=1; AJvYcCWVDvF9BcthDfl0X8OX08wNx9cEM1bhbnI0WJ9Yv9j6vQh7lFDztwHsYQsOA12KB4VWUO5TZa3CN/qmW4ub95L1hZc= X-Gm-Message-State: AOJu0Ywur+Wu9ETBiJqf1qA5qhh6nk56OaEs2Wj3QicFp5w73lXI8t8b DwtpAfY8KtzmhSdnQaEWlQb+CFCK1jz7yU/W8EXBUAFnbEJOfUw+ X-Google-Smtp-Source: AGHT+IFD4VCZPhcPm2Rk63mPUix3jDHrVISF+2jKDO75i/IpB19bfGUMK55l/v+7yOpi8L7by6qmNg== X-Received: by 2002:a05:6a20:3d89:b0:1c0:e673:736c with SMTP id adf61e73a8af0-1c0e67375famr5151048637.3.1720345834895; Sun, 07 Jul 2024 02:50:34 -0700 (PDT) Received: from localhost.localdomain ([39.144.43.178]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b1fdc335csm2184601b3a.22.2024.07.07.02.50.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2024 02:50:34 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org Cc: ying.huang@intel.com, mgorman@techsingularity.net, linux-mm@kvack.org, Yafang Shao Subject: [PATCH 1/3] mm/page_alloc: A minor fix to the calculation of pcp->free_count Date: Sun, 7 Jul 2024 17:49:54 +0800 Message-Id: <20240707094956.94654-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240707094956.94654-1-laoar.shao@gmail.com> References: <20240707094956.94654-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5C325180007 X-Stat-Signature: md61anomr5bt8ztjx1nsxgia3okbda4x X-HE-Tag: 1720345836-502057 X-HE-Meta: U2FsdGVkX1++3/5HbFrDjHlV+bJPVMmeAC6puoOk41S1VyR0iMe5fPrTe+Pgt+jwxbo6hby33Lctx0tXSZACtL6AROcYCWYRRFuipkTkVxG4d25SJEyYu+U9e2sMypdMk9OqVnzbkQbLY6TglQVMtJRM/3Ns5lyQAfab3SnzQqMA60R2lNMRs0mSyuPupwtf997kQmOoXmhKOe0vlwnPMaj2VXGzWx2t7xDiwsW4ciYiH/ukhvbJ3Tn0ewwjCEuPT4NzXHk+7VUwsM+pl6I4czckjaXL2f8jyBvXLYbEKi6jmy5Qtc7ixtB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dLfmBbC7RZT3KsH/h344VStq3/sxPKtpwVFZ1cvOF1XTTr5buF4FOwlXD/Nddrbjw8oUHosUBB8XWDHz2CqEjF1pBErsL7ZAwQZMKpi1JRYTgc67c4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.006057, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, At worst, the pcp->free_count can be (batch - 1 + (1 << MAX_ORDER)), which may exceed the expected max value of (batch << CONFIG_PCP_BATCH_SCALE_MAX). This issue was identified through code review, and no real problems have been observed. Signed-off-by: Yafang Shao Cc: "Huang, Ying" Reviewed-by: "Huang, Ying" --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e22ce5675ca..8e2f4e1ab4f2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2534,7 +2534,8 @@ static void free_unref_page_commit(struct zone *zone, struct per_cpu_pages *pcp, pcp->flags &= ~PCPF_PREV_FREE_HIGH_ORDER; } if (pcp->free_count < (batch << CONFIG_PCP_BATCH_SCALE_MAX)) - pcp->free_count += (1 << order); + pcp->free_count = min(pcp->free_count + (1 << order), + batch << CONFIG_PCP_BATCH_SCALE_MAX); high = nr_pcp_high(pcp, zone, batch, free_high); if (pcp->count >= high) { free_pcppages_bulk(zone, nr_pcp_free(pcp, batch, high, free_high),