From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH v4 05/13] virtio-mem: remove replay_populated/replay_discarded implementation
Date: Mon, 04 May 2026 16:30:11 +0400 [thread overview]
Message-ID: <20260504-rdm5-v4-5-bdf61e57c1e1@redhat.com> (raw)
In-Reply-To: <20260504-rdm5-v4-0-bdf61e57c1e1@redhat.com>
The replay iteration logic has been moved into the RamDiscardManager,
which now iterates at source granularity using is_populated(). The
source-level replay_populated/replay_discarded methods and their
helpers are no longer called.
Remove the now-dead replay methods, the VirtIOMEMReplayData struct,
the virtio_mem_for_each_plugged/unplugged_section() helpers (only used
by the replay methods), and the virtio_mem_section_cb typedef.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/virtio/virtio-mem.c | 112 -------------------------------------------------
1 file changed, 112 deletions(-)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ec165503205..2b67b2882d2 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -259,72 +259,6 @@ static int virtio_mem_for_each_plugged_range(VirtIOMEM *vmem, void *arg,
return ret;
}
-typedef int (*virtio_mem_section_cb)(MemoryRegionSection *s, void *arg);
-
-static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
- const MemoryRegionSection *s,
- void *arg,
- virtio_mem_section_cb cb)
-{
- unsigned long first_bit, last_bit;
- uint64_t offset, size;
- int ret = 0;
-
- first_bit = s->offset_within_region / vmem->block_size;
- first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
- while (first_bit < vmem->bitmap_size) {
- MemoryRegionSection tmp = *s;
-
- offset = first_bit * vmem->block_size;
- last_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size,
- first_bit + 1) - 1;
- size = (last_bit - first_bit + 1) * vmem->block_size;
-
- if (!memory_region_section_intersect_range(&tmp, offset, size)) {
- break;
- }
- ret = cb(&tmp, arg);
- if (ret) {
- break;
- }
- first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size,
- last_bit + 2);
- }
- return ret;
-}
-
-static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
- const MemoryRegionSection *s,
- void *arg,
- virtio_mem_section_cb cb)
-{
- unsigned long first_bit, last_bit;
- uint64_t offset, size;
- int ret = 0;
-
- first_bit = s->offset_within_region / vmem->block_size;
- first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
- while (first_bit < vmem->bitmap_size) {
- MemoryRegionSection tmp = *s;
-
- offset = first_bit * vmem->block_size;
- last_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size,
- first_bit + 1) - 1;
- size = (last_bit - first_bit + 1) * vmem->block_size;
-
- if (!memory_region_section_intersect_range(&tmp, offset, size)) {
- break;
- }
- ret = cb(&tmp, arg);
- if (ret) {
- break;
- }
- first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size,
- last_bit + 2);
- }
- return ret;
-}
-
static void virtio_mem_notify_unplug(VirtIOMEM *vmem, uint64_t offset,
uint64_t size)
{
@@ -1667,50 +1601,6 @@ static bool virtio_mem_rds_is_populated(const RamDiscardSource *rds,
return virtio_mem_is_range_plugged(vmem, start_gpa, end_gpa - start_gpa);
}
-struct VirtIOMEMReplayData {
- ReplayRamDiscardState fn;
- void *opaque;
-};
-
-static int virtio_mem_rds_replay_cb(MemoryRegionSection *s, void *arg)
-{
- struct VirtIOMEMReplayData *data = arg;
-
- return data->fn(s, data->opaque);
-}
-
-static int virtio_mem_rds_replay_populated(const RamDiscardSource *rds,
- const MemoryRegionSection *s,
- ReplayRamDiscardState replay_fn,
- void *opaque)
-{
- const VirtIOMEM *vmem = VIRTIO_MEM(rds);
- struct VirtIOMEMReplayData data = {
- .fn = replay_fn,
- .opaque = opaque,
- };
-
- g_assert(s->mr == &vmem->memdev->mr);
- return virtio_mem_for_each_plugged_section(vmem, s, &data,
- virtio_mem_rds_replay_cb);
-}
-
-static int virtio_mem_rds_replay_discarded(const RamDiscardSource *rds,
- const MemoryRegionSection *s,
- ReplayRamDiscardState replay_fn,
- void *opaque)
-{
- const VirtIOMEM *vmem = VIRTIO_MEM(rds);
- struct VirtIOMEMReplayData data = {
- .fn = replay_fn,
- .opaque = opaque,
- };
-
- g_assert(s->mr == &vmem->memdev->mr);
- return virtio_mem_for_each_unplugged_section(vmem, s, &data,
- virtio_mem_rds_replay_cb);
-}
-
static void virtio_mem_unplug_request_check(VirtIOMEM *vmem, Error **errp)
{
if (vmem->unplugged_inaccessible == ON_OFF_AUTO_OFF) {
@@ -1766,8 +1656,6 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data)
rdsc->get_min_granularity = virtio_mem_rds_get_min_granularity;
rdsc->is_populated = virtio_mem_rds_is_populated;
- rdsc->replay_populated = virtio_mem_rds_replay_populated;
- rdsc->replay_discarded = virtio_mem_rds_replay_discarded;
}
static const TypeInfo virtio_mem_info = {
--
2.54.0
next prev parent reply other threads:[~2026-05-04 12:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 12:30 [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 01/13] system/memory: split RamDiscardManager into source and manager Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 02/13] system/memory: move RamDiscardManager to separate compilation unit Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 03/13] system/memory: constify section arguments Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 04/13] system/ram-discard-manager: implement replay via is_populated iteration Marc-André Lureau
2026-05-13 20:40 ` Peter Xu
2026-05-04 12:30 ` Marc-André Lureau [this message]
2026-05-13 20:40 ` [PATCH v4 05/13] virtio-mem: remove replay_populated/replay_discarded implementation Peter Xu
2026-05-04 12:30 ` [PATCH v4 06/13] system/ram-discard-manager: drop replay from source interface Marc-André Lureau
2026-05-13 20:40 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 07/13] system/memory: implement RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 08/13] system/physmem: destroy ram block attributes before RCU-deferred reclaim Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 09/13] system/memory: add RamDiscardManager reference counting and cleanup Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 10/13] tests: add unit tests for RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 11/13] system/physmem: make ram_block_discard_range() handle guest_memfd Marc-André Lureau
2026-05-13 20:37 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 12/13] monitor: add 'info ramblock-attributes' command Marc-André Lureau
2026-05-13 20:39 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 13/13] RFC: hw/virtio: start virtio-mem guest_memfd regions as shared Marc-André Lureau
2026-05-13 20:47 ` Peter Xu
2026-05-14 7:32 ` Chenyi Qiang
2026-05-13 20:53 ` [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Peter Xu
2026-05-14 5:15 ` Chenyi Qiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260504-rdm5-v4-5-bdf61e57c1e1@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.