From: Yafang Shao <laoar.shao@gmail.com>
To: akpm@linux-foundation.org
Cc: ying.huang@intel.com, mgorman@techsingularity.net,
linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH v3 1/3] mm/page_alloc: A minor fix to the calculation of pcp->free_count
Date: Sun, 4 Aug 2024 16:01:05 +0800 [thread overview]
Message-ID: <20240804080107.21094-2-laoar.shao@gmail.com> (raw)
In-Reply-To: <20240804080107.21094-1-laoar.shao@gmail.com>
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 <laoar.shao@gmail.com>
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
---
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 47c0ce1d6fa1..d9371806f6b5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2614,7 +2614,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),
--
2.34.1
next prev parent reply other threads:[~2024-08-04 8:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-04 8:01 [PATCH v3 0/3] mm: Introduce a new sysctl knob vm.pcp_batch_scale_max Yafang Shao
2024-08-04 8:01 ` Yafang Shao [this message]
2024-08-04 8:01 ` [PATCH v3 2/3] mm/page_alloc: Avoid changing pcp->high decaying when adjusting CONFIG_PCP_BATCH_SCALE_MAX Yafang Shao
2024-08-04 8:01 ` [PATCH v3 3/3] mm/page_alloc: Introduce a new sysctl knob vm.pcp_batch_scale_max Yafang Shao
2024-08-05 1:38 ` Huang, Ying
2024-08-05 1:58 ` Yafang Shao
2024-08-05 3:02 ` Huang, Ying
2024-08-05 3:17 ` Yafang Shao
2024-08-05 4:32 ` Huang, Ying
2024-08-05 4:48 ` Yafang Shao
2024-08-05 5:00 ` Huang, Ying
2024-08-05 5:36 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240804080107.21094-2-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox