From patchwork Mon Jul 29 02:35:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13744204 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 31A90C3DA64 for ; Mon, 29 Jul 2024 02:36:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749316B0092; Sun, 28 Jul 2024 22:36:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D1F26B0093; Sun, 28 Jul 2024 22:36:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5247D6B0095; Sun, 28 Jul 2024 22:36:17 -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 28A556B0092 for ; Sun, 28 Jul 2024 22:36:17 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D82CEA3636 for ; Mon, 29 Jul 2024 02:36:16 +0000 (UTC) X-FDA: 82391225952.30.3ECC75C Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by imf25.hostedemail.com (Postfix) with ESMTP id 0CD47A0011 for ; Mon, 29 Jul 2024 02:36:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Jn06+/50"; spf=pass (imf25.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.174 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=1722220533; 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=jg0luuKQzRJAO26CkBsWiEMjPCpDdgcrqFNhbhE58Hk=; b=JhhvZ8NulwVn7eWjC9Bxt5cMakKQ2cBFVfvS7vzYzCk8OBl8vPE8Jgr08cFUbsrnOyWzA0 9lcvFiNIlGZYPjyLVieqyumKCwy4yJe5rzFSI/q+vWIDPjIe4rYWKiYRzpVfayqbqzcd66 pe1OgZHXe9NZUFjJcOtMxEIHDxdYP64= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Jn06+/50"; spf=pass (imf25.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.174 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=1722220533; a=rsa-sha256; cv=none; b=a1fGVE5WH8goWkbnl0Ou0iMEVE8Gd0v0GNQY8Sb3nSYod4O2icsUpXyjKa3Ixo+hsfJyA4 fOcCz8O59I5xbvltS7xMyBzNeE/QN0HWZT2ADOZw6NOMjg82pQv9tF2+m3zOlYQ0Q3AJIV 6SToZMkrrZyg85A8nvMc3phHYo54W2k= Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3db14339fb0so2108286b6e.2 for ; Sun, 28 Jul 2024 19:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722220574; x=1722825374; 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=jg0luuKQzRJAO26CkBsWiEMjPCpDdgcrqFNhbhE58Hk=; b=Jn06+/50i6GXY11hQ9VdSutmpm2KpxbkbLx3igHmBgXuMLBlpaEW0nNa2RmKJYLnso K7JOrJRyeRI7Xp3NfuKbtANCf4U6IapxyN/TGhYBSolfFx8HHJCeO9pu+ZBycqpThHP9 7IHmqXC9wj6wHP1iaxze+5j55hHyzKId9I4yjpzL5wQYf/yFbcJ2uwsoZkaZ0bhCnv15 Wz3C2VReuF2+fvC0PIdtJe+gGmlvsZqFAxWZe/SGkOsaGYg5moY5yqHHFW5ygapeYsjX Mc+CKmCcOk/DX4GcLEcoofBqab5E4RgI0FTAebThSuhKgZ/dgNPPSFGcuVh7LOn9CQDr h0Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722220574; x=1722825374; 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=jg0luuKQzRJAO26CkBsWiEMjPCpDdgcrqFNhbhE58Hk=; b=RNEso2VYAI2gQCtulbFeQc8qJmjYpB3ME0syccMd1KJrjBp2sjiq8QoGtO+AvSJmSv 5Yvnwnk8J5rJd4Ypu0jbRUXVvNPn8l3J6g5D4AMcEFwnO27n2VOccc7IB+IyK5XIh8VJ 19wPR4JEkwqeCcdI1u22IJ7oTlrW5/WKqrPbUEC3YzIGVfduzQW9uVxp/gnJGHWJAut7 kTNmMsdh+ISKLevu+Cp72y/oQCFvz7ORCaC30Pt3QQwvc7HJ1grWj5FwDfDGjqQxcDeL VLILadR+14xdVFh6rNWVLQayzTfFHwlD3W3qNc7RPhnvJc4NDpW9cOH6nVPN9x2VDWua mX0w== X-Forwarded-Encrypted: i=1; AJvYcCWlvh4Fthlye4uq/ffCJfDuTTeals7ZzKCJvfWPkVJ0+8TZgAFTSEVUVqqg+zE3Dh62ZM+rp0P16XKfDuHGGipU9gA= X-Gm-Message-State: AOJu0YxAnMwKsRdmI2knScjr11oy4MUwXRQ3cJK6k/sc9Z7OhX5X+egz tJXNYkmY6P3a2zQHUTuvu8LNA28UqVi5EoSnR8tEnpvYj/98AaUlNqYKiw7kU4aKig== X-Google-Smtp-Source: AGHT+IFKwM4rZcQsqIPEyUdTCNhsJ+pE1RKGMyz0WPb2vDHrPBKM5G1X0683CL+l8GFBrXiyyYdhwQ== X-Received: by 2002:a05:6808:ecb:b0:3da:a16e:1764 with SMTP id 5614622812f47-3db2389bfe1mr9638471b6e.4.1722220574036; Sun, 28 Jul 2024 19:36:14 -0700 (PDT) Received: from localhost.localdomain ([223.104.210.31]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm5335673a12.4.2024.07.28.19.36.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2024 19:36:13 -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 v2 1/3] mm/page_alloc: A minor fix to the calculation of pcp->free_count Date: Mon, 29 Jul 2024 10:35:30 +0800 Message-Id: <20240729023532.1555-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240729023532.1555-1-laoar.shao@gmail.com> References: <20240729023532.1555-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: ctf99f8bhe816egqfxf3frba3oc38c6k X-Rspam-User: X-Rspamd-Queue-Id: 0CD47A0011 X-Rspamd-Server: rspam02 X-HE-Tag: 1722220574-259912 X-HE-Meta: U2FsdGVkX1/+o4iFyV42YE0y7xogqwPTiR4QGhlDNk6uUU2Bd0CrB3XEWsGdP4bcLaFAmkTInm+aIb0FneBG6NZctuPQl5IJk4flLcQCOHDykuUmDu5d9Ax/bLJu2u1CWAPOF11pYKINMylFHd0yl1/uZiFuxC7NSjiXlnB74zaXCpfGsKw1W7aWy3xvYXN9alAqvPKjYYiHWR9iFktq2Fq8wiGT5lY86F1KmhZ04+RMTRXgsoQqFda4lB5j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Ccrkohzeb6aHbRDVplTHreXys/GjFlj+f6sTqLAUuCIly6wWEKYao/V7GaQDs3dLNsaaUh5hDsFiPRF78HY+BRqGFbeia6akxTR5/PT/gnfw/zGAMqFZKvl9f41EJldAUcN9NKFa0S+743pgKegoTtVjbK3KpBIEWX86Fa4Eg++8ZB/FeAJAx7Hvk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, 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 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 9ecf99190ea2..d2ea2721f6a6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2557,7 +2557,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),