All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org,
	aarcange@redhat.com
Subject: Re: [PATCH 2/2] KVM: MMU: Flush TLBs only once in invlpg() before releasing mmu_lock
Date: Fri, 10 Feb 2012 15:42:14 +0800	[thread overview]
Message-ID: <4F34CA56.1080202@linux.vnet.ibm.com> (raw)
In-Reply-To: <4F34C591.1030909@oss.ntt.co.jp>

On 02/10/2012 03:21 PM, Takuya Yoshikawa wrote:

> (2012/02/10 15:55), Xiao Guangrong wrote:
>> On 02/10/2012 02:29 PM, Takuya Yoshikawa wrote:
>>
>>> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
>>> index 1561028..69d06f5 100644
>>> --- a/arch/x86/kvm/paging_tmpl.h
>>> +++ b/arch/x86/kvm/paging_tmpl.h
>>> @@ -682,6 +682,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
>>>       mmu_topup_memory_caches(vcpu);
>>>
>>>       spin_lock(&vcpu->kvm->mmu_lock);
>>> +
>>>       for_each_shadow_entry(vcpu, gva, iterator) {
>>>           level = iterator.level;
>>>           sptep = iterator.sptep;
>>> @@ -697,8 +698,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
>>>               pte_gpa = FNAME(get_level1_sp_gpa)(sp);
>>>               pte_gpa += (sptep - sp->spt) * sizeof(pt_element_t);
>>>
>>> -            if (mmu_page_zap_pte(vcpu->kvm, sp, sptep))
>>> -                kvm_flush_remote_tlbs(vcpu->kvm);
>>> +            mmu_page_zap_pte(vcpu->kvm, sp, sptep);
>>>
>>>               if (!rmap_can_add(vcpu))
>>>                   break;
>>> @@ -713,6 +713,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
>>>           if (!is_shadow_present_pte(*sptep) || !sp->unsync_children)
>>>               break;
>>>       }
>>> +
>>> +    kvm_flush_remote_tlbs(vcpu->kvm);
>>>       spin_unlock(&vcpu->kvm->mmu_lock);
>>
>>
>> It is obvious wrong, i do not think all tlbs always need be flushed...
>>
> 
> What do you mean by "obvious wrong" ?
> 


In the current code, all tlbs are flushed only when s spte is zapped, but after
your change, they are always changed.

> Even before this patch, we were always flushing TLBs from the caller.
> 


Oh, could you please tell me where tlbs can be flushed except when a spte is
zapped in this path?

> I have a question:  your patches apparently changed the timing of TLB flush
> but all I could see from the changelogs were:
> 
> 
>     KVM: MMU: cleanup FNAME(invlpg)
> 
>     Directly Use mmu_page_zap_pte to zap spte in FNAME(invlpg), also remove the
>     same code between FNAME(invlpg) and FNAME(sync_page)
> 


This patch dose not change the logic, the tlb flushed time is also not changed,
it just directly call kvm_flush_remote_tlbs when a spte is zapped.

> 
>     KVM: MMU: fast prefetch spte on invlpg path
> 
>     Fast prefetch spte for the unsync shadow page on invlpg path
> 
> 


This patch did not change the code when kvm_flush_remote_tlbs is called.

Where cause your confused?


  reply	other threads:[~2012-02-10  7:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10  6:28 [PATCH 1/2] KVM: mmu_notifier: Flush TLBs before releasing mmu_lock Takuya Yoshikawa
2012-02-10  6:29 ` [PATCH 2/2] KVM: MMU: Flush TLBs only once in invlpg() " Takuya Yoshikawa
2012-02-10  6:55   ` Xiao Guangrong
2012-02-10  7:21     ` Takuya Yoshikawa
2012-02-10  7:42       ` Xiao Guangrong [this message]
2012-02-14  4:36         ` Takuya Yoshikawa
2012-02-14  4:56           ` Takuya Yoshikawa
2012-02-14 17:21             ` Andrea Arcangeli
2012-02-10  7:52 ` [PATCH 1/2] KVM: mmu_notifier: Flush TLBs " Xiao Guangrong
2012-02-13  6:00   ` Takuya Yoshikawa
2012-02-14 17:27   ` Andrea Arcangeli
2012-02-10 17:26 ` Marcelo Tosatti
2012-02-14 17:10 ` Andrea Arcangeli
2012-02-14 17:29   ` Marcelo Tosatti
2012-02-14 18:53     ` Andrea Arcangeli
2012-02-14 19:43       ` Marcelo Tosatti
2012-02-15  9:18         ` Avi Kivity
2012-02-15  9:47           ` Avi Kivity
2012-02-15 11:37             ` Xiao Guangrong
2012-02-15 14:07               ` Avi Kivity
2012-02-15 19:16                 ` Andrea Arcangeli
2012-02-16  4:50                 ` Xiao Guangrong
2012-02-16 11:57                   ` Avi Kivity
2012-02-17  2:36                     ` Xiao Guangrong

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=4F34CA56.1080202@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=aarcange@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /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.