All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] x86: Align incw instruction to avoid split lock
@ 2022-01-24 11:14 Junming Liu
  2022-01-24 14:17 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Junming Liu @ 2022-01-24 11:14 UTC (permalink / raw)
  To: pbonzini, seanjc, kvm; +Cc: Junming Liu

A split lock is any atomic operation whose operand crosses two cache
lines. Since the operand spans two cache lines and the operation must
be atomic, the system locks the bus while the CPU accesses the two cache
lines. The bus lock operation is heavy weight and can cause
severe performance degradation.

Here's the log when run x86 test cases:
[ 3572.765921] x86/split lock detection: #AC: qemu-system-x86/24383
took a split_lock trap at address: 0x400306

Root caused 'cpu_online_count' spans two cache lines,
"lock incw cpu_online_count" instruction causes split lock.
'cpu_online_count' is the type of word(two bytes) and
therefore it needs to be aligned to 2 bytes to avoid split lock.

Signed-off-by: Junming Liu <junming.liu@intel.com>
---
 x86/cstart.S   | 1 +
 x86/cstart64.S | 1 +
 2 files changed, 2 insertions(+)

diff --git a/x86/cstart.S b/x86/cstart.S
index 2c0eec7..6db6a38 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -143,6 +143,7 @@ ap_init:
 online_cpus:
 	.fill (max_cpus + 7) / 8, 1, 0
 
+.align 2
 cpu_online_count:	.word 1
 
 .code16
diff --git a/x86/cstart64.S b/x86/cstart64.S
index ff79ae7..7272452 100644
--- a/x86/cstart64.S
+++ b/x86/cstart64.S
@@ -256,4 +256,5 @@ ap_init:
 	jne 1b
 	ret
 
+.align 2
 cpu_online_count:	.word 1
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [kvm-unit-tests PATCH] x86: Align incw instruction to avoid split lock
  2022-01-24 11:14 [kvm-unit-tests PATCH] x86: Align incw instruction to avoid split lock Junming Liu
@ 2022-01-24 14:17 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-01-24 14:17 UTC (permalink / raw)
  To: Junming Liu, seanjc, kvm

On 1/24/22 12:14, Junming Liu wrote:
> A split lock is any atomic operation whose operand crosses two cache
> lines. Since the operand spans two cache lines and the operation must
> be atomic, the system locks the bus while the CPU accesses the two cache
> lines. The bus lock operation is heavy weight and can cause
> severe performance degradation.
> 
> Here's the log when run x86 test cases:
> [ 3572.765921] x86/split lock detection: #AC: qemu-system-x86/24383
> took a split_lock trap at address: 0x400306
> 
> Root caused 'cpu_online_count' spans two cache lines,
> "lock incw cpu_online_count" instruction causes split lock.
> 'cpu_online_count' is the type of word(two bytes) and
> therefore it needs to be aligned to 2 bytes to avoid split lock.
> 
> Signed-off-by: Junming Liu <junming.liu@intel.com>
> ---
>   x86/cstart.S   | 1 +
>   x86/cstart64.S | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/x86/cstart.S b/x86/cstart.S
> index 2c0eec7..6db6a38 100644
> --- a/x86/cstart.S
> +++ b/x86/cstart.S
> @@ -143,6 +143,7 @@ ap_init:
>   online_cpus:
>   	.fill (max_cpus + 7) / 8, 1, 0
>   
> +.align 2
>   cpu_online_count:	.word 1
>   
>   .code16
> diff --git a/x86/cstart64.S b/x86/cstart64.S
> index ff79ae7..7272452 100644
> --- a/x86/cstart64.S
> +++ b/x86/cstart64.S
> @@ -256,4 +256,5 @@ ap_init:
>   	jne 1b
>   	ret
>   
> +.align 2
>   cpu_online_count:	.word 1

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-24 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 11:14 [kvm-unit-tests PATCH] x86: Align incw instruction to avoid split lock Junming Liu
2022-01-24 14:17 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.