figured out the real reason why this is so slow poking around in gdb some more. kvm_log_clear iterates kvm_state->nr_slots times clearing out dirty bitmaps on each memory slot. the code seems to assume nr_slots is relatively small - 32 is the default value for it if KVM_CAP_NR_MEMSLOTS is unspecified.
on my machine, KVM_CAP_NR_MEMSLOTS is 32764 :)
tracking down this mismatch between assumption and reality has led me to find it's been fixed already upstream. neat! https://patchew.org/QEMU/20230421032522.999-1-robert.hoo.linux@gmail.com/