Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread David Hildenbrand
On 11.03.21 22:37, Peter Xu wrote: On Mon, Mar 08, 2021 at 04:05:50PM +0100, David Hildenbrand wrote: We can create shared anonymous memory via "-object memory-backend-ram,share=on,..." which is, for example, required by PVRDMA for mremap() to work. Shared anonymous memory is weird,

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread Peter Xu
On Mon, Mar 08, 2021 at 04:05:50PM +0100, David Hildenbrand wrote: > We can create shared anonymous memory via > "-object memory-backend-ram,share=on,..." > which is, for example, required by PVRDMA for mremap() to work. > > Shared anonymous memory is weird, though. Instead of MADV_DONTNEED,

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread Peter Xu
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

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread David Hildenbrand
On 11.03.21 18:22, Peter Xu wrote: On Thu, Mar 11, 2021 at 06:15:15PM +0100, David Hildenbrand wrote: On 11.03.21 18:11, Peter Xu wrote: On Thu, Mar 11, 2021 at 05:45:46PM +0100, David Hildenbrand wrote: On 11.03.21 17:39, Dr. David Alan Gilbert wrote: * David Hildenbrand (da...@redhat.com)

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread Peter Xu
On Thu, Mar 11, 2021 at 06:15:15PM +0100, David Hildenbrand wrote: > On 11.03.21 18:11, Peter Xu wrote: > > On Thu, Mar 11, 2021 at 05:45:46PM +0100, David Hildenbrand wrote: > > > On 11.03.21 17:39, Dr. David Alan Gilbert wrote: > > > > * David Hildenbrand (da...@redhat.com) wrote: > > > > > We

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread David Hildenbrand
On 11.03.21 18:15, David Hildenbrand wrote: On 11.03.21 18:11, Peter Xu wrote: On Thu, Mar 11, 2021 at 05:45:46PM +0100, David Hildenbrand wrote: On 11.03.21 17:39, Dr. David Alan Gilbert wrote: * David Hildenbrand (da...@redhat.com) wrote: We can create shared anonymous memory via

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread David Hildenbrand
On 11.03.21 18:11, Peter Xu wrote: On Thu, Mar 11, 2021 at 05:45:46PM +0100, David Hildenbrand wrote: On 11.03.21 17:39, Dr. David Alan Gilbert wrote: * David Hildenbrand (da...@redhat.com) wrote: We can create shared anonymous memory via "-object memory-backend-ram,share=on,..." which

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread Peter Xu
On Thu, Mar 11, 2021 at 05:45:46PM +0100, David Hildenbrand wrote: > On 11.03.21 17:39, Dr. David Alan Gilbert wrote: > > * David Hildenbrand (da...@redhat.com) wrote: > > > We can create shared anonymous memory via > > > "-object memory-backend-ram,share=on,..." > > > which is, for example,

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread David Hildenbrand
On 11.03.21 17:39, Dr. David Alan Gilbert wrote: * David Hildenbrand (da...@redhat.com) wrote: We can create shared anonymous memory via "-object memory-backend-ram,share=on,..." which is, for example, required by PVRDMA for mremap() to work. Shared anonymous memory is weird, though.

Re: [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-11 Thread Dr. David Alan Gilbert
* David Hildenbrand (da...@redhat.com) wrote: > We can create shared anonymous memory via > "-object memory-backend-ram,share=on,..." > which is, for example, required by PVRDMA for mremap() to work. > > Shared anonymous memory is weird, though. Instead of MADV_DONTNEED, we > have to use

[PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory

2021-03-08 Thread David Hildenbrand
We can create shared anonymous memory via "-object memory-backend-ram,share=on,..." which is, for example, required by PVRDMA for mremap() to work. Shared anonymous memory is weird, though. Instead of MADV_DONTNEED, we have to use MADV_REMOVE. MADV_DONTNEED fails silently and does nothing.