Re: Page zapping and page table reclaim

From
Yang Shi <hidden>
Date
2021-03-19 17:04:22
Reply to
David Hildenbrand, 2021-03-11
On Thu, Mar 11, 2021 at 1:35 PM David Hildenbrand [off-list ref] wrote:
On 11.03.21 22:26, Peter Xu wrote:
quoted
On Thu, Mar 11, 2021 at 07:14:02PM +0100, David Hildenbrand wrote:
quoted
I was wondering, is there any mechanism that reclaims basically empty page
tables in a running process?
Would munmap() count? :)
Haha, no -- also not mmap(FIXED) or mremap(FIXED) ;)

As so often lately, the use case is sparse memory mappings where we

a) may want to reuse the area later.
b) don't want to hold the mmap lock in write while optimizing
c) don't want to create a lot of individual mappings that we might not
be able to merge again.
Will the below work for you?

1. acquire write mmap lock
2. unlink vmas from the list and rbtree (so the vmas won't be visible
to any concurrent readers/writers)
3. downgrade write lock to read lock
4. zap page tables and free page tables
5. upgrade to write lock
6. relink vmas back to list and rbtree

Actually the current implementation of munmap() does the first 5 steps.

But there is no rwsem upgrade function, so you may have to release the
lock then reacquire the write lock.

--
Thanks,

David / dhildenb
  
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