Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-23 Thread David Hildenbrand
On 23.02.21 16:03, Paolo Bonzini wrote: On 23/02/21 11:50, David Hildenbrand wrote: However, I do agree that the notifier should work with MemoryRegionSection - this will make the "client" code much easier. The register()/replay_populate() mechanism should consume a MemoryRegionSection to wor

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-23 Thread Paolo Bonzini
On 23/02/21 11:50, David Hildenbrand wrote: However, I do agree that the notifier should work with MemoryRegionSection - this will make the "client" code much easier. The register()/replay_populate() mechanism should consume a MemoryRegionSection to work on, and call the listener via (adjus

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-23 Thread David Hildenbrand
On 22.02.21 20:43, David Hildenbrand wrote: The main motivation is to let listener decide how it wants to handle the memory region. For example, for vhost, vdpa, kvm, ... I only want a single region, not separate ones for each and every populated range, punching out discarded ranges. Note that th

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread David Hildenbrand
The main motivation is to let listener decide how it wants to handle the memory region. For example, for vhost, vdpa, kvm, ... I only want a single region, not separate ones for each and every populated range, punching out discarded ranges. Note that there are cases (i.e., anonymous memory), where

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread David Hildenbrand
On 22.02.21 18:37, Paolo Bonzini wrote: On 22/02/21 15:53, David Hildenbrand wrote: Yes, but does it behave more like the IOMMU notifier in other regards? :)  The IOMMU notifier is concerned with an iova concept that doesn't exist at the MemoryRegion level, while RamDiscardListener works at the

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread Paolo Bonzini
On 22/02/21 15:53, David Hildenbrand wrote: Yes, but does it behave more like the IOMMU notifier in other regards? :)  The IOMMU notifier is concerned with an iova concept that doesn't exist at the MemoryRegion level, while RamDiscardListener works at the (MemoryRegion, offset) level that can eas

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread David Hildenbrand
On 22.02.21 15:18, Paolo Bonzini wrote: On 22/02/21 15:03, David Hildenbrand wrote: +    /** + * @replay_populated: + * + * Notify the #RamDiscardListener about all populated parts within the + * #MemoryRegion via the #RamDiscardMgr. + * + * In case any notification fai

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread Paolo Bonzini
On 22/02/21 15:03, David Hildenbrand wrote: +    /** + * @replay_populated: + * + * Notify the #RamDiscardListener about all populated parts within the + * #MemoryRegion via the #RamDiscardMgr. + * + * In case any notification fails, no further notifications are trigg

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread David Hildenbrand
+/** + * @replay_populated: + * + * Notify the #RamDiscardListener about all populated parts within the + * #MemoryRegion via the #RamDiscardMgr. + * + * In case any notification fails, no further notifications are triggered. + * The listener is not required to b

Re: [PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread Paolo Bonzini
On 22/02/21 12:56, David Hildenbrand wrote: +/** + * @get_min_granularity: + * + * Get the minimum granularity in which listeners will get notified + * about changes within the #MemoryRegion via the #RamDiscardMgr. + * + * @rdm: the #RamDiscardMgr + * @mr: the #Me

[PATCH v6 01/12] memory: Introduce RamDiscardMgr for RAM memory regions

2021-02-22 Thread David Hildenbrand
We have some special RAM memory regions (managed by virtio-mem), whereby the guest agreed to only use selected memory ranges. "unused" parts are discarded so they won't consume memory - to logically unplug these memory ranges. Before the VM is allowed to use such logically unplugged memory again, c