From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: [PATCH v4 2/2] x86/kvm: Provide optimized version of vcpu_is_preempted() for x86-64 Date: Thu, 16 Feb 2017 16:00:10 -0500 Message-ID: <9c101df4-7320-556a-ca41-e024629e9a67@redhat.com> References: <1487194670-6319-1-git-send-email-longman@redhat.com> <1487194670-6319-3-git-send-email-longman@redhat.com> <20170216164815.GD6515@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170216164815.GD6515@twins.programming.kicks-ass.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Peter Zijlstra Cc: linux-arch@vger.kernel.org, Juergen Gross , Jeremy Fitzhardinge , x86@kernel.org, kvm@vger.kernel.org, =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Boris Ostrovsky , Pan Xinhui , Paolo Bonzini , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Chris Wright , Ingo Molnar , andrew.cooper3@citrix.com, "H. Peter Anvin" , xen-devel@lists.xenproject.org, Alok Kataria , Thomas Gleixner List-Id: linux-arch.vger.kernel.org On 02/16/2017 11:48 AM, Peter Zijlstra wrote: > On Wed, Feb 15, 2017 at 04:37:50PM -0500, Waiman Long wrote: >> +/* >> + * Hand-optimize version for x86-64 to avoid 8 64-bit register saving and >> + * restoring to/from the stack. It is assumed that the preempted value >> + * is at an offset of 16 from the beginning of the kvm_steal_time structure >> + * which is verified by the BUILD_BUG_ON() macro below. >> + */ >> +#define PREEMPTED_OFFSET 16 > As per Andrew's suggestion, the 'right' way is something like so. Thanks for the tip. I was not aware of the asm-offsets stuff. I will update the patch to use it. Cheers, Longman From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:33730 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933481AbdBPVAS (ORCPT ); Thu, 16 Feb 2017 16:00:18 -0500 Subject: Re: [PATCH v4 2/2] x86/kvm: Provide optimized version of vcpu_is_preempted() for x86-64 References: <1487194670-6319-1-git-send-email-longman@redhat.com> <1487194670-6319-3-git-send-email-longman@redhat.com> <20170216164815.GD6515@twins.programming.kicks-ass.net> From: Waiman Long Message-ID: <9c101df4-7320-556a-ca41-e024629e9a67@redhat.com> Date: Thu, 16 Feb 2017 16:00:10 -0500 MIME-Version: 1.0 In-Reply-To: <20170216164815.GD6515@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Peter Zijlstra Cc: Jeremy Fitzhardinge , Chris Wright , Alok Kataria , Rusty Russell , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , linux-arch@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Pan Xinhui , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Boris Ostrovsky , Juergen Gross , andrew.cooper3@citrix.com Message-ID: <20170216210010.D-TK7tyEPVyWHemnbfCKCps5sOkKBlf1E4nzOx5JyeY@z> On 02/16/2017 11:48 AM, Peter Zijlstra wrote: > On Wed, Feb 15, 2017 at 04:37:50PM -0500, Waiman Long wrote: >> +/* >> + * Hand-optimize version for x86-64 to avoid 8 64-bit register saving and >> + * restoring to/from the stack. It is assumed that the preempted value >> + * is at an offset of 16 from the beginning of the kvm_steal_time structure >> + * which is verified by the BUILD_BUG_ON() macro below. >> + */ >> +#define PREEMPTED_OFFSET 16 > As per Andrew's suggestion, the 'right' way is something like so. Thanks for the tip. I was not aware of the asm-offsets stuff. I will update the patch to use it. Cheers, Longman