PR libstdc++/71312 Increase alignment of pooled mutexes
authorJonathan Wakely <jwakely@redhat.com>
Mon, 29 Apr 2019 12:55:29 +0000 (13:55 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 29 Apr 2019 12:55:29 +0000 (13:55 +0100)
PR libstdc++/71312
* src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes.

From-SVN: r270649

libstdc++-v3/ChangeLog
libstdc++-v3/src/c++11/shared_ptr.cc

index a5482bb..2168a79 100644 (file)
@@ -1,5 +1,8 @@
 2019-04-29  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/71312
+       * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes.
+
        * include/bits/stl_bvector.h (vector<bool>::empty()): Add nodiscard
        attribute.
 
index 1f1323e..a4e833b 100644 (file)
@@ -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];
   }
 }