linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nitin Gupta <ngupta@nitingupta.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
	Nitin Gupta <nigupta@nvidia.com>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Khalid Aziz <khalid.aziz@oracle.com>,
	Oleksandr Natalenko <oleksandr@redhat.com>,
	Michal Hocko <mhocko@suse.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Matthew Wilcox <willy@infradead.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	David Rientjes <rientjes@google.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Linux API <linux-api@vger.kernel.org>
Subject: Re: [PATCH v8] mm: Proactive compaction
Date: Wed, 17 Jun 2020 15:02:59 -0700	[thread overview]
Message-ID: <10f8a7c1-dc1f-532b-7ef7-d37b04334fbe@nitingupta.dev> (raw)
In-Reply-To: <20200617135312.4f395479454c55a8d021b023@linux-foundation.org>



On 6/17/20 1:53 PM, Andrew Morton wrote:
> On Tue, 16 Jun 2020 13:45:27 -0700 Nitin Gupta <nigupta@nvidia.com> wrote:
> 
>> For some applications, we need to allocate almost all memory as
>> hugepages. However, on a running system, higher-order allocations can
>> fail if the memory is fragmented. Linux kernel currently does on-demand
>> compaction as we request more hugepages, but this style of compaction
>> incurs very high latency. Experiments with one-time full memory
>> compaction (followed by hugepage allocations) show that kernel is able
>> to restore a highly fragmented memory state to a fairly compacted memory
>> state within <1 sec for a 32G system. Such data suggests that a more
>> proactive compaction can help us allocate a large fraction of memory as
>> hugepages keeping allocation latencies low.
>>
>> ...
>>
> 
> All looks straightforward to me and easy to disable if it goes wrong.
> 
> All the hard-coded magic numbers are a worry, but such is life.
> 
> One teeny complaint:
> 
>>
>> ...
>>
>> @@ -2650,12 +2801,34 @@ static int kcompactd(void *p)
>>   		unsigned long pflags;
>>   
>>   		trace_mm_compaction_kcompactd_sleep(pgdat->node_id);
>> -		wait_event_freezable(pgdat->kcompactd_wait,
>> -				kcompactd_work_requested(pgdat));
>> +		if (wait_event_freezable_timeout(pgdat->kcompactd_wait,
>> +			kcompactd_work_requested(pgdat),
>> +			msecs_to_jiffies(HPAGE_FRAG_CHECK_INTERVAL_MSEC))) {
>> +
>> +			psi_memstall_enter(&pflags);
>> +			kcompactd_do_work(pgdat);
>> +			psi_memstall_leave(&pflags);
>> +			continue;
>> +		}
>>   
>> -		psi_memstall_enter(&pflags);
>> -		kcompactd_do_work(pgdat);
>> -		psi_memstall_leave(&pflags);
>> +		/* kcompactd wait timeout */
>> +		if (should_proactive_compact_node(pgdat)) {
>> +			unsigned int prev_score, score;
> 
> Everywhere else, scores have type `int'.  Here they are unsigned.  How come?
> 
> Would it be better to make these unsigned throughout?  I don't think a
> score can ever be negative?
> 

The score is always in [0, 100], so yes, it should be unsigned.
I will send another patch which fixes this.

Thanks,
Nitin


  reply	other threads:[~2020-06-17 22:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 20:45 [PATCH v8] mm: Proactive compaction Nitin Gupta
2020-06-17 20:53 ` Andrew Morton
2020-06-17 22:02   ` Nitin Gupta [this message]
2020-06-23  2:26 ` Nathan Chancellor
2020-06-23  4:21   ` maobibo
2020-06-23  4:32   ` Nitin Gupta
2020-06-23  4:57     ` Nathan Chancellor
2020-06-23  6:42       ` Nitin Gupta

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=10f8a7c1-dc1f-532b-7ef7-d37b04334fbe@nitingupta.dev \
    --to=ngupta@nitingupta.dev \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=khalid.aziz@oracle.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=nigupta@nvidia.com \
    --cc=oleksandr@redhat.com \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.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).