mm: change free_cma and free_pages declarations to unsigned
Subsystems (2)
PATCH 1/2 mm: change free_cma and free_pages declarations to unsigned
Their stored values come from zone_page_state() which returns an unsigned long. To improve code correctness we should avoid mixing signed and unsigned integers.
--- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/page_alloc.c +2 -2
@@ -2242,7 +2242,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order,/* free_pages may go negative - that's OK */ long min = mark;int o; -long free_cma =0 ; +unsigned long free_cma =0 ; free_pages -= (1 << order) -1 ;if (alloc_flags &ALLOC_HIGH )
@@ -2280,7 +2280,7 @@ bool zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,bool zone_watermark_ok_safe (struct zone *z,unsigned int order,unsigned long mark,int classzone_idx,int alloc_flags) { -long free_pages =zone_page_state (z,NR_FREE_PAGES ); +unsigned long free_pages =zone_page_state (z,NR_FREE_PAGES );if (z->percpu_drift_mark && free_pages < z->percpu_drift_mark) free_pages =zone_page_state_snapshot (z,NR_FREE_PAGES );
Signature · 7 lines
2.5.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Mel Gorman
NAKQuoted 14 lines · Alexandru Moise
Their stored values come from
zone_page_state()which returns an unsigned long. To improve code correctness we should avoid mixing signed and unsigned integers.Signed-off-by Alexandru Moise <[email protected]>--- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/page_alloc.c +0
-0
mm/page_alloc.c static bool __zone_watermark_ok(struct zone *z, unsigned int order, · line 2246
Quoted 6 lines
mm/page_alloc.c +1
-1@@ -2242,7 +2242,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order,/* free_pages may go negative - that's OK */ long min = mark;int o; -long free_cma =0 ; +unsigned long free_cma =0 ;
NAK.
free_cma is used with free_pages which is explicitly commented as saying it can go negative. With your patch, there is a signed/unsigned operation where the unsigned type cannot fit into the signed type which casts them both to unsigned which is then broken for the comparison. This patch looks broken for very subtle reasons. Please do not do any similar style patches to this because they can introduce subtle breakage if issues are not caught at review.
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 24 lines · Mel Gorman
Quoted 14 lines · Alexandru Moise
Their stored values come from
zone_page_state()which returns an unsigned long. To improve code correctness we should avoid mixing signed and unsigned integers.Signed-off-by Alexandru Moise <[email protected]>--- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/page_alloc.c +0
-0mm/page_alloc.c static bool __zone_watermark_ok(struct zone *z, unsigned int order, · line 2246
Quoted 6 lines
mm/page_alloc.c +1
-1@@ -2242,7 +2242,7 @@ static bool __zone_watermark_ok(struct zone *z, unsigned int order,/* free_pages may go negative - that's OK */ long min = mark;int o; -long free_cma =0 ; +unsigned long free_cma =0 ;NAK.
Quoted 8 lines
free_cmais used withfree_pageswhich is explicitly commented as saying it can go negative. With your patch, there is a signed/unsigned operation where the unsigned type cannot fit into the signed type which casts them both to unsigned which is then broken for the comparison. This patch looks broken for very subtle reasons. Please do not do any similar style patches to this because they can introduce subtle breakage if issues are not caught at review.
Understood, I thought the comment only applied to the "min" variable.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>