From 1dde2576ecb4410250250e1b44c1478925a0da6a Mon Sep 17 00:00:00 2001 From: Zack Winter <3457246+zackwintermdb@users.noreply.github.com> Date: Thu, 2 May 2024 19:00:58 -0700 Subject: [PATCH] SERVER-90036 Set glibc.pthread.rseq on evergreen variants with glibc version >= 2.34 (#21713) GitOrigin-RevId: 376c345d34577098b95aedbc9daa2a7b937497f4 --- evergreen/prelude.sh | 1 + evergreen/prelude_system_env_variables.sh | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 evergreen/prelude_system_env_variables.sh diff --git a/evergreen/prelude.sh b/evergreen/prelude.sh index eb671d4b5ae..b935774f10a 100755 --- a/evergreen/prelude.sh +++ b/evergreen/prelude.sh @@ -12,6 +12,7 @@ evergreen_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" . "$evergreen_dir/prelude_venv.sh" . "$evergreen_dir/prelude_db_contrib_tool.sh" . "$evergreen_dir/prelude_mongo_task_generator.sh" +. "$evergreen_dir/prelude_system_env_variables.sh" expansions_yaml="$evergreen_dir/../../expansions.yml" expansions_default_yaml="$evergreen_dir/../etc/expansions.default.yml" diff --git a/evergreen/prelude_system_env_variables.sh b/evergreen/prelude_system_env_variables.sh new file mode 100755 index 00000000000..4ad4ba073a2 --- /dev/null +++ b/evergreen/prelude_system_env_variables.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +get_glibc_version() { + getconf GNU_LIBC_VERSION | cut -d ' ' -f 2 +} + +# Systems with glibc 2.34 or newer register custom rseq ABI +# behavior that is incompatible with the new TCMalloc, and will cause +# TCMalloc's rseq functionality to break and fall back to the per-thread +# cache behavior. Systems with an older glibc version will successfully +# use TCMalloc's per-CPU caches. We must ensure this environment variable is +# set on problematic systems. +configure_glibc_pthread_req() { + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + local ver="$(get_glibc_version)" + local major="$(echo $ver | cut -d '.' -f 1)" + local minor="$(echo $ver | cut -d '.' -f 2)" + if ((major > 2 || ((major == 2 && minor >= 34)))); then + export GLIBC_TUNABLES="glibc.pthread.rseq=0" + echo "glibc version >= 2.34 detected, setting env variable GLIBC_TUNABLES=glibc.pthread.rseq=0" + fi + fi +} + +configure_glibc_pthread_req