[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250323050749.165863-1-nickrterrell@gmail.com>
Date: Sat, 22 Mar 2025 22:07:49 -0700
From: Nick Terrell <nickrterrell@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Nick Terrell <terrelln@...com>,
Nick Terrell <nickrterrell@...il.com>,
Kernel Team <Kernel-team@...com>,
David Sterba <dsterba@...e.com>,
Nick Terrell <terrelln@...a.com>,
Ingo Molnar <mingo@...hat.com>,
Michael Kelley <mhklinux@...look.com>,
Borislav Petkov <bp@...en8.de>
Subject: [PATCH] zstd: Work around gcc segfault on versions older than 11.4
From: Nick Terrell <terrelln@...a.com>
Older gcc version segfault in zstd code as of 9d7de2aa8b41 on x86. This seems
to be triggered by some other compilation changes. But it can be worked
around by disabling DYNAMIC_BMI2 for older gcc compilers.
The original suggested patch in the thread suggested gating on gcc >= 11,
but there is only positive confirmation that gcc 11.4 and later succeed,
so I'm being slightly more conservative.
This will reduce performance of Zstandard decoding by ~10% if using a
gcc version older than 11.4, and the binary is not compiled with BMI2
support at compile time.
I've compiled & run basic tests for gcc-9 and gcc-14.2. I've reproed the
gcc segfault before the fix, and it compiles after.
Link: https://lore.kernel.org/lkml/SN6PR02MB415723FBCD79365E8D72CA5FD4D82@SN6PR02MB4157.namprd02.prod.outlook.com/
CC: Ingo Molnar <mingo@...hat.com>
CC: Michael Kelley <mhklinux@...look.com>
CC: Borislav Petkov <bp@...en8.de>
Signed-off-by: Nick Terrell <terrelln@...com>
---
lib/zstd/common/portability_macros.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/zstd/common/portability_macros.h b/lib/zstd/common/portability_macros.h
index 05286af72683..efae9465d57d 100644
--- a/lib/zstd/common/portability_macros.h
+++ b/lib/zstd/common/portability_macros.h
@@ -56,12 +56,14 @@
/* Enable runtime BMI2 dispatch based on the CPU.
- * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
+ * Enabled for clang & gcc >= 11.4 on x86 when BMI2 isn't enabled by default.
+ * Disabled for gcc < 11.4 because of a segfault while compiling
+ * HUF_compress1X_usingCTable_internal_body().
*/
#ifndef DYNAMIC_BMI2
# if ((defined(__clang__) && __has_attribute(__target__)) \
|| (defined(__GNUC__) \
- && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
+ && (__GNUC__ >= 12 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 4)))) \
&& (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) \
&& !defined(__BMI2__)
# define DYNAMIC_BMI2 1
--
2.48.1
Powered by blists - more mailing lists