All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memblock:use a more appropriate order calculation when free memblock pages
@ 2020-12-03 15:23 carver4lio
  2020-12-04 13:42   ` Qian Cai
  2020-12-06 11:55 ` Mike Rapoport
  0 siblings, 2 replies; 11+ messages in thread
From: carver4lio @ 2020-12-03 15:23 UTC (permalink / raw)
  To: rppt; +Cc: akpm, linux-mm, linux-kernel, Hailong Liu

From: Hailong Liu <liu.hailong6@zte.com.cn>

When system in the booting stage, pages span from [start, end] of a memblock
are freed to buddy in a order as large as possible (less than MAX_ORDER) at
first, then decrease gradually to a proper order(less than end) in a loop.

However, *min(MAX_ORDER - 1UL, __ffs(start))* can not get the largest order
in some cases.
Instead, *__ffs(end - start)* may be more appropriate and meaningful.

Signed-off-by: Hailong Liu <liu.hailong6@zte.com.cn>
---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index b68ee8678..7c6d0dde7 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1931,7 +1931,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
 	int order;
 
 	while (start < end) {
-		order = min(MAX_ORDER - 1UL, __ffs(start));
+		order = min(MAX_ORDER - 1UL, __ffs(end - start));
 
 		while (start + (1UL << order) > end)
 			order--;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-12-06 14:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 15:23 [PATCH] mm/memblock:use a more appropriate order calculation when free memblock pages carver4lio
2020-12-04 13:42 ` Qian Cai
2020-12-04 13:42   ` Qian Cai
     [not found]   ` <CGME20201204160751eucas1p13cc7aad8c68dd2a495c4bbf422c4228c@eucas1p1.samsung.com>
2020-12-04 16:07     ` Marek Szyprowski
2020-12-04 17:43       ` Jon Hunter
2020-12-05 17:09         ` Anders Roxell
2020-12-05 17:09           ` Anders Roxell
2020-12-05 17:12           ` Anders Roxell
2020-12-05 17:12             ` Anders Roxell
2020-12-06 11:55 ` Mike Rapoport
2020-12-06 14:21   ` carver4lio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.