linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vijay Balakrishna <vijayb@linux.microsoft.com>
To: Michal Hocko <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Oleg Nesterov <oleg@redhat.com>, Song Liu <songliubraving@fb.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Allen Pais <apais@microsoft.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [v2 2/2] mm: khugepaged: avoid overriding min_free_kbytes set by user
Date: Wed, 16 Sep 2020 12:18:12 -0700	[thread overview]
Message-ID: <7f4816ce-cdb0-b549-c94b-66328b65a85d@linux.microsoft.com> (raw)
In-Reply-To: <20200916075900.GE18998@dhcp22.suse.cz>



On 9/16/2020 12:59 AM, Michal Hocko wrote:
> On Tue 15-09-20 14:10:58, Vijay Balakrishna wrote:
>> set_recommended_min_free_kbytes need to honor min_free_kbytes set by the
>> user.  Post start-of-day THP enable or memory hotplug operations can
>> lose user specified min_free_kbytes, in particular when it is higher than
>> calculated recommended value.  Also modifying "recommended_min" variable
>> type to "int" from "unsigned long" to avoid undesired result noticed
>> during testing.  It is due to comparing "unsigned long" with "int" type.
>>
>> Signed-off-by: Vijay Balakrishna <vijayb@linux.microsoft.com>
>> Cc: stable@vger.kernel.org
>> Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com>
>> ---
>>   mm/khugepaged.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index 4f7107476a6f..b4b753ba411a 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -2253,7 +2253,7 @@ static void set_recommended_min_free_kbytes(void)
>>   {
>>   	struct zone *zone;
>>   	int nr_zones = 0;
>> -	unsigned long recommended_min;
>> +	int recommended_min;
>>   
>>   	for_each_populated_zone(zone) {
>>   		/*
>> @@ -2280,12 +2280,12 @@ static void set_recommended_min_free_kbytes(void)
>>   
>>   	/* don't ever allow to reserve more than 5% of the lowmem */
>>   	recommended_min = min(recommended_min,
>> -			      (unsigned long) nr_free_buffer_pages() / 20);
>> +			      (int) nr_free_buffer_pages() / 20);
> 
> nr_free_buffer_pages can oveflow in int on very large machines.

Good point.  I will address it.

> 
>>   	recommended_min <<= (PAGE_SHIFT-10);
>>   
>> -	if (recommended_min > min_free_kbytes) {
>> +	if (recommended_min > user_min_free_kbytes) {
> 
> This can decrease the size theoretically. Because user_min_free_kbytes
> is -1 by default and recommended_min might be <= min_free_kbytes.
> 
> You need to check both. Also can we make user_min_free_kbytes 0 by
> default? From a quick look, nobody should really care.

Let me rework.

Thanks,
Vijay

> 
>>   		if (user_min_free_kbytes >= 0)
>> -			pr_info("raising min_free_kbytes from %d to %lu to help transparent hugepage allocations\n",
>> +			pr_info("raising min_free_kbytes from %d to %d to help transparent hugepage allocations\n",
>>   				min_free_kbytes, recommended_min);
>>   
>>   		min_free_kbytes = recommended_min;
>> -- 
>> 2.28.0
>>
> 


  reply	other threads:[~2020-09-16 19:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 21:10 [v2 1/2] mm: khugepaged: recalculate min_free_kbytes after memory hotplug as expected by khugepaged Vijay Balakrishna
2020-09-15 21:10 ` [v2 2/2] mm: khugepaged: avoid overriding min_free_kbytes set by user Vijay Balakrishna
2020-09-16  7:59   ` Michal Hocko
2020-09-16 19:18     ` Vijay Balakrishna [this message]
2020-09-16  7:47 ` [v2 1/2] mm: khugepaged: recalculate min_free_kbytes after memory hotplug as expected by khugepaged Michal Hocko

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=7f4816ce-cdb0-b549-c94b-66328b65a85d@linux.microsoft.com \
    --to=vijayb@linux.microsoft.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=apais@microsoft.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=oleg@redhat.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=songliubraving@fb.com \
    /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