linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charan Teja Kalla <charante@codeaurora.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	vinmenon@codeaurora.org
Subject: Re: [PATCH] mm, page_alloc: reset the zone->watermark_boost early
Date: Tue, 12 May 2020 19:01:22 +0530	[thread overview]
Message-ID: <1cf5e778-eae1-fc71-aed4-d84d664d79dd@codeaurora.org> (raw)
In-Reply-To: <20200511131155.0b40ee443c3367e8f748b16f@linux-foundation.org>


Thank you Andrew for the reply.

On 5/12/2020 1:41 AM, Andrew Morton wrote:
> On Mon, 11 May 2020 19:10:08 +0530 Charan Teja Reddy <charante@codeaurora.org> wrote:
> 
>> Updating the zone watermarks by any means, like extra_free_kbytes,
>> min_free_kbytes, water_mark_scale_factor e.t.c, when watermark_boost is
>> set will result into the higher low and high watermarks than the user
>> asks. This can be avoided by resetting the zone->watermark_boost to zero
>> early.
> 
> Does this solve some problem which has been observed in testing?

Sorry, what are those issues observed in testing? It would be helpful
If you post them here. 

> 
>> ...
>>
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -7746,9 +7746,9 @@ static void __setup_per_zone_wmarks(void)
>>  			    mult_frac(zone_managed_pages(zone),
>>  				      watermark_scale_factor, 10000));
>>  
>> +		zone->watermark_boost = 0;
>>  		zone->_watermark[WMARK_LOW]  = min_wmark_pages(zone) + tmp;
>>  		zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2;
>> -		zone->watermark_boost = 0;
>>  
>>  		spin_unlock_irqrestore(&zone->lock, flags);
>>  	}
> 
> This could only be a problem if code is accessing these things without
> holding zone->lock.  Is that ever the case?
> 

This is a problem even when accessing these things with zone->lock
held because we are directly using the macro min_wmark_pages(zone)
which leads to the issue. Pasting macro here for reference.

#define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost)

Steps that lead to the issue is like below:
1) On the extfrag event, we try to boost the watermark by storing the
   value in ->watermark_boost.

2) User changes the value of extra|min_free_kbytes or watermark_scale_factor.
  
   In __setup_perzone_wmarks, we directly store the user asked
   watermarks in the zones structure. In this step, the value
   is always offsets by ->watermark_boost as we use the min_wmark_pages() macro.

3) Later, when kswapd woke up, it resets the zone's watermark_boost to zero. 

Step 2 from the above is what resulting into the issue.

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

  reply	other threads:[~2020-05-12 13:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 13:40 [PATCH] mm, page_alloc: reset the zone->watermark_boost early Charan Teja Reddy
2020-05-11 20:11 ` Andrew Morton
2020-05-12 13:31   ` Charan Teja Kalla [this message]
2020-05-13  9:46     ` Charan Teja Kalla
2020-05-13 22:24       ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1cf5e778-eae1-fc71-aed4-d84d664d79dd@codeaurora.org \
    --to=charante@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vinmenon@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).