Re: [PATCH v5 1/3] x86/cpufeatures: Enumerate #DB for bus lock detection

2021-03-19 Thread Fenghua Yu
On Fri, Mar 19, 2021 at 09:35:39PM +0100, Thomas Gleixner wrote:
> On Sat, Mar 13 2021 at 05:49, Fenghua Yu wrote:
> > A bus lock is acquired though either split locked access to
> 
> s/though/through/
> either a 
> > Some CPUs have ability to notify the kernel by an #DB trap after a user
> 
> the ability

Thank you for your review, Thomas! Will fix the issues.

-Fenghua


Re: [PATCH v5 1/3] x86/cpufeatures: Enumerate #DB for bus lock detection

2021-03-19 Thread Thomas Gleixner
On Sat, Mar 13 2021 at 05:49, Fenghua Yu wrote:
> A bus lock is acquired though either split locked access to

s/though/through/
either a 

> writeback (WB) memory or any locked access to non-WB memory. This is
> typically >1000 cycles slower than an atomic operation within a cache
> line. It also disrupts performance on other cores.
>
> Some CPUs have ability to notify the kernel by an #DB trap after a user

the ability

> instruction acquires a bus lock and is executed. This allows the kernel
> to enforce user application throttling or mitigations. Both breakpoint
> and bus lock can trigger the #DB trap in the same instruction and the
> ordering of handling them is the kernel #DB handler's choice.

Thanks,

tglx


[PATCH v5 1/3] x86/cpufeatures: Enumerate #DB for bus lock detection

2021-03-12 Thread Fenghua Yu
A bus lock is acquired though either split locked access to
writeback (WB) memory or any locked access to non-WB memory. This is
typically >1000 cycles slower than an atomic operation within a cache
line. It also disrupts performance on other cores.

Some CPUs have ability to notify the kernel by an #DB trap after a user
instruction acquires a bus lock and is executed. This allows the kernel
to enforce user application throttling or mitigations. Both breakpoint
and bus lock can trigger the #DB trap in the same instruction and the
ordering of handling them is the kernel #DB handler's choice.

The CPU feature flag to be shown in /proc/cpuinfo will be "bus_lock_detect".

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
Change Log:
v5:
- Add "Both breakpoint and bus lock can trigger an #DB trap..." in the
  commit message (Thomas).

 arch/x86/include/asm/cpufeatures.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/cpufeatures.h 
b/arch/x86/include/asm/cpufeatures.h
index cc96e26d69f7..faec3d92d09b 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -354,6 +354,7 @@
 #define X86_FEATURE_AVX512_VPOPCNTDQ   (16*32+14) /* POPCNT for vectors of 
DW/QW */
 #define X86_FEATURE_LA57   (16*32+16) /* 5-level page tables */
 #define X86_FEATURE_RDPID  (16*32+22) /* RDPID instruction */
+#define X86_FEATURE_BUS_LOCK_DETECT(16*32+24) /* Bus Lock detect */
 #define X86_FEATURE_CLDEMOTE   (16*32+25) /* CLDEMOTE instruction */
 #define X86_FEATURE_MOVDIRI(16*32+27) /* MOVDIRI instruction */
 #define X86_FEATURE_MOVDIR64B  (16*32+28) /* MOVDIR64B instruction */
-- 
2.30.2