linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: hughd@google.com, willy@infradead.org, mgorman@suse.de,
	muchun.song@linux.dev, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] asynchronously scan and free empty user PTE pages
Date: Tue, 18 Jun 2024 11:40:51 +0200	[thread overview]
Message-ID: <4f56d1e9-2c23-42e5-9aef-6b29d072138e@redhat.com> (raw)
In-Reply-To: <025ea89a-bb94-4f60-b6ad-d8b88d3cfc60@bytedance.com>

On 18.06.24 09:51, Qi Zheng wrote:
> Hi David,
> 
> On 2024/6/18 01:49, David Hildenbrand wrote:
>>
>>>>
>>>> No strong opinion, something synchronous sounds to me like the
>>>> low-hanging fruit, that could add the infrastructure to be used by
>>>> something more advanced/synchronously :)
>>>
>>> Got it, I will try to do the following in the next version.
>>>
>>> a. for MADV_DONTNEED case, try synchronous reclaim as you said
>>>
>>
>> I think that really is the low hanging fruit that would cover quite some
>> cases already: (1) reclaim when MADV_DONTNEED spans the complete page
>> table.
> 
> I will check and free the PTE page in the zap_pte_range() if the
> (end - addr >= PMD_SIZE) condition is met.
> 
>>
>> Then, there is (2) reclaim when MADV_DONTNEED spans only part of the
>> page table (e.g., single PTE), but my best guess is that it's better to
>> scan for that asynchronously than making possibly each MADV_DONTNEED
>> sycall invocation slower.
> 
> Maybe just mark the vma, and then scan it in the system reclaim path.
> 
> I also plan to do this in the MADV_FREE case, instead of adding an
> asynchronous madvise option first.
> 
>>
>> (1) would already help a lot and showcase how the locking/machinery
>> would work.
>>
>>
>>> b. for MADV_FREE case:
>>>
>>>      - add a madvise option for synchronous reclaim
>>>
>>>      - add another madvise option to mark the vma, then add its
>>>              corresponding mm to a global list, and then traverse
>>>              the list and reclaim it when the memory is tight and
>>>              enters the system reclaim path.
>>>              (maybe there is an option to unmark)
>>>
>>> c. for s390 case you mentioned, create a CONFIG_FREE_PT first, and
>>>       then s390 will not select this config until the problem is solved.
>>>
>>> d. for lockless scan, try using disabling IRQ or (mmap read lock +
>>> pte_offset_map_nolock).
>>
>> Although d) really only is desired when scanning asynchronously I think.
>> During (1) above, we know that the table will be very likely empty
>> (unless weird race).
> 
> Agree.

Again, thanks for working on this. Let me know (can also do privately) 
if you run into any issues or think I can be of help. :)

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-06-18  9:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13  8:38 Qi Zheng
2024-06-13  8:38 ` [RFC PATCH 1/3] mm: pgtable: move pte_free_defer() out of CONFIG_TRANSPARENT_HUGEPAGE Qi Zheng
2024-06-13  8:38 ` [RFC PATCH 2/3] mm: pgtable: make pte_offset_map_nolock() return pmdval Qi Zheng
2024-06-13  8:38 ` [RFC PATCH 3/3] mm: free empty user PTE pages Qi Zheng
2024-06-13  9:04 ` [RFC PATCH 0/3] asynchronously scan and " David Hildenbrand
2024-06-13  9:32   ` Qi Zheng
2024-06-13 10:25     ` David Hildenbrand
2024-06-13 11:59       ` Qi Zheng
2024-06-14  3:32         ` Qi Zheng
2024-06-17 17:51           ` David Hildenbrand
2024-06-18  7:52             ` Qi Zheng
2024-06-14  7:53         ` David Hildenbrand
2024-06-14 10:49           ` Qi Zheng
2024-06-17 17:49             ` David Hildenbrand
2024-06-18  7:51               ` Qi Zheng
2024-06-18  9:40                 ` David Hildenbrand [this message]
2024-06-18  9:55                   ` Qi Zheng

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=4f56d1e9-2c23-42e5-9aef-6b29d072138e@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=muchun.song@linux.dev \
    --cc=willy@infradead.org \
    --cc=zhengqi.arch@bytedance.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