Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbdLMMb2 (ORCPT ); Wed, 13 Dec 2017 07:31:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbdLMMb0 (ORCPT ); Wed, 13 Dec 2017 07:31:26 -0500 Subject: Re: [PATCH v8 1/4] KVM: X86: Add vCPU running/preempted state To: David Hildenbrand , Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Peter Zijlstra , Wanpeng Li References: <1513128784-5924-1-git-send-email-wanpeng.li@hotmail.com> <1513128784-5924-2-git-send-email-wanpeng.li@hotmail.com> <3fb56993-3bb6-442c-f12e-0c99c06ef5c2@redhat.com> <692741fa-ff8b-add6-36f2-87374ff9abaa@redhat.com> From: Paolo Bonzini Message-ID: <7cbb12b9-e742-fe51-8713-59675e658bfc@redhat.com> Date: Wed, 13 Dec 2017 13:31:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <692741fa-ff8b-add6-36f2-87374ff9abaa@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 13 Dec 2017 12:31:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2152 Lines: 55 On 13/12/2017 12:45, David Hildenbrand wrote: > On 13.12.2017 12:38, Wanpeng Li wrote: >> 2017-12-13 18:20 GMT+08:00 David Hildenbrand : >>> On 13.12.2017 02:33, Wanpeng Li wrote: >>>> From: Wanpeng Li >>>> >>>> This patch reuses the preempted field in kvm_steal_time, and will export >>>> the vcpu running/pre-empted information to the guest from host. This will >>>> enable guest to intelligently send ipi to running vcpus and set flag for >>>> pre-empted vcpus. This will prevent waiting for vcpus that are not running. >>>> >>>> Cc: Paolo Bonzini >>>> Cc: Radim Krčmář >>>> Cc: Peter Zijlstra >>>> Signed-off-by: Wanpeng Li >>>> --- >>>> arch/x86/include/uapi/asm/kvm_para.h | 3 +++ >>>> arch/x86/kernel/kvm.c | 2 +- >>>> arch/x86/kvm/x86.c | 4 ++-- >>>> 3 files changed, 6 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h >>>> index 09cc064..763b692 100644 >>>> --- a/arch/x86/include/uapi/asm/kvm_para.h >>>> +++ b/arch/x86/include/uapi/asm/kvm_para.h >>>> @@ -51,6 +51,9 @@ struct kvm_steal_time { >>>> __u32 pad[11]; >>>> }; >>>> >>>> +#define KVM_VCPU_NOT_PREEMPTED (0 << 0) >>>> +#define KVM_VCPU_PREEMPTED (1 << 0) >>> >>> Is it really helpful to have two flags? >>> >>> Just use KVM_VCPU_PREEMPTED and clear that one in record_steal_time() >> >> I think it is fine since there is a third flag introduced in patch >> 2/4, it is more clear currently. >> >> Regards, >> Wanpeng Li >> > > Having two flags representing the same thing is not clear to me. I agree that KVM_VCPU_NOT_PREEMPTED is not particularly necessary, but it is not correct to clear KVM_VCPU_PREEMPTED; instead, the entire field must be cleared to zero. Also, this patch is not justified very well by the commit message. A better wording would be: The next patch will add another bit to the preempted field in kvm_steal_time. Define a constant for bit 0 (the only one that is currently used).