mm: Cast lowmem_reserve to long
z->lowmem_reserve[classzone_idx] is an unsigned long but free_pages and min are longs. If free_pages is negative, the function will incorrectly return true because it will treat the negative long as a large, positive unsigned long. This change casts z->lowmem_reserve to a long and fixes a typo in the comment. Change-Id: Icada1fa5ca650fbcdb0656f637adbb98f223eec5 Signed-off-by: Jack Cheung <jackc@codeaurora.org> (cherry picked from commit 9f41da81017657a194a4e145bab337f13a4d7fd9)
This commit is contained in:
committed by
Stephen Boyd
parent
4fe9e26803
commit
18e44d3eaf
@@ -1548,8 +1548,9 @@ static inline int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
|
||||
static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
|
||||
int classzone_idx, int alloc_flags, long free_pages)
|
||||
{
|
||||
/* free_pages my go negative - that's OK */
|
||||
/* free_pages may go negative - that's OK */
|
||||
long min = mark;
|
||||
long lowmem_reserve = z->lowmem_reserve[classzone_idx];
|
||||
int o;
|
||||
|
||||
free_pages -= (1 << order) - 1;
|
||||
@@ -1558,7 +1559,7 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
|
||||
if (alloc_flags & ALLOC_HARDER)
|
||||
min -= min / 4;
|
||||
|
||||
if (free_pages <= min + z->lowmem_reserve[classzone_idx])
|
||||
if (free_pages <= min + lowmem_reserve)
|
||||
return false;
|
||||
for (o = 0; o < order; o++) {
|
||||
/* At the next order, this order's pages become unavailable */
|
||||
|
||||
Reference in New Issue
Block a user