[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 12/15] memory: Clarify mapping requirements for RamDiscardMana
From: |
David Hildenbrand |
Subject: |
[PATCH v1 12/15] memory: Clarify mapping requirements for RamDiscardManager |
Date: |
Fri, 16 Jun 2023 11:26:51 +0200 |
We really only care about the RAM memory region not being mapped into
an address space yet as long as we're still setting up the
RamDiscardManager. Once mapped into an address space, memory notifiers
would get notified about such a region and any attempts to modify the
RamDiscardManager would be wrong.
While "mapped into an address space" is easy to check for RAM regions that
are mapped directly (following the ->container links), it's harder to
check when such regions are mapped indirectly via aliases. For now, we can
only detect that a region is mapped through an alias (->mapped_via_alias),
but we don't have a handle on these aliases to follow all their ->container
links to test if they are eventually mapped into an address space.
So relax the assertion in memory_region_set_ram_discard_manager(),
remove the check in memory_region_get_ram_discard_manager() and clarify
the doc.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/exec/memory.h | 5 +++--
softmmu/memory.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c3661b2276..1e35a2c828 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -590,8 +590,9 @@ typedef void (*ReplayRamDiscard)(MemoryRegionSection
*section, void *opaque);
* populated (consuming memory), to be used/accessed by the VM.
*
* A #RamDiscardManager can only be set for a RAM #MemoryRegion while the
- * #MemoryRegion isn't mapped yet; it cannot change while the #MemoryRegion is
- * mapped.
+ * #MemoryRegion isn't mapped into an address space yet (either directly
+ * or via an alias); it cannot change while the #MemoryRegion is
+ * mapped into an address space.
*
* The #RamDiscardManager is intended to be used by technologies that are
* incompatible with discarding of RAM (e.g., VFIO, which may pin all
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 7d9494ce70..c1e8aa133f 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2081,7 +2081,7 @@ int memory_region_iommu_num_indexes(IOMMUMemoryRegion
*iommu_mr)
RamDiscardManager *memory_region_get_ram_discard_manager(MemoryRegion *mr)
{
- if (!memory_region_is_mapped(mr) || !memory_region_is_ram(mr)) {
+ if (!memory_region_is_ram(mr)) {
return NULL;
}
return mr->rdm;
@@ -2090,7 +2090,7 @@ RamDiscardManager
*memory_region_get_ram_discard_manager(MemoryRegion *mr)
void memory_region_set_ram_discard_manager(MemoryRegion *mr,
RamDiscardManager *rdm)
{
- g_assert(memory_region_is_ram(mr) && !memory_region_is_mapped(mr));
+ g_assert(memory_region_is_ram(mr));
g_assert(!rdm || !mr->rdm);
mr->rdm = rdm;
}
--
2.40.1
- [PATCH v1 02/15] kvm: Add stub for kvm_get_max_memslots(), (continued)
- [PATCH v1 02/15] kvm: Add stub for kvm_get_max_memslots(), David Hildenbrand, 2023/06/16
- [PATCH v1 03/15] vhost: Add vhost_get_max_memslots(), David Hildenbrand, 2023/06/16
- [PATCH v1 04/15] memory-device, vhost: Add a memslot soft limit for memory devices, David Hildenbrand, 2023/06/16
- [PATCH v1 05/15] kvm: Return number of free memslots, David Hildenbrand, 2023/06/16
- [PATCH v1 06/15] vhost: Return number of free memslots, David Hildenbrand, 2023/06/16
- [PATCH v1 07/15] memory-device: Support memory devices that statically consume multiple memslots, David Hildenbrand, 2023/06/16
- [PATCH v1 08/15] memory-device: Track the actually used memslots in DeviceMemoryState, David Hildenbrand, 2023/06/16
- [PATCH v1 09/15] memory-device, vhost: Support memory devices that dynamically consume multiple memslots, David Hildenbrand, 2023/06/16
- [PATCH v1 10/15] pc-dimm: Provide pc_dimm_get_free_slots() to query free ram slots, David Hildenbrand, 2023/06/16
- [PATCH v1 11/15] memory-device: Support memory-devices with auto-detection of the number of memslots, David Hildenbrand, 2023/06/16
- [PATCH v1 12/15] memory: Clarify mapping requirements for RamDiscardManager,
David Hildenbrand <=
- [PATCH v1 13/15] virtio-mem: Expose device memory via multiple memslots if enabled, David Hildenbrand, 2023/06/16
- [PATCH v1 15/15] virtio-mem: Mark memslot alias memory regions unmergeable, David Hildenbrand, 2023/06/16
- [PATCH v1 14/15] memory, vhost: Allow for marking memory device memory regions unmergeable, David Hildenbrand, 2023/06/16