public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Zhang, Xiantao" <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org,
	Hollis Blanchard
	<hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] KVM portability split : move mmu code to arch
Date: Sun, 18 Nov 2007 13:31:28 +0200	[thread overview]
Message-ID: <47402290.2030604@qumranet.com> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC9A064F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Zhang, Xiantao wrote:
> According to privious decisions, mmu code should be moved to arch.  
>
> >From 43a629932b6babcbf2af75299192c1d77c2393d5 Mon Sep 17 00:00:00 2001
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Fri, 16 Nov 2007 13:16:40 +0800
> Subject: [PATCH] KVM: MMU split for portability.
> Since mmu code is very arch-denpendent, move them to archs.
> 1. For kvm_vm_ioctl_get_dirty_log, this ioctl should be first transfered
> to arch-specific code, and will 
> call the common code implemtend in kvm_get_dirty_log to perform common
> task. 
> 2. For set_memory_region,  I moved the mmu-speicific operations to an
> arch-ops. 
> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/kvm/kvm.h      |    8 ++++
>  drivers/kvm/kvm_main.c |   49 +++------------------------
>  drivers/kvm/x86.c      |   85
> +++++++++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 94 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index 0414e92..84eec47 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -362,29 +362,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  	if (mem->slot >= kvm->nmemslots)
>  		kvm->nmemslots = mem->slot + 1;
>  
> -	if (!kvm->n_requested_mmu_pages) {
> -		unsigned int n_pages;
> -
> -		if (npages) {
> -			n_pages = npages * KVM_PERMILLE_MMU_PAGES /
> 1000;
> -			kvm_mmu_change_mmu_pages(kvm,
> kvm->n_alloc_mmu_pages +
> -						 n_pages);
> -		} else {
> -			unsigned int nr_mmu_pages;
> -
> -			n_pages = old.npages * KVM_PERMILLE_MMU_PAGES /
>   

We rely on the values in 'old' here...

> 1000;
> -			nr_mmu_pages = kvm->n_alloc_mmu_pages - n_pages;
> -			nr_mmu_pages = max(nr_mmu_pages,
> -				        (unsigned int)
> KVM_MIN_ALLOC_MMU_PAGES);
> -			kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
> -		}
> -	}
>  
>  	*memslot = new;
>  
> -	kvm_mmu_slot_remove_write_access(kvm, mem->slot);
> -	kvm_flush_remote_tlbs(kvm);
> -
>  	kvm_free_physmem_slot(&old, &new);
>  	return 0;
>  
> @@ -404,6 +384,8 @@ int kvm_set_memory_region(struct kvm *kvm,
>  
>  	mutex_lock(&kvm->lock);
>  	r = __kvm_set_memory_region(kvm, mem, user_alloc);
> +	if (r == 0)
> +		kvm_arch_set_memory_region(kvm, mem, user_alloc);
>   

But 'old' does not longer exist here.  You recalculate it from  
kvm->memslots[] but the value is not longer identical to the 'old' value.

Suggest changing this code not to rely on 'old' at all; instead 
recalculate nr_mmu_pages from kvm->memslots[] each time.  That will make 
the code more robust, enabling the movement later.


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


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

      parent reply	other threads:[~2007-11-18 11:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-16  5:38 [PATCH] KVM portability split : move mmu code to arch Zhang, Xiantao
     [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC9A064F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-16  5:50   ` Zhang, Xiantao
2007-11-18 11:31   ` Avi Kivity [this message]

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=47402290.2030604@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
    --cc=hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox