zone_watermark_ok() rework
Subsystems (2)
PATCH 1/1 zone_watermark_ok() rework
Hello,
In zone_watermark_ok(), the original algorithm seems not logical. This is a rework. Comments?
Coywolf
Signed-off-by Coywolf Qi Hunt <[email protected]>
---
page_alloc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~orig +5 -10
@@ -772,7 +772,7 @@int zone_watermark_ok (struct zone *z,int order,unsigned long mark,int classzone_idx,int can_try_harder,int gfp_high) { -/* free_pages my go negative - that's OK */ +/* free_pages may go negative - that's OK */ long min = mark, free_pages = z->free_pages - (1 << order) +1 ;int o;
@@ -783,17 +783,12 @@if (free_pages <= min + z->lowmem_reserve[classzone_idx])return 0 ; -for (o =0 ; o < order; o++) { -/* At the next order, this order's pages become unavailable */ - free_pages -= z->free_area[o].nr_free << o; -/* Require fewer higher order pages to be free */ - min >>=1 ; - -if (free_pages <= min) -return 0 ; +for (o = order; o <MAX_ORDER ; o++) { +if (z->free_area[o].nr_free) +return 1 ; } -return 1 ; +return 0 ; } static inline int
Quoted 17 lines · Coywolf Qi Hunt
Hello,
In
zone_watermark_ok(), the original algorithm seems not logical. This is a rework. Comments?Coywolf
Signed-off-by Coywolf Qi Hunt <[email protected]>---
page_alloc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
mm/page_alloc.c line 778
Quoted 8 lines
mm/page_alloc.c renamed from mm/page_alloc.c~orig +1
-1@@ -772,7 +772,7 @@int zone_watermark_ok (struct zone *z,int order,unsigned long mark,int classzone_idx,int can_try_harder,int gfp_high) { -/* free_pages my go negative - that's OK */ +/* free_pages may go negative - that's OK */ long min = mark, free_pages = z->free_pages - (1 << order) +1 ;int o;
Typo. Thanks.
Quoted 12 lines
mm/page_alloc.c renamed from mm/page_alloc.c~orig +0
-7@@ -783,17 +783,12 @@if (free_pages <= min + z->lowmem_reserve[classzone_idx])return 0 ; -for (o =0 ; o < order; o++) { -/* At the next order, this order's pages become unavailable */ - free_pages -= z->free_area[o].nr_free << o; -/* Require fewer higher order pages to be free */ - min >>=1 ; - -if (free_pages <= min)
mm/page_alloc.c line 794
Quoted 10 lines
mm/page_alloc.c renamed from mm/page_alloc.c~orig +4
-2-return 0 ; +for (o = order; o <MAX_ORDER ; o++) { +if (z->free_area[o].nr_free) +return 1 ; } -return 1 ; +return 0 ; } static inline int
Well the original algorithm's intention is to include some watermarks for higher order pages for eg. GFP_ATOMIC and PF_MEMALLOC. To that goal I believe the algorithm is logical?
Yours is correct if our intention was simply to ensure _any_ higher order page is available, however it is also redundant because rmqueue will catch that for us. However, that is not the intention :)
Any reasons why it should be changed?
Thanks,
Nick
Signature · 5 lines
SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com