Re: [PATCH] KVM: replace large kvmalloc allocation with vmalloc

From: Paolo Bonzini
Date: Fri Oct 15 2021 - 13:48:18 EST


On 15/10/21 19:28, Sean Christopherson wrote:
for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) {
slot->arch.gfn_track[i] =
- kvcalloc(npages, sizeof(*slot->arch.gfn_track[i]),
- GFP_KERNEL_ACCOUNT);
+ vcalloc(npages, sizeof(*slot->arch.gfn_track[i]));
This loses the memcg accounting, which is somewhat important for the theoretical
4MiB allocations:-)

True, and in fact 4 MiB is not so theoretical.

Maybe split out the introduction of vcalloc() to a separate patch (or two) and
introduce additional helpers to allow passing in gfp_t to e.g. __vzalloc()?

Yes, this is what actually slowed me down this week.This is the bare minimum that I can send to Linus right now to avoid the WARN.

I have patches to clean all of this up, but they will have to go throw Andrew Morton; he will decide whether to throw them in 5.15 or go through stable, but anyway 5.16.1 or .2 should have the accounting back at most.

Paolo