[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 1/9] memory: Introduce replay_discarded callback for RamDiscar
From: |
David Hildenbrand |
Subject: |
[PATCH v5 1/9] memory: Introduce replay_discarded callback for RamDiscardManager |
Date: |
Sat, 4 Sep 2021 18:09:05 +0200 |
Introduce replay_discarded callback similar to our existing
replay_populated callback, to be used my migration code to never migrate
discarded memory.
Acked-by: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/exec/memory.h | 21 +++++++++++++++++++++
softmmu/memory.c | 11 +++++++++++
2 files changed, 32 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c3d417d317..93e972b55a 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -537,6 +537,7 @@ static inline void
ram_discard_listener_init(RamDiscardListener *rdl,
}
typedef int (*ReplayRamPopulate)(MemoryRegionSection *section, void *opaque);
+typedef void (*ReplayRamDiscard)(MemoryRegionSection *section, void *opaque);
/*
* RamDiscardManagerClass:
@@ -625,6 +626,21 @@ struct RamDiscardManagerClass {
MemoryRegionSection *section,
ReplayRamPopulate replay_fn, void *opaque);
+ /**
+ * @replay_discarded:
+ *
+ * Call the #ReplayRamDiscard callback for all discarded parts within the
+ * #MemoryRegionSection via the #RamDiscardManager.
+ *
+ * @rdm: the #RamDiscardManager
+ * @section: the #MemoryRegionSection
+ * @replay_fn: the #ReplayRamDiscard callback
+ * @opaque: pointer to forward to the callback
+ */
+ void (*replay_discarded)(const RamDiscardManager *rdm,
+ MemoryRegionSection *section,
+ ReplayRamDiscard replay_fn, void *opaque);
+
/**
* @register_listener:
*
@@ -669,6 +685,11 @@ int ram_discard_manager_replay_populated(const
RamDiscardManager *rdm,
ReplayRamPopulate replay_fn,
void *opaque);
+void ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
+ MemoryRegionSection *section,
+ ReplayRamDiscard replay_fn,
+ void *opaque);
+
void ram_discard_manager_register_listener(RamDiscardManager *rdm,
RamDiscardListener *rdl,
MemoryRegionSection *section);
diff --git a/softmmu/memory.c b/softmmu/memory.c
index bfedaf9c4d..cd86205627 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2076,6 +2076,17 @@ int ram_discard_manager_replay_populated(const
RamDiscardManager *rdm,
return rdmc->replay_populated(rdm, section, replay_fn, opaque);
}
+void ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
+ MemoryRegionSection *section,
+ ReplayRamDiscard replay_fn,
+ void *opaque)
+{
+ RamDiscardManagerClass *rdmc = RAM_DISCARD_MANAGER_GET_CLASS(rdm);
+
+ g_assert(rdmc->replay_discarded);
+ rdmc->replay_discarded(rdm, section, replay_fn, opaque);
+}
+
void ram_discard_manager_register_listener(RamDiscardManager *rdm,
RamDiscardListener *rdl,
MemoryRegionSection *section)
--
2.31.1
- [PATCH v5 0/9] migration/ram: Optimize for virtio-mem via RamDiscardManager, David Hildenbrand, 2021/09/04
- [PATCH v5 1/9] memory: Introduce replay_discarded callback for RamDiscardManager,
David Hildenbrand <=
- [PATCH v5 2/9] virtio-mem: Implement replay_discarded RamDiscardManager callback, David Hildenbrand, 2021/09/04
- [PATCH v5 3/9] migration/ram: Don't passs RAMState to migration_clear_memory_region_dirty_bitmap_*(), David Hildenbrand, 2021/09/04
- [PATCH v5 4/9] migration/ram: Handle RAMBlocks with a RamDiscardManager on the migration source, David Hildenbrand, 2021/09/04
- [PATCH v5 5/9] virtio-mem: Drop precopy notifier, David Hildenbrand, 2021/09/04
- [PATCH v5 6/9] migration/postcopy: Handle RAMBlocks with a RamDiscardManager on the destination, David Hildenbrand, 2021/09/04
- [PATCH v5 7/9] migration: Simplify alignment and alignment checks, David Hildenbrand, 2021/09/04
- [PATCH v5 8/9] migration/ram: Factor out populating pages readable in ram_block_populate_pages(), David Hildenbrand, 2021/09/04