summaryrefslogtreecommitdiff
path: root/storage/perfschema
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-01-12 17:03:45 +0100
committerSergei Golubchik <serg@mariadb.org>2015-01-13 10:15:21 +0100
commite695db0f2d97cbba2832e0f3dc25af5add1f16ac (patch)
tree7c03822a83a0b16ae513b22659b9ac43068b0411 /storage/perfschema
parent1f0ad6c6b3421a815ea6373c66aaf693852342cf (diff)
downloadmariadb-git-e695db0f2d97cbba2832e0f3dc25af5add1f16ac.tar.gz
MDEV-7437 remove suport for "atomics" with rwlocks
Diffstat (limited to 'storage/perfschema')
-rw-r--r--storage/perfschema/CMakeLists.txt1
-rw-r--r--storage/perfschema/pfs_atomic.cc81
-rw-r--r--storage/perfschema/pfs_atomic.h139
-rw-r--r--storage/perfschema/pfs_server.cc2
-rw-r--r--storage/perfschema/unittest/pfs_account-oom-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_host-oom-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_instr-oom-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_instr-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_instr_class-oom-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_instr_class-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_timer-t.cc4
-rw-r--r--storage/perfschema/unittest/pfs_user-oom-t.cc4
12 files changed, 12 insertions, 243 deletions
diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt
index 52c1d9b05d9..c5e565979e4 100644
--- a/storage/perfschema/CMakeLists.txt
+++ b/storage/perfschema/CMakeLists.txt
@@ -132,7 +132,6 @@ cursor_by_user.cc
ha_perfschema.cc
pfs.cc
pfs_account.cc
-pfs_atomic.cc
pfs_autosize.cc
pfs_column_values.cc
pfs_con_slice.cc
diff --git a/storage/perfschema/pfs_atomic.cc b/storage/perfschema/pfs_atomic.cc
deleted file mode 100644
index 601bd94cabd..00000000000
--- a/storage/perfschema/pfs_atomic.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
-
-/**
- @file storage/perfschema/pfs_atomic.cc
- Atomic operations (implementation).
-*/
-
-#include <my_global.h>
-#include <my_pthread.h>
-#include "pfs_atomic.h"
-
-/*
- Using SAFE_MUTEX is impossible, because of recursion.
- - code locks mutex X
- - P_S records the event
- - P_S needs an atomic counter A
- - safe mutex called for m_mutex[hash(A)]
- - safe mutex allocates/free memory
- - safe mutex locks THR_LOCK_malloc
- - P_S records the event
- - P_S needs an atomic counter B
- - safe mutex called for m_mutex[hash(B)]
-
- When hash(A) == hash(B), safe_mutex complains rightly that
- the mutex is already locked.
- In some cases, A == B, in particular for events_waits_history_long_index.
-
- In short, the implementation of PFS_atomic should not cause events
- to be recorded in the performance schema.
-
- Also, because SAFE_MUTEX redefines pthread_mutex_t, etc,
- this code is not inlined in pfs_atomic.h, but located here in pfs_atomic.cc.
-
- What is needed is a plain, unmodified, pthread_mutex_t.
- This is provided by my_atomic_rwlock_t.
-*/
-
-/**
- Internal rwlock array.
- Using a single rwlock for all atomic operations would be a bottleneck.
- Using a rwlock per performance schema structure would be too costly in
- memory, and use too many rwlock.
- The PFS_atomic implementation computes a hash value from the
- atomic variable, to spread the bottleneck across 256 buckets,
- while still providing --transparently for the caller-- an atomic
- operation.
-*/
-my_atomic_rwlock_t PFS_atomic::m_rwlock_array[256];
-static int init_done;
-
-void PFS_atomic::init(void)
-{
- uint i;
-
- for (i=0; i< array_elements(m_rwlock_array); i++)
- my_atomic_rwlock_init(&m_rwlock_array[i]);
- init_done= 1;
-}
-
-void PFS_atomic::cleanup(void)
-{
- uint i;
- if (!init_done)
- return;
- for (i=0; i< array_elements(m_rwlock_array); i++)
- my_atomic_rwlock_destroy(&m_rwlock_array[i]);
-}
-
diff --git a/storage/perfschema/pfs_atomic.h b/storage/perfschema/pfs_atomic.h
index 61b8c2b2804..31833b832cf 100644
--- a/storage/perfschema/pfs_atomic.h
+++ b/storage/perfschema/pfs_atomic.h
@@ -27,221 +27,106 @@
class PFS_atomic
{
public:
- /** Initialise the PFS_atomic component. */
- static void init();
- /** Cleanup the PFS_atomic component. */
- static void cleanup();
-
/** Atomic load. */
static inline int32 load_32(volatile int32 *ptr)
{
- int32 result;
- rdlock(ptr);
- result= my_atomic_load32(ptr);
- rdunlock(ptr);
- return result;
+ return my_atomic_load32(ptr);
}
/** Atomic load. */
static inline int64 load_64(volatile int64 *ptr)
{
- int64 result;
- rdlock(ptr);
- result= my_atomic_load64(ptr);
- rdunlock(ptr);
- return result;
+ return my_atomic_load64(ptr);
}
/** Atomic load. */
static inline uint32 load_u32(volatile uint32 *ptr)
{
- uint32 result;
- rdlock(ptr);
- result= (uint32) my_atomic_load32((int32*) ptr);
- rdunlock(ptr);
- return result;
+ return (uint32) my_atomic_load32((int32*) ptr);
}
/** Atomic load. */
static inline uint64 load_u64(volatile uint64 *ptr)
{
- uint64 result;
- rdlock(ptr);
- result= (uint64) my_atomic_load64((int64*) ptr);
- rdunlock(ptr);
- return result;
+ return (uint64) my_atomic_load64((int64*) ptr);
}
/** Atomic store. */
static inline void store_32(volatile int32 *ptr, int32 value)
{
- wrlock(ptr);
my_atomic_store32(ptr, value);
- wrunlock(ptr);
}
/** Atomic store. */
static inline void store_64(volatile int64 *ptr, int64 value)
{
- wrlock(ptr);
my_atomic_store64(ptr, value);
- wrunlock(ptr);
}
/** Atomic store. */
static inline void store_u32(volatile uint32 *ptr, uint32 value)
{
- wrlock(ptr);
my_atomic_store32((int32*) ptr, (int32) value);
- wrunlock(ptr);
}
/** Atomic store. */
static inline void store_u64(volatile uint64 *ptr, uint64 value)
{
- wrlock(ptr);
my_atomic_store64((int64*) ptr, (int64) value);
- wrunlock(ptr);
}
/** Atomic add. */
static inline int32 add_32(volatile int32 *ptr, int32 value)
{
- int32 result;
- wrlock(ptr);
- result= my_atomic_add32(ptr, value);
- wrunlock(ptr);
- return result;
+ return my_atomic_add32(ptr, value);
}
/** Atomic add. */
static inline int64 add_64(volatile int64 *ptr, int64 value)
{
- int64 result;
- wrlock(ptr);
- result= my_atomic_add64(ptr, value);
- wrunlock(ptr);
- return result;
+ return my_atomic_add64(ptr, value);
}
/** Atomic add. */
static inline uint32 add_u32(volatile uint32 *ptr, uint32 value)
{
- uint32 result;
- wrlock(ptr);
- result= (uint32) my_atomic_add32((int32*) ptr, (int32) value);
- wrunlock(ptr);
- return result;
+ return (uint32) my_atomic_add32((int32*) ptr, (int32) value);
}
/** Atomic add. */
static inline uint64 add_u64(volatile uint64 *ptr, uint64 value)
{
- uint64 result;
- wrlock(ptr);
- result= (uint64) my_atomic_add64((int64*) ptr, (int64) value);
- wrunlock(ptr);
- return result;
+ return (uint64) my_atomic_add64((int64*) ptr, (int64) value);
}
/** Atomic compare and swap. */
static inline bool cas_32(volatile int32 *ptr, int32 *old_value,
int32 new_value)
{
- bool result;
- wrlock(ptr);
- result= my_atomic_cas32(ptr, old_value, new_value);
- wrunlock(ptr);
- return result;
+ return my_atomic_cas32(ptr, old_value, new_value);
}
/** Atomic compare and swap. */
static inline bool cas_64(volatile int64 *ptr, int64 *old_value,
int64 new_value)
{
- bool result;
- wrlock(ptr);
- result= my_atomic_cas64(ptr, old_value, new_value);
- wrunlock(ptr);
- return result;
+ return my_atomic_cas64(ptr, old_value, new_value);
}
/** Atomic compare and swap. */
static inline bool cas_u32(volatile uint32 *ptr, uint32 *old_value,
uint32 new_value)
{
- bool result;
- wrlock(ptr);
- result= my_atomic_cas32((int32*) ptr, (int32*) old_value,
+ return my_atomic_cas32((int32*) ptr, (int32*) old_value,
(uint32) new_value);
- wrunlock(ptr);
- return result;
}
/** Atomic compare and swap. */
static inline bool cas_u64(volatile uint64 *ptr, uint64 *old_value,
uint64 new_value)
{
- bool result;
- wrlock(ptr);
- result= my_atomic_cas64((int64*) ptr, (int64*) old_value,
+ return my_atomic_cas64((int64*) ptr, (int64*) old_value,
(uint64) new_value);
- wrunlock(ptr);
- return result;
- }
-
-private:
- static my_atomic_rwlock_t m_rwlock_array[256];
-
- /**
- Helper used only with non native atomic implementations.
- @sa MY_ATOMIC_MODE_RWLOCKS
- */
- static inline my_atomic_rwlock_t *get_rwlock(volatile void *ptr)
- {
- /*
- Divide an address by 8 to remove alignment,
- modulo 256 to fall in the array.
- */
- uint index= (((intptr) ptr) >> 3) & 0xFF;
- my_atomic_rwlock_t *result= &m_rwlock_array[index];
- return result;
- }
-
- /**
- Helper used only with non native atomic implementations.
- @sa MY_ATOMIC_MODE_RWLOCKS
- */
- static inline void rdlock(volatile void *ptr)
- {
- my_atomic_rwlock_rdlock(get_rwlock(ptr));
- }
-
- /**
- Helper used only with non native atomic implementations.
- @sa MY_ATOMIC_MODE_RWLOCKS
- */
- static inline void wrlock(volatile void *ptr)
- {
- my_atomic_rwlock_wrlock(get_rwlock(ptr));
- }
-
- /**
- Helper used only with non native atomic implementations.
- @sa MY_ATOMIC_MODE_RWLOCKS
- */
- static inline void rdunlock(volatile void *ptr)
- {
- my_atomic_rwlock_rdunlock(get_rwlock(ptr));
- }
-
- /**
- Helper used only with non native atomic implementations.
- @sa MY_ATOMIC_MODE_RWLOCKS
- */
- static inline void wrunlock(volatile void *ptr)
- {
- my_atomic_rwlock_wrunlock(get_rwlock(ptr));
}
};
diff --git a/storage/perfschema/pfs_server.cc b/storage/perfschema/pfs_server.cc
index 383a46785fb..9799a9c4ffc 100644
--- a/storage/perfschema/pfs_server.cc
+++ b/storage/perfschema/pfs_server.cc
@@ -71,7 +71,6 @@ initialize_performance_schema(PFS_global_param *param)
}
init_timers();
- PFS_atomic::init();
init_event_name_sizing(param);
register_global_classes();
@@ -187,7 +186,6 @@ static void cleanup_performance_schema(void)
cleanup_account_hash();
cleanup_digest();
cleanup_digest_hash();
- PFS_atomic::cleanup();
}
void shutdown_performance_schema(void)
diff --git a/storage/perfschema/unittest/pfs_account-oom-t.cc b/storage/perfschema/unittest/pfs_account-oom-t.cc
index 2343e8378ad..6984fab6648 100644
--- a/storage/perfschema/unittest/pfs_account-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_account-oom-t.cc
@@ -100,11 +100,7 @@ void test_oom()
void do_all_tests()
{
- PFS_atomic::init();
-
test_oom();
-
- PFS_atomic::cleanup();
}
int main(int, char **)
diff --git a/storage/perfschema/unittest/pfs_host-oom-t.cc b/storage/perfschema/unittest/pfs_host-oom-t.cc
index 5b823ce4eac..d12abe6f38b 100644
--- a/storage/perfschema/unittest/pfs_host-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_host-oom-t.cc
@@ -100,11 +100,7 @@ void test_oom()
void do_all_tests()
{
- PFS_atomic::init();
-
test_oom();
-
- PFS_atomic::cleanup();
}
int main(int, char **)
diff --git a/storage/perfschema/unittest/pfs_instr-oom-t.cc b/storage/perfschema/unittest/pfs_instr-oom-t.cc
index 18c0029776d..f1df130180b 100644
--- a/storage/perfschema/unittest/pfs_instr-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc
@@ -654,11 +654,7 @@ void test_oom()
void do_all_tests()
{
- PFS_atomic::init();
-
test_oom();
-
- PFS_atomic::cleanup();
}
int main(int argc, char **argv)
diff --git a/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc
index fab22b203d3..e0361b3a958 100644
--- a/storage/perfschema/unittest/pfs_instr-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-t.cc
@@ -402,13 +402,9 @@ void test_with_instances()
void do_all_tests()
{
- PFS_atomic::init();
-
test_no_instruments();
test_no_instances();
test_with_instances();
-
- PFS_atomic::cleanup();
}
int main(int argc, char **argv)
diff --git a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
index 264d6126336..dc4f954bc8a 100644
--- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
@@ -56,11 +56,7 @@ void test_oom()
void do_all_tests()
{
- PFS_atomic::init();
-
test_oom();
-
- PFS_atomic::cleanup();
}
int main(int argc, char **argv)
diff --git a/storage/perfschema/unittest/pfs_instr_class-t.cc b/storage/perfschema/unittest/pfs_instr_class-t.cc
index 706c5724a80..6fb2abc30a0 100644
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc
@@ -655,8 +655,6 @@ void test_instruments_reset()
void do_all_tests()
{
- PFS_atomic::init();
-
test_no_registration();
test_mutex_registration();
test_rwlock_registration();
@@ -666,8 +664,6 @@ void do_all_tests()
test_socket_registration();
test_table_registration();
test_instruments_reset();
-
- PFS_atomic::cleanup();
}
int main(int argc, char **argv)
diff --git a/storage/perfschema/unittest/pfs_timer-t.cc b/storage/perfschema/unittest/pfs_timer-t.cc
index 0a2cc63f30e..8fb3a206ebf 100644
--- a/storage/perfschema/unittest/pfs_timer-t.cc
+++ b/storage/perfschema/unittest/pfs_timer-t.cc
@@ -106,11 +106,7 @@ void test_timers()
void do_all_tests()
{
- PFS_atomic::init();
-
test_timers();
-
- PFS_atomic::cleanup();
}
int main(int, char **)
diff --git a/storage/perfschema/unittest/pfs_user-oom-t.cc b/storage/perfschema/unittest/pfs_user-oom-t.cc
index 3cb80e1b7f9..d37d5368ee1 100644
--- a/storage/perfschema/unittest/pfs_user-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_user-oom-t.cc
@@ -99,11 +99,7 @@ void test_oom()
void do_all_tests()
{
- PFS_atomic::init();
-
test_oom();
-
- PFS_atomic::cleanup();
}
int main(int, char **)