From 7bbdd8d13e6cc06d77321209a945edf64350a5ac Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 29 Apr 2019 13:55:29 +0100 Subject: [PATCH] PR libstdc++/71312 Increase alignment of pooled mutexes PR libstdc++/71312 * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes. From-SVN: r270649 --- libstdc++-v3/ChangeLog | 3 +++ libstdc++-v3/src/c++11/shared_ptr.cc | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a5482bbcdf7..2168a795f48 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2019-04-29 Jonathan Wakely + PR libstdc++/71312 + * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes. + * include/bits/stl_bvector.h (vector::empty()): Add nodiscard attribute. diff --git a/libstdc++-v3/src/c++11/shared_ptr.cc b/libstdc++-v3/src/c++11/shared_ptr.cc index 1f1323ef89f..a4e833bf4c8 100644 --- a/libstdc++-v3/src/c++11/shared_ptr.cc +++ b/libstdc++-v3/src/c++11/shared_ptr.cc @@ -34,7 +34,9 @@ namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden) __gnu_cxx::__mutex& get_mutex(unsigned char i) { - static __gnu_cxx::__mutex m[mask + 1]; + // increase alignment to put each lock on a separate cache line + struct alignas(64) M : __gnu_cxx::__mutex { }; + static M m[mask + 1]; return m[i]; } } -- 2.30.2