All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	syzbot+e0de2333cbf95ea473e8@syzkaller.appspotmail.com
Subject: Re: [PATCH] KVM: replace large kvmalloc allocation with vmalloc
Date: Fri, 15 Oct 2021 17:28:09 +0000	[thread overview]
Message-ID: <YWm6KcNvaHDMhfsG@google.com> (raw)
In-Reply-To: <20211015165519.135670-1-pbonzini@redhat.com>

On Fri, Oct 15, 2021, Paolo Bonzini wrote:
> diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> index 21427e84a82e..0d9842472288 100644
> --- a/arch/x86/kvm/mmu/page_track.c
> +++ b/arch/x86/kvm/mmu/page_track.c
> @@ -36,8 +36,7 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
>  
>  	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 :-)

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()?

>  		if (!slot->arch.gfn_track[i])
>  			goto track_free;
>  	}
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index aabd3a2ec1bc..07f5760ea30c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -11394,7 +11394,7 @@ static int memslot_rmap_alloc(struct kvm_memory_slot *slot,
>  
>  		WARN_ON(slot->arch.rmap[i]);
>  
> -		slot->arch.rmap[i] = kvcalloc(lpages, sz, GFP_KERNEL_ACCOUNT);
> +		slot->arch.rmap[i] = vcalloc(lpages, sz);
>  		if (!slot->arch.rmap[i]) {
>  			memslot_rmap_free(slot);
>  			return -ENOMEM;
> @@ -11475,7 +11475,7 @@ static int kvm_alloc_memslot_metadata(struct kvm *kvm,
>  
>  		lpages = __kvm_mmu_slot_lpages(slot, npages, level);
>  
> -		linfo = kvcalloc(lpages, sizeof(*linfo), GFP_KERNEL_ACCOUNT);
> +		linfo = vcalloc(lpages, sizeof(*linfo));
>  		if (!linfo)
>  			goto out_free;

All of the associated free paths should be converted to vfree().

  reply	other threads:[~2021-10-15 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 16:55 [PATCH] KVM: replace large kvmalloc allocation with vmalloc Paolo Bonzini
2021-10-15 17:28 ` Sean Christopherson [this message]
2021-10-15 17:48   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YWm6KcNvaHDMhfsG@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=syzbot+e0de2333cbf95ea473e8@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.