memory: drop RamDiscardListener::double_discard_supported
This was never turned off, effectively some dead code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Link: https://lore.kernel.org/r/20260226140001.3622334-3-marcandre.lureau@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
Marc-André Lureau committed
Feb 26, 2026 at 14:59 UTC
d3008f2e522b600137098a4f4107c8f24ffed17c
4 files changed
+5
-54
hw/vfio/listener.c
+1
-1
@@ -283,7 +283,7 @@ static bool vfio_ram_discard_register_listener(VFIOContainer *bcontainer,
283
284
ram_discard_listener_init(&vrdl->listener,
285
vfio_ram_discard_notify_populate,
286
- vfio_ram_discard_notify_discard, true);
286
+ vfio_ram_discard_notify_discard);
287
ram_discard_manager_register_listener(rdm, &vrdl->listener, section);
288
QLIST_INSERT_HEAD(&bcontainer->vrdl_list, vrdl, next);
289
hw/virtio/virtio-mem.c
+2
-20
@@ -331,14 +331,6 @@ static int virtio_mem_notify_populate_cb(MemoryRegionSection *s, void *arg)
331
return rdl->notify_populate(rdl, s);
332
}
333
334
-static int virtio_mem_notify_discard_cb(MemoryRegionSection *s, void *arg)
335
-{
336
- RamDiscardListener *rdl = arg;
337
-
338
- rdl->notify_discard(rdl, s);
339
- return 0;
340
-}
341
-
334
static void virtio_mem_notify_unplug(VirtIOMEM *vmem, uint64_t offset,
335
uint64_t size)
336
{
@@ -398,12 +390,7 @@ static void virtio_mem_notify_unplug_all(VirtIOMEM *vmem)
390
}
391
392
QLIST_FOREACH(rdl, &vmem->rdl_list, next) {
401
- if (rdl->double_discard_supported) {
402
- rdl->notify_discard(rdl, rdl->section);
403
- } else {
404
- virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
405
- virtio_mem_notify_discard_cb);
406
- }
393
+ rdl->notify_discard(rdl, rdl->section);
394
}
395
}
396
@@ -1824,12 +1811,7 @@ static void virtio_mem_rdm_unregister_listener(RamDiscardManager *rdm,
1811
1812
g_assert(rdl->section->mr == &vmem->memdev->mr);
1813
if (vmem->size) {
1827
- if (rdl->double_discard_supported) {
1828
- rdl->notify_discard(rdl, rdl->section);
1829
- } else {
1830
- virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
1831
- virtio_mem_notify_discard_cb);
1832
- }
1814
+ rdl->notify_discard(rdl, rdl->section);
1815
}
1816
1817
memory_region_section_free_copy(rdl->section);
include/system/memory.h
+1
-11
@@ -580,26 +580,16 @@ struct RamDiscardListener {
580
*/
581
NotifyRamDiscard notify_discard;
582
583
- /*
584
- * @double_discard_supported:
585
- *
586
- * The listener suppors getting @notify_discard notifications that span
587
- * already discarded parts.
588
- */
589
- bool double_discard_supported;
590
-
583
MemoryRegionSection *section;
584
QLIST_ENTRY(RamDiscardListener) next;
585
};
586
587
static inline void ram_discard_listener_init(RamDiscardListener *rdl,
588
NotifyRamPopulate populate_fn,
597
- NotifyRamDiscard discard_fn,
598
- bool double_discard_supported)
589
+ NotifyRamDiscard discard_fn)
590
{
591
rdl->notify_populate = populate_fn;
592
rdl->notify_discard = discard_fn;
602
- rdl->double_discard_supported = double_discard_supported;
593
}
594
595
/**
system/ram-block-attributes.c
+1
-22
@@ -61,16 +61,6 @@ ram_block_attributes_notify_populate_cb(MemoryRegionSection *section,
61
return rdl->notify_populate(rdl, section);
62
}
63
64
-static int
65
-ram_block_attributes_notify_discard_cb(MemoryRegionSection *section,
66
- void *arg)
67
-{
68
- RamDiscardListener *rdl = arg;
69
-
70
- rdl->notify_discard(rdl, section);
71
- return 0;
72
-}
73
-
64
static int
65
ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
66
MemoryRegionSection *section,
@@ -191,22 +181,11 @@ ram_block_attributes_rdm_unregister_listener(RamDiscardManager *rdm,
181
RamDiscardListener *rdl)
182
{
183
RamBlockAttributes *attr = RAM_BLOCK_ATTRIBUTES(rdm);
194
- int ret;
184
185
g_assert(rdl->section);
186
g_assert(rdl->section->mr == attr->ram_block->mr);
187
199
- if (rdl->double_discard_supported) {
200
- rdl->notify_discard(rdl, rdl->section);
201
- } else {
202
- ret = ram_block_attributes_for_each_populated_section(attr,
203
- rdl->section, rdl, ram_block_attributes_notify_discard_cb);
204
- if (ret) {
205
- error_report("%s: Failed to unregister RAM discard listener: %s",
206
- __func__, strerror(-ret));
207
- exit(1);
208
- }
209
- }
188
+ rdl->notify_discard(rdl, rdl->section);
189
190
memory_region_section_free_copy(rdl->section);
191
rdl->section = NULL;