From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Bin Yang <bin.yang@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Mark Gross <mark.gross@intel.com>
Subject: [PATCH 6/8] x86/mm/cpa: Move CLFLUSH test into cpa_flush_array()
Date: Wed, 19 Sep 2018 10:50:22 +0200 [thread overview]
Message-ID: <20180919085948.087848187@infradead.org> (raw)
In-Reply-To: 20180919085016.164552924@infradead.org
Rather than guarding cpa_flush_array() users with a CLFLUSH test, put
it inside.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/mm/pageattr.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -328,6 +328,11 @@ static void cpa_flush_array(unsigned lon
BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
+ if (!static_cpu_has(X86_FEATURE_CLFLUSH)) {
+ cpa_flush_all(cache);
+ return;
+ }
+
flush_tlb_kernel_range(baddr, baddr + PAGE_SIZE * numpages);
if (!cache)
@@ -1753,19 +1758,19 @@ static int change_page_attr_set_clr(unsi
cache = !!pgprot2cachemode(mask_set);
/*
- * On success we use CLFLUSH, when the CPU supports it to
- * avoid the WBINVD. If the CPU does not support it and in the
- * error case we fall back to cpa_flush_all (which uses
- * WBINVD):
- */
- if (!ret && boot_cpu_has(X86_FEATURE_CLFLUSH)) {
- if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
- cpa_flush_array(baddr, addr, numpages, cache,
- cpa.flags, pages);
- } else
- cpa_flush_range(baddr, numpages, cache);
- } else
+ * On error; flush everything to be sure.
+ */
+ if (ret) {
cpa_flush_all(cache);
+ goto out;
+ }
+
+ if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
+ cpa_flush_array(baddr, addr, numpages, cache,
+ cpa.flags, pages);
+ } else {
+ cpa_flush_range(baddr, numpages, cache);
+ }
out:
return ret;
next prev parent reply other threads:[~2018-09-19 9:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 8:50 [PATCH 0/8] x86/mm/cpa: Further optimizations Peter Zijlstra
2018-09-19 8:50 ` [PATCH 1/8] x86/mm/cpa: Use flush_tlb_all() Peter Zijlstra
2018-09-19 9:15 ` Peter Zijlstra
2018-09-19 10:08 ` Thomas Gleixner
2018-09-27 18:51 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 2/8] x86/mm/cpa: Move flush_tlb_all() Peter Zijlstra
2018-09-21 21:34 ` Dave Hansen
2018-09-22 10:37 ` Peter Zijlstra
2018-09-24 16:11 ` Dave Hansen
2018-09-27 18:52 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 3/8] x86/mm/cpa: Unconditionally avoid WBINDV when we can Peter Zijlstra
2018-09-27 18:53 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 4/8] x86/mm/cpa: Use flush_tlb_kernel_range() Peter Zijlstra
2018-09-27 18:53 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 5/8] x86/mm/cpa: Move CLFLUSH test into cpa_flush_range() Peter Zijlstra
2018-09-27 18:54 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` Peter Zijlstra [this message]
2018-09-27 18:54 ` [tip:x86/mm] x86/mm/cpa: Move CLFLUSH test into cpa_flush_array() tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 7/8] x86/mm/cpa: Factor common code between cpa_flush_*() Peter Zijlstra
2018-09-27 18:55 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-19 8:50 ` [PATCH 8/8] x86/mm/cpa: Optimize __cpa_flush_range() Peter Zijlstra
2018-09-27 18:55 ` [tip:x86/mm] " tip-bot for Peter Zijlstra
2018-09-21 22:50 ` [PATCH 0/8] x86/mm/cpa: Further optimizations Dave Hansen
2018-09-21 22:50 ` Dave Hansen
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=20180919085948.087848187@infradead.org \
--to=peterz@infradead.org \
--cc=bin.yang@intel.com \
--cc=dave.hansen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.gross@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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).