qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to h


From: Peter Xu
Subject: Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory
Date: Thu, 11 Mar 2021 16:25:05 -0500

On Thu, Mar 11, 2021 at 06:41:29PM +0100, David Hildenbrand wrote:
> It zaps the page tables but the shmem pages are still referenced (in the
> pagecache AFAIU). On next user space access, you would fill the page tables
> with the previous content.
> 
> That's why MADV_DONTNEED works properly on private anonymous memory, but not
> on shared anonymous memory - the only valid references are in the page
> tables in case of private mappings (well, unless we have other references
> like GUP etc.).

For some reason I thought anonymous shared memory could do auto-recycle, but
after a second thought what you said makes perfect sense.

> 
> 
> I did wonder, however, if there is benefit in doing both:
> 
> MADV_REMOVE followed by MADV_DONTNEED or the other way around. Like, will
> the extra MADV_DONTNEED also remove page tables and not just invalidate/zap
> the entries. Doesn't make a difference functionality-wise, but
> memory-consumption-wise.
> 
> I'll still have to have a look.

I saw your other email - that'll be another topic of course.  For now I believe
it's not necessary, and your current patch looks valid.

I just hope when qemu decides to disgard the range, we're sure the rdma
mremap() region have been unmaped - iiuc that's the only use case of that.
Otherwise data would corrupt.

-- 
Peter Xu




reply via email to

[Prev in Thread] Current Thread [Next in Thread]