lkml.org 
[lkml]   [2019]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: align up min_free_kbytes to multipy of 4
On Sun, Jun 09, 2019 at 05:10:28PM +0800, ChenGang wrote:
>Usually the value of min_free_kbytes is multiply of 4,
>and in this case ,the right shift is ok.
>But if it's not, the right-shifting operation will lose the low 2 bits,

But PAGE_SHIFT is not always 12.

>and this cause kernel don't reserve enough memory.
>So it's necessary to align the value of min_free_kbytes to multiply of 4.
>For example, if min_free_kbytes is 64, then should keep 16 pages,
>but if min_free_kbytes is 65 or 66, then should keep 17 pages.
>
>Signed-off-by: ChenGang <cg.chen@huawei.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 d66bc8a..1baeeba 100644
>--- a/mm/page_alloc.c
>+++ b/mm/page_alloc.c
>@@ -7611,7 +7611,8 @@ static void setup_per_zone_lowmem_reserve(void)
>
> static void __setup_per_zone_wmarks(void)
> {
>- unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10);
>+ unsigned long pages_min =
>+ (PAGE_ALIGN(min_free_kbytes * 1024) / 1024) >> (PAGE_SHIFT - 10);

In my mind, pages_min is an estimated value. Do we need to be so precise?

> unsigned long lowmem_pages = 0;
> struct zone *zone;
> unsigned long flags;
>--
>1.8.5.6

--
Wei Yang
Help you, Help me

\
 
 \ /
  Last update: 2019-06-09 16:55    [W:0.040 / U:2.336 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site