Re: Page zapping and page table reclaim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 11, 2021 at 1:35 PM David Hildenbrand <david@xxxxxxxxxx> wrote:
>
> On 11.03.21 22:26, Peter Xu wrote:
> > On Thu, Mar 11, 2021 at 07:14:02PM +0100, David Hildenbrand wrote:
> >> 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
>
>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux