lkml.org 
[lkml]   [2018]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 05/15] x86/split_lock: Use non atomic set and clear bit instructions to clear cpufeature
Date
When #AC exception is enabled for split locked accesses,
clear_cpufeature() generates #AC exception because of atomic setting
or clearing bits in non cache line aligned x86_capability depending
on compiler.

But kernel clears cpufeatures only when a CPU boots up. Therefore, there
is no racing condition when clear_cpufeature() is called and no need to
atomically clear or set x86_capability.

To avoid #AC exception caused by split lock and get better performance,
call non atomic __set_bit() and __clear_bit().

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
---
arch/x86/kernel/cpu/cpuid-deps.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index 2c0bd38a44ab..0c02c6e44ea7 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -65,15 +65,15 @@ static const struct cpuid_dep cpuid_deps[] = {
static inline void clear_feature(struct cpuinfo_x86 *c, unsigned int feature)
{
/*
- * Note: This could use the non atomic __*_bit() variants, but the
- * rest of the cpufeature code uses atomics as well, so keep it for
- * consistency. Cleanup all of it separately.
+ * Because this code is only called during boot time and there
+ * is no need to be atomic, use non atomic __*_bit() to avoid
+ * #AC exception for split locked access.
*/
if (!c) {
clear_cpu_cap(&boot_cpu_data, feature);
- set_bit(feature, (unsigned long *)cpu_caps_cleared);
+ __set_bit(feature, (unsigned long *)cpu_caps_cleared);
} else {
- clear_bit(feature, (unsigned long *)c->x86_capability);
+ __clear_bit(feature, (unsigned long *)c->x86_capability);
}
}

--
2.5.0
\
 
 \ /
  Last update: 2018-05-14 20:55    [W:0.549 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site