linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Filippo Sironi <sironi@amazon.de>,
	David Woodhouse <dwmw@amazon.co.uk>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andy Lutomirski <luto@kernel.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>,
	Dan Williams <dan.j.williams@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	arjan.van.de.ven@intel.com, dave.hansen@intel.com,
	jmattson@google.com, karahmed@amazon.de, kvm@vger.kernel.org,
	rkrcmar@redhat.com, Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 4.4 09/33] KVM/x86: Reduce retpoline performance impact in slot_handle_level_range(), by always inlining iterator helper methods
Date: Wed, 21 Feb 2018 13:44:52 +0100	[thread overview]
Message-ID: <20180221124410.165090932@linuxfoundation.org> (raw)
In-Reply-To: <20180221124409.564661689@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Woodhouse <dwmw@amazon.co.uk>

commit 928a4c39484281f8ca366f53a1db79330d058401 upstream.

With retpoline, tight loops of "call this function for every XXX" are
very much pessimised by taking a prediction miss *every* time. This one
is by far the biggest contributor to the guest launch time with retpoline.

By marking the iterator slot_handle_…() functions always_inline, we can
ensure that the indirect function call can be optimised away into a
direct call and it actually generates slightly smaller code because
some of the other conditionals can get optimised away too.

Performance is now pretty close to what we see with nospectre_v2 on
the command line.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Filippo Sironi <sironi@amazon.de>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Filippo Sironi <sironi@amazon.de>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: arjan.van.de.ven@intel.com
Cc: dave.hansen@intel.com
Cc: jmattson@google.com
Cc: karahmed@amazon.de
Cc: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com
Link: http://lkml.kernel.org/r/1518305967-31356-4-git-send-email-dwmw@amazon.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kvm/mmu.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4503,7 +4503,7 @@ void kvm_mmu_setup(struct kvm_vcpu *vcpu
 typedef bool (*slot_level_handler) (struct kvm *kvm, unsigned long *rmap);
 
 /* The caller should hold mmu-lock before calling this function. */
-static bool
+static __always_inline bool
 slot_handle_level_range(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			slot_level_handler fn, int start_level, int end_level,
 			gfn_t start_gfn, gfn_t end_gfn, bool lock_flush_tlb)
@@ -4533,7 +4533,7 @@ slot_handle_level_range(struct kvm *kvm,
 	return flush;
 }
 
-static bool
+static __always_inline bool
 slot_handle_level(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		  slot_level_handler fn, int start_level, int end_level,
 		  bool lock_flush_tlb)
@@ -4544,7 +4544,7 @@ slot_handle_level(struct kvm *kvm, struc
 			lock_flush_tlb);
 }
 
-static bool
+static __always_inline bool
 slot_handle_all_level(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		      slot_level_handler fn, bool lock_flush_tlb)
 {
@@ -4552,7 +4552,7 @@ slot_handle_all_level(struct kvm *kvm, s
 				 PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb);
 }
 
-static bool
+static __always_inline bool
 slot_handle_large_level(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			slot_level_handler fn, bool lock_flush_tlb)
 {
@@ -4560,7 +4560,7 @@ slot_handle_large_level(struct kvm *kvm,
 				 PT_MAX_HUGEPAGE_LEVEL, lock_flush_tlb);
 }
 
-static bool
+static __always_inline bool
 slot_handle_leaf(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		 slot_level_handler fn, bool lock_flush_tlb)
 {

  parent reply	other threads:[~2018-02-21 12:44 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 12:44 [PATCH 4.4 00/33] 4.4.117-stable review Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 01/33] IB/mlx4: Fix incorrectly releasing steerable UD QPs when have only ETH ports Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 02/33] PM / devfreq: Propagate error from devfreq_add_device() Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 03/33] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 04/33] ARM: dts: STi: Add gpio polarity for "hdmi,hpd-gpio" property Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 05/33] arm: spear600: Add missing interrupt-parent of rtc Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 06/33] arm: spear13xx: Fix dmas cells Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 07/33] arm: spear13xx: Fix spics gpio controllers warning Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 08/33] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
2018-02-21 12:44 ` Greg Kroah-Hartman [this message]
2018-02-21 12:44 ` [PATCH 4.4 10/33] x86/cpu: Change type of x86_cache_size variable to unsigned int Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 11/33] drm/radeon: adjust tested variable Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 12/33] rtc-opal: Fix handling of firmware error codes, prevent busy loops Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 13/33] ext4: save error to disk in __ext4_grp_locked_error() Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 14/33] ext4: correct documentation for grpid mount option Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 15/33] mm: hide a #warning for COMPILE_TEST Greg Kroah-Hartman
2018-02-21 12:44 ` [PATCH 4.4 16/33] video: fbdev: atmel_lcdfb: fix display-timings lookup Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 17/33] console/dummy: leave .con_font_get set to NULL Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 18/33] rtlwifi: rtl8821ae: Fix connection lost problem correctly Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 19/33] Btrfs: fix deadlock in run_delalloc_nocow Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 20/33] Btrfs: fix crash due to not cleaning up tree log blocks dirty bits Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 21/33] Btrfs: fix unexpected -EEXIST when creating new inode Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 22/33] ALSA: hda - Fix headset mic detection problem for two Dell machines Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 23/33] ALSA: usb-audio: Fix UAC2 get_ctl request with a RANGE attribute Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 24/33] ALSA: hda/realtek: PCI quirk for Fujitsu U7x7 Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 25/33] ALSA: usb-audio: add implicit fb quirk for Behringer UFX1204 Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 26/33] ALSA: seq: Fix racy pool initializations Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 27/33] mvpp2: fix multicast address filter Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 28/33] dm: correctly handle chained bios in dec_pending() Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 29/33] x86: fix build warnign with 32-bit PAE Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 30/33] vfs: dont do RCU lookup of empty pathnames Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 31/33] ARM: pxa/tosa-bt: add MODULE_LICENSE tag Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 32/33] ARM: dts: s5pv210: add interrupt-parent for ohci Greg Kroah-Hartman
2018-02-21 12:45 ` [PATCH 4.4 33/33] media: r820t: fix r820t_write_reg for KASAN Greg Kroah-Hartman
2018-02-21 14:46 ` [PATCH 4.4 00/33] 4.4.117-stable review Nathan Chancellor
2018-02-21 15:30   ` Greg Kroah-Hartman
2018-02-21 17:58 ` Naresh Kamboju
2018-02-21 18:57 ` kernelci.org bot
2018-02-21 20:12 ` Shuah Khan
2018-02-22 14:11 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180221124410.165090932@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=arjan.van.de.ven@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=dwmw@amazon.co.uk \
    --cc=jmattson@google.com \
    --cc=jpoimboe@redhat.com \
    --cc=karahmed@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rkrcmar@redhat.com \
    --cc=sironi@amazon.de \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).