Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
faf169d2
Commit
faf169d2
authored
Dec 02, 2014
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6906 - Relaxed memory order for counters
Let some atomic counters use relaxed memory order.
parent
732d2daf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/mysqld.h
sql/mysqld.h
+6
-6
sql/table_cache.cc
sql/table_cache.cc
+7
-6
No files found.
sql/mysqld.cc
View file @
faf169d2
...
...
@@ -3982,7 +3982,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
}
// workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1)
int64
volatile
*
volatile
ptr
=&
global_status_var
.
memory_used
;
my_atomic_add64
(
ptr
,
size
);
my_atomic_add64
_explicit
(
ptr
,
size
,
MY_MEMORY_ORDER_RELAXED
);
}
}
...
...
sql/mysqld.h
View file @
faf169d2
...
...
@@ -633,7 +633,7 @@ inline __attribute__((warn_unused_result)) query_id_t next_query_id()
{
query_id_t
id
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
id
=
my_atomic_add64
(
&
global_query_id
,
1
);
id
=
my_atomic_add64
_explicit
(
&
global_query_id
,
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
return
(
id
);
}
...
...
@@ -642,7 +642,7 @@ inline query_id_t get_query_id()
{
query_id_t
id
;
my_atomic_rwlock_wrlock
(
&
global_query_id_lock
);
id
=
my_atomic_load64
(
&
global_query_id
);
id
=
my_atomic_load64
_explicit
(
&
global_query_id
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
&
global_query_id_lock
);
return
id
;
}
...
...
@@ -668,28 +668,28 @@ inline void table_case_convert(char * name, uint length)
inline
void
thread_safe_increment32
(
int32
*
value
,
my_atomic_rwlock_t
*
lock
)
{
my_atomic_rwlock_wrlock
(
lock
);
(
void
)
my_atomic_add32
(
value
,
1
);
(
void
)
my_atomic_add32
_explicit
(
value
,
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
lock
);
}
inline
void
thread_safe_decrement32
(
int32
*
value
,
my_atomic_rwlock_t
*
lock
)
{
my_atomic_rwlock_wrlock
(
lock
);
(
void
)
my_atomic_add32
(
value
,
-
1
);
(
void
)
my_atomic_add32
_explicit
(
value
,
-
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
lock
);
}
inline
void
thread_safe_increment64
(
int64
*
value
,
my_atomic_rwlock_t
*
lock
)
{
my_atomic_rwlock_wrlock
(
lock
);
(
void
)
my_atomic_add64
(
value
,
1
);
(
void
)
my_atomic_add64
_explicit
(
value
,
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
lock
);
}
inline
void
thread_safe_decrement64
(
int64
*
value
,
my_atomic_rwlock_t
*
lock
)
{
my_atomic_rwlock_wrlock
(
lock
);
(
void
)
my_atomic_add64
(
value
,
-
1
);
(
void
)
my_atomic_add64
_explicit
(
value
,
-
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
lock
);
}
...
...
sql/table_cache.cc
View file @
faf169d2
...
...
@@ -139,7 +139,7 @@ uint tc_records(void)
{
uint
count
;
my_atomic_rwlock_rdlock
(
&
LOCK_tdc_atomics
);
count
=
my_atomic_load32
(
&
tc_count
);
count
=
my_atomic_load32
_explicit
(
&
tc_count
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_rdunlock
(
&
LOCK_tdc_atomics
);
return
count
;
}
...
...
@@ -155,7 +155,7 @@ uint tc_records(void)
static
void
tc_remove_table
(
TABLE
*
table
)
{
my_atomic_rwlock_wrlock
(
&
LOCK_tdc_atomics
);
my_atomic_add32
(
&
tc_count
,
-
1
);
my_atomic_add32
_explicit
(
&
tc_count
,
-
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
&
LOCK_tdc_atomics
);
table
->
s
->
tdc
.
all_tables
.
remove
(
table
);
}
...
...
@@ -259,7 +259,8 @@ void tc_add_table(THD *thd, TABLE *table)
/* If we have too many TABLE instances around, try to get rid of them */
my_atomic_rwlock_wrlock
(
&
LOCK_tdc_atomics
);
need_purge
=
my_atomic_add32
(
&
tc_count
,
1
)
>=
(
int32
)
tc_size
;
need_purge
=
my_atomic_add32_explicit
(
&
tc_count
,
1
,
MY_MEMORY_ORDER_RELAXED
)
>=
(
int32
)
tc_size
;
my_atomic_rwlock_wrunlock
(
&
LOCK_tdc_atomics
);
if
(
need_purge
)
...
...
@@ -1101,7 +1102,7 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
ulong
tdc_refresh_version
(
void
)
{
my_atomic_rwlock_rdlock
(
&
LOCK_tdc_atomics
);
ulong
v
=
my_atomic_load64
(
&
tdc_version
);
ulong
v
=
my_atomic_load64
_explicit
(
&
tdc_version
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_rdunlock
(
&
LOCK_tdc_atomics
);
return
v
;
}
...
...
@@ -1110,7 +1111,7 @@ ulong tdc_refresh_version(void)
ulong
tdc_increment_refresh_version
(
void
)
{
my_atomic_rwlock_wrlock
(
&
LOCK_tdc_atomics
);
ulong
v
=
my_atomic_add64
(
&
tdc_version
,
1
);
ulong
v
=
my_atomic_add64
_explicit
(
&
tdc_version
,
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
&
LOCK_tdc_atomics
);
DBUG_PRINT
(
"tcache"
,
(
"incremented global refresh_version to: %lu"
,
v
));
return
v
+
1
;
...
...
@@ -1210,7 +1211,7 @@ void tdc_assign_new_table_id(TABLE_SHARE *share)
do
{
my_atomic_rwlock_wrlock
(
&
LOCK_tdc_atomics
);
tid
=
my_atomic_add64
(
&
last_table_id
,
1
);
tid
=
my_atomic_add64
_explicit
(
&
last_table_id
,
1
,
MY_MEMORY_ORDER_RELAXED
);
my_atomic_rwlock_wrunlock
(
&
LOCK_tdc_atomics
);
}
while
(
unlikely
(
tid
==
~
0UL
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment