1 /***************************************************************************** 2 3 Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License, version 2.0, as published by the 7 Free Software Foundation. 8 9 This program is also distributed with certain software (including but not 10 limited to OpenSSL) that is licensed under separate terms, as designated in a 11 particular file or component or in included license documentation. The authors 12 of MySQL hereby grant you an additional permission to link the program and 13 your derivative works with the separately licensed software that they have 14 included with MySQL. 15 16 This program is distributed in the hope that it will be useful, but WITHOUT 17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, 19 for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 25 *****************************************************************************/ 26 27 /** @file include/ut0cpu_cache.h 28 Utilities related to CPU cache. */ 29 30 #ifndef ut0cpu_cache_h 31 #define ut0cpu_cache_h 32 33 #include "ut0ut.h" 34 namespace ut { 35 36 /** CPU cache line size */ 37 #ifdef __powerpc__ 38 constexpr size_t INNODB_CACHE_LINE_SIZE = 128; 39 #else 40 constexpr size_t INNODB_CACHE_LINE_SIZE = 64; 41 #endif /* __powerpc__ */ 42 43 /** 44 A utility wrapper class, which adds padding at the end of the wrapped structure, 45 so that the next object after it is guaranteed to be in the next cache line. 46 This is to avoid false-sharing. 47 Use this, as opposed to alignas(), to avoid problems with allocators which do 48 not handle over-aligned types. 49 */ 50 template <typename T> 51 struct Cacheline_padded : public T { 52 char pad[INNODB_CACHE_LINE_SIZE]; 53 }; 54 } /* namespace ut */ 55 56 #endif /* ut0cpu_cache_h */ 57