Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185AbdCIWo4 (ORCPT ); Thu, 9 Mar 2017 17:44:56 -0500 Received: from mail.kernel.org ([198.145.29.136]:38256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753417AbdCIWow (ORCPT ); Thu, 9 Mar 2017 17:44:52 -0500 Message-Id: <20170309224447.678652367@goodmis.org> User-Agent: quilt/0.63-1 Date: Thu, 09 Mar 2017 17:42:05 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Andrew Morton Subject: [PATCH 1/2] x86/nmi: Optimize the check for being in the repeat_nmi code References: <20170309224204.066497548@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0001-x86-nmi-Optimize-the-check-for-being-in-the-repeat_n.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1203 Lines: 50 From: "Steven Rostedt (Red Hat)" Linus mentioned that doing two compares can be replaced by a single compare. That is, instead of: movq $repeat_nmi, %rdx cmpq 8(%rsp), %rdx ja not_in_region movq $end_repeat_nmi, %rdx cmpq 8(%rsp), %rdx ja in_region we can replace that with: movq 8(%rsp), %rdx subq $repeat_nmi, %rdx cmpq $end_repeat_nmi-repeat_nmi, %rdx jb in_region Inspired-by: Linus Torvalds Signed-off-by: Steven Rostedt (VMware) --- arch/x86/entry/entry_64.S | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 044d18ebc43c..3aad759aace2 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1330,13 +1330,10 @@ ENTRY(nmi) * resume the outer NMI. */ - movq $repeat_nmi, %rdx - cmpq 8(%rsp), %rdx - ja 1f - movq $end_repeat_nmi, %rdx - cmpq 8(%rsp), %rdx - ja nested_nmi_out -1: + movq 8(%rsp), %rdx + subq $repeat_nmi, %rdx + cmpq $end_repeat_nmi-repeat_nmi, %rdx + jb nested_nmi_out /* * Now check "NMI executing". If it's set, then we're nested. -- 2.10.2