Re: Page zapping and page table reclaim

From
Vlastimil Babka <hidden>
Date
2021-03-18 16:57:21
Reply to
David Hildenbrand, 2021-03-11
On 3/11/21 7:14 PM, David Hildenbrand wrote:
Hi folks,

I was wondering, is there any mechanism that reclaims basically empty page
tables in a running process?

Like: When I MADV_DONTNEED a huge range, there could be plenty of basically
empty (e.g., all entries invalid) page tables we could reclaim. As soon as we
zap a complete PMD we could reclaim (depending on the architecture) a whole page.

Zapping on the PMD level might make most impact I guess.

For 1 GB, we need 262144 4k pages. If we assume each PTE is 8 bytes, we need a
total of 8 MB for the lowest level page tables (PTE).

OTOH, we would need 512 PMD entries - a single 4k page. Zapping 1 TB would mean
we can free up another 4MB - rather a corner case and we can live with that.


Of course, the same might apply to other cases where we can restore all page
table content from the VMA again. One example would be after MADV_FREE zapped a
whole range of entries we marked.
I don't think we have such mechanism, but IIRC I've heard the idea mentioned
before, probably from Michal Hocko. Definitely an interesting research project
idea to evaluate the cost vs benefits of that.
Looks like if we happen to zap a THP, we should already get what we want (no
page table, nothing to remove)

I haven't immediately stumbled over anything, but could be I am missing the
obvious. I guess what would need some thought is concurrent discards/pagefaults
- but it feels like being similar to collapsing/splitting a THP while there is
other system activity.

Maybe there is already something and I am just not aware of it.

Thanks!
  
Thread (13 messages) 13 messages, 6 authors, last reply 2021-03-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help