All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Dong, Eddie" <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: pre-cleanup for SMP: move mmu cache to be VM bais
Date: Thu, 31 May 2007 11:03:22 +0300	[thread overview]
Message-ID: <465E814A.3070204@qumranet.com> (raw)
In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A0188858D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Dong, Eddie wrote:
> Move per VCPU mmu_memory_cache to be VM basis. 
>
> Your opnion?
>
> Eddie
>
> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
> index 0632d0b..77989b4 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -300,11 +300,6 @@ struct kvm_vcpu {
>  
>  	struct kvm_mmu mmu;
>  
> -	struct kvm_mmu_memory_cache mmu_pte_chain_cache;
> -	struct kvm_mmu_memory_cache mmu_rmap_desc_cache;
> -	struct kvm_mmu_memory_cache mmu_page_cache;
> -	struct kvm_mmu_memory_cache mmu_page_header_cache;
> -
>  	gfn_t last_pt_write_gfn;
>  	int   last_pt_write_count;
>  
> @@ -383,6 +378,11 @@ struct kvm {
>  	unsigned long rmap_overflow;
>  	struct list_head vm_list;
>  	struct file *filp;
> +
> +	struct kvm_mmu_memory_cache mmu_pte_chain_cache;
> +	struct kvm_mmu_memory_cache mmu_rmap_desc_cache;
> +	struct kvm_mmu_memory_cache mmu_page_cache;
> +	struct kvm_mmu_memory_cache mmu_page_header_cache;
>  };
>  
>   

This exposes a race:
>
> static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu)
> {
>     int r;
>
>     r = __mmu_topup_memory_caches(vcpu, GFP_NOWAIT);
>     if (r < 0) {
>         spin_unlock(&vcpu->kvm->lock);
>         kvm_arch_ops->vcpu_put(vcpu);
>         r = __mmu_topup_memory_caches(vcpu, GFP_KERNEL);
>         kvm_arch_ops->vcpu_load(vcpu);
>         spin_lock(&vcpu->kvm->lock);
>     }
>     return r;
> }

If, after we've allocated but before we grab the lock back, another vcpu 
comes along and steals our memory, we can oom with no recovery.

This can be fixed by having a while() in there, but I don't see a real 
need.  The memory caches are local to the vcpu so they have some modest 
performance benefit (although it's probably not meausrable given all the 
other work this code path does).

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-05-31  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-31  6:34 pre-cleanup for SMP: move mmu cache to be VM bais Dong, Eddie
     [not found] ` <10EA09EFD8728347A513008B6B0DA77A0188858D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-31  8:03   ` Avi Kivity [this message]
     [not found]     ` <465E814A.3070204-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-05-31  8:11       ` Dong, Eddie
     [not found]         ` <10EA09EFD8728347A513008B6B0DA77A01888651-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-05-31  8:20           ` Avi Kivity
     [not found]             ` <465E855B.4020706-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-05-31  8:34               ` Dong, Eddie

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=465E814A.3070204@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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.