Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941017AbcJXOj4 (ORCPT ); Mon, 24 Oct 2016 10:39:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53736 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932878AbcJXOjw (ORCPT ); Mon, 24 Oct 2016 10:39:52 -0400 Subject: Re: [PATCH v4 5/5] x86, kvm: support vcpu preempted check To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Pan Xinhui References: <1476872416-42752-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <1476872416-42752-6-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20161019172403.GA9240@potion> Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, xen-devel-request@lists.xenproject.org, kvm@vger.kernel.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, mingo@redhat.com, peterz@infradead.org, paulmck@linux.vnet.ibm.com, will.deacon@arm.com, kernellwp@gmail.com, jgross@suse.com, bsingharora@gmail.com, boqun.feng@gmail.com, borntraeger@de.ibm.com From: Paolo Bonzini Message-ID: Date: Mon, 24 Oct 2016 16:39:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20161019172403.GA9240@potion> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 24 Oct 2016 14:39:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 749 Lines: 23 On 19/10/2016 19:24, Radim Krčmář wrote: >> > + if (vcpu->arch.st.msr_val & KVM_MSR_ENABLED) >> > + if (kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, >> > + &vcpu->arch.st.steal, >> > + sizeof(struct kvm_steal_time)) == 0) { >> > + vcpu->arch.st.steal.preempted = 1; >> > + kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, >> > + &vcpu->arch.st.steal, >> > + sizeof(struct kvm_steal_time)); >> > + } > Please name this block of code. Something like > kvm_steal_time_set_preempted(vcpu); While at it: 1) the kvm_read_guest_cached is not necessary. You can rig the call to kvm_write_guest_cached so that it only writes vcpu->arch.st.steal.preempted. 2) split the patch in host and guest sides. Paolo