Skip to content

Commit f80b08f

Browse files
Charan Teja Reddytorvalds
authored andcommitted
mm, page_alloc: skip ->waternark_boost for atomic order-0 allocations
When boosting is enabled, it is observed that rate of atomic order-0 allocation failures are high due to the fact that free levels in the system are checked with ->watermark_boost offset. This is not a problem for sleepable allocations but for atomic allocations which looks like regression. This problem is seen frequently on system setup of Android kernel running on Snapdragon hardware with 4GB RAM size. When no extfrag event occurred in the system, ->watermark_boost factor is zero, thus the watermark configurations in the system are: _watermark = ( [WMARK_MIN] = 1272, --> ~5MB [WMARK_LOW] = 9067, --> ~36MB [WMARK_HIGH] = 9385), --> ~38MB watermark_boost = 0 After launching some memory hungry applications in Android which can cause extfrag events in the system to an extent that ->watermark_boost can be set to max i.e. default boost factor makes it to 150% of high watermark. _watermark = ( [WMARK_MIN] = 1272, --> ~5MB [WMARK_LOW] = 9067, --> ~36MB [WMARK_HIGH] = 9385), --> ~38MB watermark_boost = 14077, -->~57MB With default system configuration, for an atomic order-0 allocation to succeed, having free memory of ~2MB will suffice. But boosting makes the min_wmark to ~61MB thus for an atomic order-0 allocation to be successful system should have minimum of ~23MB of free memory(from calculations of zone_watermark_ok(), min = 3/4(min/2)). But failures are observed despite system is having ~20MB of free memory. In the testing, this is reproducible as early as first 300secs since boot and with furtherlowram configurations(<2GB) it is observed as early as first 150secs since boot. These failures can be avoided by excluding the ->watermark_boost in watermark caluculations for atomic order-0 allocations. [[email protected]: fix comment grammar, reflow comment] [[email protected]: fix suggested by Mel Gorman] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Charan Teja Reddy <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Vinayak Menon <[email protected]> Cc: Mel Gorman <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent f27ce0e commit f80b08f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

mm/page_alloc.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,7 +3588,7 @@ bool zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
35883588

35893589
static inline bool zone_watermark_fast(struct zone *z, unsigned int order,
35903590
unsigned long mark, int highest_zoneidx,
3591-
unsigned int alloc_flags)
3591+
unsigned int alloc_flags, gfp_t gfp_mask)
35923592
{
35933593
long free_pages;
35943594

@@ -3607,8 +3607,23 @@ static inline bool zone_watermark_fast(struct zone *z, unsigned int order,
36073607
return true;
36083608
}
36093609

3610-
return __zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags,
3611-
free_pages);
3610+
if (__zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags,
3611+
free_pages))
3612+
return true;
3613+
/*
3614+
* Ignore watermark boosting for GFP_ATOMIC order-0 allocations
3615+
* when checking the min watermark. The min watermark is the
3616+
* point where boosting is ignored so that kswapd is woken up
3617+
* when below the low watermark.
3618+
*/
3619+
if (unlikely(!order && (gfp_mask & __GFP_ATOMIC) && z->watermark_boost
3620+
&& ((alloc_flags & ALLOC_WMARK_MASK) == WMARK_MIN))) {
3621+
mark = z->_watermark[WMARK_MIN];
3622+
return __zone_watermark_ok(z, order, mark, highest_zoneidx,
3623+
alloc_flags, free_pages);
3624+
}
3625+
3626+
return false;
36123627
}
36133628

36143629
bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
@@ -3752,7 +3767,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
37523767

37533768
mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
37543769
if (!zone_watermark_fast(zone, order, mark,
3755-
ac->highest_zoneidx, alloc_flags)) {
3770+
ac->highest_zoneidx, alloc_flags,
3771+
gfp_mask)) {
37563772
int ret;
37573773

37583774
#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT

0 commit comments

Comments
 (0)