Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941453AbcJYBZm (ORCPT ); Mon, 24 Oct 2016 21:25:42 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51918 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932604AbcJYBZl (ORCPT ); Mon, 24 Oct 2016 21:25:41 -0400 Subject: Re: [PATCH v4 5/5] x86, kvm: support vcpu preempted check To: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= 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> <20161024151417.GC2247@potion> <1a556fcf-e071-8c32-7a4b-ca7a2ffc17e9@redhat.com> Cc: Pan Xinhui , 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: Pan Xinhui Date: Tue, 25 Oct 2016 09:25:37 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1a556fcf-e071-8c32-7a4b-ca7a2ffc17e9@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102501-0044-0000-0000-000001F2A7BB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102501-0045-0000-0000-000005CEC257 Message-Id: <2f37742f-6839-1ef4-0838-05fb7222f14a@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-24_19:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610250022 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1220 Lines: 39 在 2016/10/24 23:18, Paolo Bonzini 写道: > > > On 24/10/2016 17:14, Radim Krčmář wrote: >> 2016-10-24 16:39+0200, Paolo Bonzini: >>> 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. >> >> I agree. kvm_write_guest_cached() always writes from offset 0, so we'd >> want a new function that allows to specify a starting offset. > > Yeah, let's leave it for a follow-up then! > I think I can make a having-offset version. :) > Thanks, > > Paolo > >> Using cached vcpu->arch.st.steal to avoid the read wouldn't be as good. >> >