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>
This commit is contained in:
Marc-André Lureau
2026-02-26 14:59:47 +01:00
committed by Peter Xu
parent 0a6830e68f
commit d3008f2e52
4 changed files with 5 additions and 54 deletions

View File

@@ -283,7 +283,7 @@ static bool vfio_ram_discard_register_listener(VFIOContainer *bcontainer,
ram_discard_listener_init(&vrdl->listener,
vfio_ram_discard_notify_populate,
vfio_ram_discard_notify_discard, true);
vfio_ram_discard_notify_discard);
ram_discard_manager_register_listener(rdm, &vrdl->listener, section);
QLIST_INSERT_HEAD(&bcontainer->vrdl_list, vrdl, next);

View File

@@ -331,14 +331,6 @@ static int virtio_mem_notify_populate_cb(MemoryRegionSection *s, void *arg)
return rdl->notify_populate(rdl, s);
}
static int virtio_mem_notify_discard_cb(MemoryRegionSection *s, void *arg)
{
RamDiscardListener *rdl = arg;
rdl->notify_discard(rdl, s);
return 0;
}
static void virtio_mem_notify_unplug(VirtIOMEM *vmem, uint64_t offset,
uint64_t size)
{
@@ -398,12 +390,7 @@ static void virtio_mem_notify_unplug_all(VirtIOMEM *vmem)
}
QLIST_FOREACH(rdl, &vmem->rdl_list, next) {
if (rdl->double_discard_supported) {
rdl->notify_discard(rdl, rdl->section);
} else {
virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
virtio_mem_notify_discard_cb);
}
rdl->notify_discard(rdl, rdl->section);
}
}
@@ -1824,12 +1811,7 @@ static void virtio_mem_rdm_unregister_listener(RamDiscardManager *rdm,
g_assert(rdl->section->mr == &vmem->memdev->mr);
if (vmem->size) {
if (rdl->double_discard_supported) {
rdl->notify_discard(rdl, rdl->section);
} else {
virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
virtio_mem_notify_discard_cb);
}
rdl->notify_discard(rdl, rdl->section);
}
memory_region_section_free_copy(rdl->section);

View File

@@ -580,26 +580,16 @@ struct RamDiscardListener {
*/
NotifyRamDiscard notify_discard;
/*
* @double_discard_supported:
*
* The listener suppors getting @notify_discard notifications that span
* already discarded parts.
*/
bool double_discard_supported;
MemoryRegionSection *section;
QLIST_ENTRY(RamDiscardListener) next;
};
static inline void ram_discard_listener_init(RamDiscardListener *rdl,
NotifyRamPopulate populate_fn,
NotifyRamDiscard discard_fn,
bool double_discard_supported)
NotifyRamDiscard discard_fn)
{
rdl->notify_populate = populate_fn;
rdl->notify_discard = discard_fn;
rdl->double_discard_supported = double_discard_supported;
}
/**

View File

@@ -61,16 +61,6 @@ ram_block_attributes_notify_populate_cb(MemoryRegionSection *section,
return rdl->notify_populate(rdl, section);
}
static int
ram_block_attributes_notify_discard_cb(MemoryRegionSection *section,
void *arg)
{
RamDiscardListener *rdl = arg;
rdl->notify_discard(rdl, section);
return 0;
}
static int
ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
MemoryRegionSection *section,
@@ -191,22 +181,11 @@ ram_block_attributes_rdm_unregister_listener(RamDiscardManager *rdm,
RamDiscardListener *rdl)
{
RamBlockAttributes *attr = RAM_BLOCK_ATTRIBUTES(rdm);
int ret;
g_assert(rdl->section);
g_assert(rdl->section->mr == attr->ram_block->mr);
if (rdl->double_discard_supported) {
rdl->notify_discard(rdl, rdl->section);
} else {
ret = ram_block_attributes_for_each_populated_section(attr,
rdl->section, rdl, ram_block_attributes_notify_discard_cb);
if (ret) {
error_report("%s: Failed to unregister RAM discard listener: %s",
__func__, strerror(-ret));
exit(1);
}
}
rdl->notify_discard(rdl, rdl->section);
memory_region_section_free_copy(rdl->section);
rdl->section = NULL;