Skip to contentSkip to conversation

raid6: add missing vzeroupper to AVX-512 code

PATCH New Eric Biggers 2 participants 2 messages Nov 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raid6: add missing vzeroupper to AVX-512 code

commit b82cf9e49c1be7cf1fd8e1bd806b0cdd25ab8127 upstream.

Since the AVX-512 optimized RAID6 code uses ZMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.

Fixes e0a491c12968 ("lib/raid6: Add AVX512 optimized gen_syndrome functions")
Fixes 13c520b2993c ("lib/raid6: Add AVX512 optimized recovery functions")
Cc Christoph Hellwig <[email protected]>
---
 lib/raid6/avx512.c       | 6 ++++++
 lib/raid6/recov_avx512.c | 2 ++
 2 files changed, 8 insertions(+)
lib/raid6/avx512.c +6 -0
index 9c3e822e1adf5..30956989e7d74 100644
@@ -95,6 +95,7 @@ static void raid6_avx5121_gen_syndrome(int disks, size_t bytes, void **ptrs)
 	}
 
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -154,6 +155,7 @@ static void raid6_avx5121_xor_syndrome(int disks, int start, int stop,
 	}
 
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -227,6 +229,7 @@ static void raid6_avx5122_gen_syndrome(int disks, size_t bytes, void **ptrs)
 	}
 
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -311,6 +314,7 @@ static void raid6_avx5122_xor_syndrome(int disks, int start, int stop,
 	}
 
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -417,6 +421,7 @@ static void raid6_avx5124_gen_syndrome(int disks, size_t bytes, void **ptrs)
 	}
 
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -550,6 +555,7 @@ static void raid6_avx5124_xor_syndrome(int disks, int start, int stop,
 			       "m" (q[d+128]), "m" (q[d+192]));
 	}
 	asm volatile("sfence" : : : "memory");
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 const struct raid6_calls raid6_avx512x4 = {
lib/raid6/recov_avx512.c +2 -0
index fd9e15bf3f30f..c8a152d9ab6da 100644
@@ -221,6 +221,7 @@ static void raid6_2data_recov_avx512(int disks, size_t bytes, int faila,
 #endif
 	}
 
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 
@@ -363,6 +364,7 @@ static void raid6_datap_recov_avx512(int disks, size_t bytes, int faila,
 #endif
 	}
 
+	asm volatile("vzeroupper");
 	kernel_fpu_end();
 }
 

base-commit: 5c40a1750f44dd6c7292d8c8d0b4ffff1734576e

Signature · 1 line
2.56.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] raid6: missing Fixes trailer for AVX-512 xor_syndrome commit 694dda62d286 --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] raid6: missing Fixes trailer for AVX-512 xor_syndrome commit 694dda62d286
--

commit 369a70502fe6ce19affa3189f8d493476e955e10
Author: Eric Biggers <[email protected]>

Quoted 8 lines

raid6: add missing vzeroupper to AVX-512 code

commit b82cf9e49c1be7cf1fd8e1bd806b0cdd25ab8127 upstream.

Since the AVX-512 optimized RAID6 code uses ZMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.

Quoted 7 lines
Fixes e0a491c12968 ("lib/raid6: Add AVX512 optimized gen_syndrome functions")
Fixes 13c520b2993c ("lib/raid6: Add AVX512 optimized recovery functions")
Cc Christoph Hellwig <[email protected]>

[Severity: Low]
In addition to the gen_syndrome and recovery functions, this patch adds vzeroupper to raid6_avx5121_xor_syndrome(), raid6_avx5122_xor_syndrome(), and raid6_avx5124_xor_syndrome(). Should this also include:

Fixes 694dda62d286 ("lib/raid6: Add AVX512 optimized xor_syndrome functions")
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1