From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932379Ab3CGJXB (ORCPT ); Thu, 7 Mar 2013 04:23:01 -0500 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:55165 "EHLO e28smtp03.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394Ab3CGJW7 (ORCPT ); Thu, 7 Mar 2013 04:22:59 -0500 Message-ID: <51385BA5.7020706@linux.vnet.ibm.com> Date: Thu, 07 Mar 2013 14:49:33 +0530 From: Raghavendra K T Organization: IBM User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: Chegu Vinod , Gleb Natapov , Marcelo Tosatti CC: Peter Zijlstra , Avi Kivity , Ingo Molnar , Rik van Riel , Srikar , "H. Peter Anvin" , "Nikunj A. Dadhania" , KVM , Thomas Gleixner , Jiannan Ouyang , "Andrew M. Theurer" , LKML , Srivatsa Vaddagiri , Andrew Jones Subject: Re: [PATCH RFC 1/2] kvm: Record the preemption status of vcpus using preempt notifiers References: <20130304180146.31281.33540.sendpatchset@codeblue.in.ibm.com> <20130304180206.31281.67229.sendpatchset@codeblue.in.ibm.com> <51360D0D.5020609@hp.com> In-Reply-To: <51360D0D.5020609@hp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13030709-3864-0000-0000-00000722EC92 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/05/2013 08:49 PM, Chegu Vinod wrote: > On 3/4/2013 10:02 AM, Raghavendra K T wrote: >> From: Raghavendra K T >> >> Note that we mark as preempted only when vcpu's task state was >> Running during preemption. >> >> Thanks Jiannan, Avi for preemption notifier ideas. Thanks Gleb, PeterZ >> for their precious suggestions. Thanks Srikar for an idea on avoiding >> rcu lock while checking task state that improved overcommit numbers. >> >> Signed-off-by: Raghavendra K T >> --- >> include/linux/kvm_host.h | 1 + >> virt/kvm/kvm_main.c | 5 +++++ >> 2 files changed, 6 insertions(+) >> >> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h >> index cad77fe..0b31e1c 100644 >> --- a/include/linux/kvm_host.h >> +++ b/include/linux/kvm_host.h >> @@ -252,6 +252,7 @@ struct kvm_vcpu { >> bool dy_eligible; >> } spin_loop; >> #endif >> + bool preempted; >> struct kvm_vcpu_arch arch; >> }; >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index adc68fe..83a804c 100644 >> --- a/virt/kvm/kvm_main.c >> +++ b/virt/kvm/kvm_main.c >> @@ -244,6 +244,7 @@ int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct >> kvm *kvm, unsigned id) >> kvm_vcpu_set_in_spin_loop(vcpu, false); >> kvm_vcpu_set_dy_eligible(vcpu, false); >> + vcpu->preempted = false; >> r = kvm_arch_vcpu_init(vcpu); >> if (r < 0) >> @@ -2902,6 +2903,8 @@ struct kvm_vcpu *preempt_notifier_to_vcpu(struct >> preempt_notifier *pn) >> static void kvm_sched_in(struct preempt_notifier *pn, int cpu) >> { >> struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); >> + if (vcpu->preempted) >> + vcpu->preempted = false; >> kvm_arch_vcpu_load(vcpu, cpu); >> } >> @@ -2911,6 +2914,8 @@ static void kvm_sched_out(struct >> preempt_notifier *pn, >> { >> struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); >> + if (current->state == TASK_RUNNING) >> + vcpu->preempted = true; >> kvm_arch_vcpu_put(vcpu); >> } >> >> . >> > Reviewed-by: Chegu Vinod Thank you Vinod. Gleb, Marcelo, any comment, concern on the patches?