configuration_validate_capabilities() allocates a bitmap on the heap
to track source capabilities via bitmap_new()/g_free(). Since
MIGRATION_CAPABILITY__MAX is a small compile-time constant (< 64),
a heap allocation for a bitmap this small is wasteful: it adds
malloc/free overhead and a potential cache miss for a transient
8-byte allocation.
Replace with DECLARE_BITMAP() on the stack and bitmap_zero() to
initialize. This eliminates the heap round-trip entirely.
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20260518110112.21395-5-guobin@linux.alibaba.com
Signed-off-by: Peter Xu <peterx@redhat.com>
{
bool ret = true;
MigrationState *s = migrate_get_current();
- unsigned long *source_caps_bm;
+ DECLARE_BITMAP(source_caps_bm, MIGRATION_CAPABILITY__MAX);
int i;
- source_caps_bm = bitmap_new(MIGRATION_CAPABILITY__MAX);
+ bitmap_zero(source_caps_bm, MIGRATION_CAPABILITY__MAX);
for (i = 0; i < state->caps_count; i++) {
MigrationCapability capability = state->capabilities[i];
set_bit(capability, source_caps_bm);
}
}
- g_free(source_caps_bm);
return ret;
}