x86: Align incw instruction to avoid split lock
PATCH 1/1 x86: Align incw instruction to avoid split lock
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.
--- x86/cstart.S | 1 + x86/cstart64.S | 1 + 2 files changed, 2 insertions(+)
x86/cstart.S +1 -0
@@ -143,6 +143,7 @@ ap_init: online_cpus: .fill (max_cpus + 7) / 8, 1, 0 +.align 2 cpu_online_count: .word 1 .code16
x86/cstart64.S +1 -0
@@ -256,4 +256,5 @@ ap_init: jne 1b ret +.align 2 cpu_online_count: .word 1
Signature · 1 line
2.17.1
Quoted 38 lines · 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/24383took a
split_locktrap at address:0x400306Root caused '
cpu_online_count' spans two cache lines, "lock incwcpu_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 <[email protected]>--- x86/cstart.S | 1 + x86/cstart64.S | 1 + 2 files changed, 2 insertions(+)x86/cstart.S +1
-0@@ -143,6 +143,7 @@ ap_init: online_cpus: .fill (max_cpus + 7) / 8, 1, 0 +.align 2 cpu_online_count: .word 1 .code16x86/cstart64.S +0
-0
x86/cstart64.S ap_init: · line 260
Quoted 5 lines
x86/cstart64.S +1
-0@@ -256,4 +256,5 @@ ap_init: jne 1b ret +.align 2 cpu_online_count: .word 1
Queued, thanks.
Paolo