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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
39a8caa5
Commit
39a8caa5
authored
Jan 07, 2019
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-17441 - InnoDB transition to C++11 atomics
buf_page_t::buf_fix_count transition to Atomic_counter.
parent
c66db377
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
104 deletions
+39
-104
include/my_counter.h
include/my_counter.h
+2
-0
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0buf.cc
+18
-18
storage/innobase/buf/buf0lru.cc
storage/innobase/buf/buf0lru.cc
+1
-1
storage/innobase/include/buf0buf.h
storage/innobase/include/buf0buf.h
+12
-32
storage/innobase/include/buf0buf.ic
storage/innobase/include/buf0buf.ic
+3
-50
storage/innobase/include/mtr0mtr.ic
storage/innobase/include/mtr0mtr.ic
+1
-1
storage/innobase/mtr/mtr0mtr.cc
storage/innobase/mtr/mtr0mtr.cc
+2
-2
No files found.
include/my_counter.h
View file @
39a8caa5
...
@@ -28,6 +28,8 @@ template <typename Type> class Atomic_counter
...
@@ -28,6 +28,8 @@ template <typename Type> class Atomic_counter
Type
sub
(
Type
i
)
{
return
m_counter
.
fetch_sub
(
i
,
std
::
memory_order_relaxed
);
}
Type
sub
(
Type
i
)
{
return
m_counter
.
fetch_sub
(
i
,
std
::
memory_order_relaxed
);
}
public:
public:
Atomic_counter
(
const
Atomic_counter
<
Type
>
&
rhs
)
{
m_counter
.
store
(
rhs
,
std
::
memory_order_relaxed
);
}
Atomic_counter
(
Type
val
)
:
m_counter
(
val
)
{}
Atomic_counter
(
Type
val
)
:
m_counter
(
val
)
{}
Atomic_counter
()
{}
Atomic_counter
()
{}
...
...
storage/innobase/buf/buf0buf.cc
View file @
39a8caa5
...
@@ -3404,7 +3404,7 @@ buf_pool_watch_set(
...
@@ -3404,7 +3404,7 @@ buf_pool_watch_set(
}
}
/* Add to an existing watch. */
/* Add to an existing watch. */
b
uf_block_fix
(
bpage
);
b
page
->
fix
(
);
return
(
NULL
);
return
(
NULL
);
}
}
...
@@ -3544,7 +3544,7 @@ void buf_pool_watch_unset(const page_id_t page_id)
...
@@ -3544,7 +3544,7 @@ void buf_pool_watch_unset(const page_id_t page_id)
increments buf_fix_count. */
increments buf_fix_count. */
bpage
=
buf_page_hash_get_low
(
buf_pool
,
page_id
);
bpage
=
buf_page_hash_get_low
(
buf_pool
,
page_id
);
if
(
b
uf_block_unfix
(
bpage
)
==
0
if
(
b
page
->
unfix
(
)
==
0
&&
buf_pool_watch_is_sentinel
(
buf_pool
,
bpage
))
{
&&
buf_pool_watch_is_sentinel
(
buf_pool
,
bpage
))
{
buf_pool_watch_remove
(
buf_pool
,
bpage
);
buf_pool_watch_remove
(
buf_pool
,
bpage
);
}
}
...
@@ -3777,7 +3777,7 @@ buf_page_get_zip(
...
@@ -3777,7 +3777,7 @@ buf_page_get_zip(
case
BUF_BLOCK_ZIP_PAGE
:
case
BUF_BLOCK_ZIP_PAGE
:
case
BUF_BLOCK_ZIP_DIRTY
:
case
BUF_BLOCK_ZIP_DIRTY
:
b
uf_block_fix
(
bpage
);
b
page
->
fix
(
);
block_mutex
=
&
buf_pool
->
zip_mutex
;
block_mutex
=
&
buf_pool
->
zip_mutex
;
mutex_enter
(
block_mutex
);
mutex_enter
(
block_mutex
);
goto
got_block
;
goto
got_block
;
...
@@ -4296,10 +4296,10 @@ buf_page_get_gen(
...
@@ -4296,10 +4296,10 @@ buf_page_get_gen(
=
buf_page_get_mutex
(
=
buf_page_get_mutex
(
&
fix_block
->
page
);
&
fix_block
->
page
);
mutex_enter
(
fix_mutex
);
mutex_enter
(
fix_mutex
);
buf_block_fix
(
fix_block
);
fix_block
->
fix
(
);
mutex_exit
(
fix_mutex
);
mutex_exit
(
fix_mutex
);
}
else
{
}
else
{
buf_block_fix
(
fix_block
);
fix_block
->
fix
(
);
}
}
/* Now safe to release page_hash mutex */
/* Now safe to release page_hash mutex */
...
@@ -4406,10 +4406,10 @@ buf_page_get_gen(
...
@@ -4406,10 +4406,10 @@ buf_page_get_gen(
BPageMutex
*
fix_mutex
=
buf_page_get_mutex
(
BPageMutex
*
fix_mutex
=
buf_page_get_mutex
(
&
fix_block
->
page
);
&
fix_block
->
page
);
mutex_enter
(
fix_mutex
);
mutex_enter
(
fix_mutex
);
buf_block_fix
(
fix_block
);
fix_block
->
fix
(
);
mutex_exit
(
fix_mutex
);
mutex_exit
(
fix_mutex
);
}
else
{
}
else
{
buf_block_fix
(
fix_block
);
fix_block
->
fix
(
);
}
}
/* Now safe to release page_hash mutex */
/* Now safe to release page_hash mutex */
...
@@ -4432,7 +4432,7 @@ buf_page_get_gen(
...
@@ -4432,7 +4432,7 @@ buf_page_get_gen(
/* The page is being read to buffer pool,
/* The page is being read to buffer pool,
but we cannot wait around for the read to
but we cannot wait around for the read to
complete. */
complete. */
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
return
(
NULL
);
return
(
NULL
);
}
}
...
@@ -4448,7 +4448,7 @@ buf_page_get_gen(
...
@@ -4448,7 +4448,7 @@ buf_page_get_gen(
/* This suggests that the page is being flushed.
/* This suggests that the page is being flushed.
Avoid returning reference to this page.
Avoid returning reference to this page.
Instead wait for the flush action to complete. */
Instead wait for the flush action to complete. */
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
os_thread_sleep
(
WAIT_FOR_WRITE
);
os_thread_sleep
(
WAIT_FOR_WRITE
);
goto
loop
;
goto
loop
;
}
}
...
@@ -4457,7 +4457,7 @@ buf_page_get_gen(
...
@@ -4457,7 +4457,7 @@ buf_page_get_gen(
evict_from_pool:
evict_from_pool:
ut_ad
(
!
fix_block
->
page
.
oldest_modification
);
ut_ad
(
!
fix_block
->
page
.
oldest_modification
);
buf_pool_mutex_enter
(
buf_pool
);
buf_pool_mutex_enter
(
buf_pool
);
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
if
(
!
buf_LRU_free_page
(
&
fix_block
->
page
,
true
))
{
if
(
!
buf_LRU_free_page
(
&
fix_block
->
page
,
true
))
{
ut_ad
(
0
);
ut_ad
(
0
);
...
@@ -4475,7 +4475,7 @@ buf_page_get_gen(
...
@@ -4475,7 +4475,7 @@ buf_page_get_gen(
adaptive hash index. There cannot be an
adaptive hash index. There cannot be an
adaptive hash index for a compressed-only
adaptive hash index for a compressed-only
page, so do not bother decompressing the page. */
page, so do not bother decompressing the page. */
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
return
(
NULL
);
return
(
NULL
);
}
}
...
@@ -4489,7 +4489,7 @@ buf_page_get_gen(
...
@@ -4489,7 +4489,7 @@ buf_page_get_gen(
/* This condition often occurs when the buffer
/* This condition often occurs when the buffer
is not buffer-fixed, but I/O-fixed by
is not buffer-fixed, but I/O-fixed by
buf_page_init_for_read(). */
buf_page_init_for_read(). */
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
/* The block is buffer-fixed or I/O-fixed.
/* The block is buffer-fixed or I/O-fixed.
Try again later. */
Try again later. */
...
@@ -4518,7 +4518,7 @@ buf_page_get_gen(
...
@@ -4518,7 +4518,7 @@ buf_page_get_gen(
/* Buffer-fixing prevents the page_hash from changing. */
/* Buffer-fixing prevents the page_hash from changing. */
ut_ad
(
bpage
==
buf_page_hash_get_low
(
buf_pool
,
page_id
));
ut_ad
(
bpage
==
buf_page_hash_get_low
(
buf_pool
,
page_id
));
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
buf_page_mutex_enter
(
block
);
buf_page_mutex_enter
(
block
);
mutex_enter
(
&
buf_pool
->
zip_mutex
);
mutex_enter
(
&
buf_pool
->
zip_mutex
);
...
@@ -4610,7 +4610,7 @@ buf_page_get_gen(
...
@@ -4610,7 +4610,7 @@ buf_page_get_gen(
buf_page_mutex_exit
(
fix_block
);
buf_page_mutex_exit
(
fix_block
);
--
buf_pool
->
n_pend_unzip
;
--
buf_pool
->
n_pend_unzip
;
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
buf_pool_mutex_exit
(
buf_pool
);
buf_pool_mutex_exit
(
buf_pool
);
rw_lock_x_unlock
(
&
fix_block
->
lock
);
rw_lock_x_unlock
(
&
fix_block
->
lock
);
...
@@ -4673,7 +4673,7 @@ buf_page_get_gen(
...
@@ -4673,7 +4673,7 @@ buf_page_get_gen(
buf_pool_mutex_enter
(
buf_pool
);
buf_pool_mutex_enter
(
buf_pool
);
buf_block_unfix
(
fix_block
);
fix_block
->
unfix
(
);
/* Now we are only holding the buf_pool->mutex,
/* Now we are only holding the buf_pool->mutex,
not block->mutex or hash_lock. Blocks cannot be
not block->mutex or hash_lock. Blocks cannot be
...
@@ -4732,7 +4732,7 @@ buf_page_get_gen(
...
@@ -4732,7 +4732,7 @@ buf_page_get_gen(
buf_page_mutex_exit
(
fix_block
);
buf_page_mutex_exit
(
fix_block
);
buf_block_fix
(
fix_block
);
fix_block
->
fix
(
);
/* Failed to evict the page; change it directly */
/* Failed to evict the page; change it directly */
...
@@ -5233,7 +5233,7 @@ buf_page_init(
...
@@ -5233,7 +5233,7 @@ buf_page_init(
ut_a
(
buf_fix_count
>
0
);
ut_a
(
buf_fix_count
>
0
);
my_atomic_add32
((
int32
*
)
&
block
->
page
.
buf_fix_count
,
buf_fix_count
)
;
block
->
page
.
buf_fix_count
+=
buf_fix_count
;
buf_pool_watch_remove
(
buf_pool
,
hash_page
);
buf_pool_watch_remove
(
buf_pool
,
hash_page
);
}
else
{
}
else
{
...
@@ -5474,7 +5474,7 @@ buf_page_init_for_read(
...
@@ -5474,7 +5474,7 @@ buf_page_init_for_read(
ut_a
(
buf_fix_count
>
0
);
ut_a
(
buf_fix_count
>
0
);
my_atomic_add32
((
int32
*
)
&
bpage
->
buf_fix_count
,
buf_fix_count
)
;
bpage
->
buf_fix_count
+=
buf_fix_count
;
ut_ad
(
buf_pool_watch_is_sentinel
(
buf_pool
,
watch_page
));
ut_ad
(
buf_pool_watch_is_sentinel
(
buf_pool
,
watch_page
));
buf_pool_watch_remove
(
buf_pool
,
watch_page
);
buf_pool_watch_remove
(
buf_pool
,
watch_page
);
...
...
storage/innobase/buf/buf0lru.cc
View file @
39a8caa5
...
@@ -2459,7 +2459,7 @@ buf_LRU_print_instance(
...
@@ -2459,7 +2459,7 @@ buf_LRU_print_instance(
if
(
bpage
->
buf_fix_count
)
{
if
(
bpage
->
buf_fix_count
)
{
fprintf
(
stderr
,
"buffix count %u "
,
fprintf
(
stderr
,
"buffix count %u "
,
bpage
->
buf_fix_count
);
uint32_t
(
bpage
->
buf_fix_count
)
);
}
}
if
(
buf_page_get_io_fix
(
bpage
))
{
if
(
buf_page_get_io_fix
(
bpage
))
{
...
...
storage/innobase/include/buf0buf.h
View file @
39a8caa5
...
@@ -665,37 +665,6 @@ buf_block_buf_fix_inc_func(
...
@@ -665,37 +665,6 @@ buf_block_buf_fix_inc_func(
buf_block_t
*
block
)
/*!< in/out: block to bufferfix */
buf_block_t
*
block
)
/*!< in/out: block to bufferfix */
MY_ATTRIBUTE
((
nonnull
));
MY_ATTRIBUTE
((
nonnull
));
/** Increments the bufferfix count.
@param[in,out] bpage block to bufferfix
@return the count */
UNIV_INLINE
ulint
buf_block_fix
(
buf_page_t
*
bpage
);
/** Increments the bufferfix count.
@param[in,out] block block to bufferfix
@return the count */
UNIV_INLINE
ulint
buf_block_fix
(
buf_block_t
*
block
);
/** Decrements the bufferfix count.
@param[in,out] bpage block to bufferunfix
@return the remaining buffer-fix count */
UNIV_INLINE
ulint
buf_block_unfix
(
buf_page_t
*
bpage
);
/** Decrements the bufferfix count.
@param[in,out] block block to bufferunfix
@return the remaining buffer-fix count */
UNIV_INLINE
ulint
buf_block_unfix
(
buf_block_t
*
block
);
# ifdef UNIV_DEBUG
# ifdef UNIV_DEBUG
/** Increments the bufferfix count.
/** Increments the bufferfix count.
@param[in,out] b block to bufferfix
@param[in,out] b block to bufferfix
...
@@ -1490,7 +1459,7 @@ class buf_page_t {
...
@@ -1490,7 +1459,7 @@ class buf_page_t {
page_size_t
size
;
page_size_t
size
;
/** Count of how manyfold this block is currently bufferfixed. */
/** Count of how manyfold this block is currently bufferfixed. */
ib_uint32_t
buf_fix_count
;
Atomic_counter
<
uint32_t
>
buf_fix_count
;
/** type of pending I/O operation; also protected by
/** type of pending I/O operation; also protected by
buf_pool->mutex for writes only */
buf_pool->mutex for writes only */
...
@@ -1645,6 +1614,14 @@ class buf_page_t {
...
@@ -1645,6 +1614,14 @@ class buf_page_t {
protected by buf_pool->zip_mutex
protected by buf_pool->zip_mutex
or buf_block_t::mutex. */
or buf_block_t::mutex. */
# endif
/* UNIV_DEBUG */
# endif
/* UNIV_DEBUG */
void
fix
()
{
buf_fix_count
++
;
}
uint32_t
unfix
()
{
uint32_t
count
=
buf_fix_count
--
;
ut_ad
(
count
!=
0
);
return
count
-
1
;
}
};
};
/** The buffer control block structure */
/** The buffer control block structure */
...
@@ -1808,6 +1785,9 @@ struct buf_block_t{
...
@@ -1808,6 +1785,9 @@ struct buf_block_t{
and accessed; we introduce this new
and accessed; we introduce this new
mutex in InnoDB-5.1 to relieve
mutex in InnoDB-5.1 to relieve
contention on the buffer pool mutex */
contention on the buffer pool mutex */
void
fix
()
{
page
.
fix
();
}
uint32_t
unfix
()
{
return
page
.
unfix
();
}
};
};
/** Check if a buf_block_t object is in a valid state
/** Check if a buf_block_t object is in a valid state
...
...
storage/innobase/include/buf0buf.ic
View file @
39a8caa5
...
@@ -945,28 +945,6 @@ buf_block_get_modify_clock(
...
@@ -945,28 +945,6 @@ buf_block_get_modify_clock(
return(block->modify_clock);
return(block->modify_clock);
}
}
/** Increments the bufferfix count.
@param[in,out] bpage block to bufferfix
@return the count */
UNIV_INLINE
ulint
buf_block_fix(
buf_page_t* bpage)
{
return uint32(my_atomic_add32((int32*) &bpage->buf_fix_count, 1) + 1);
}
/** Increments the bufferfix count.
@param[in,out] block block to bufferfix
@return the count */
UNIV_INLINE
ulint
buf_block_fix(
buf_block_t* block)
{
return(buf_block_fix(&block->page));
}
/*******************************************************************//**
/*******************************************************************//**
Increments the bufferfix count. */
Increments the bufferfix count. */
UNIV_INLINE
UNIV_INLINE
...
@@ -990,32 +968,7 @@ buf_block_buf_fix_inc_func(
...
@@ -990,32 +968,7 @@ buf_block_buf_fix_inc_func(
}
}
#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG */
buf_block_fix(block);
block->fix();
}
/** Decrements the bufferfix count.
@param[in,out] bpage block to bufferunfix
@return the remaining buffer-fix count */
UNIV_INLINE
ulint
buf_block_unfix(
buf_page_t* bpage)
{
uint32 count = uint32(my_atomic_add32((int32*) &bpage->buf_fix_count,
-1));
ut_ad(count != 0);
return count - 1;
}
/** Decrements the bufferfix count.
@param[in,out] block block to bufferunfix
@return the remaining buffer-fix count */
UNIV_INLINE
ulint
buf_block_unfix(
buf_block_t* block)
{
return(buf_block_unfix(&block->page));
}
}
/*******************************************************************//**
/*******************************************************************//**
...
@@ -1026,7 +979,7 @@ buf_block_buf_fix_dec(
...
@@ -1026,7 +979,7 @@ buf_block_buf_fix_dec(
/*==================*/
/*==================*/
buf_block_t* block) /*!< in/out: block to bufferunfix */
buf_block_t* block) /*!< in/out: block to bufferunfix */
{
{
b
uf_block_unfix(block
);
b
lock->unfix(
);
#ifdef UNIV_DEBUG
#ifdef UNIV_DEBUG
/* No debug latch is acquired if block belongs to system temporary.
/* No debug latch is acquired if block belongs to system temporary.
...
@@ -1283,7 +1236,7 @@ buf_page_release_zip(
...
@@ -1283,7 +1236,7 @@ buf_page_release_zip(
/* Fall through */
/* Fall through */
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY:
case BUF_BLOCK_ZIP_DIRTY:
buf_block_unfix(reinterpret_cast<buf_block_t*>(bpage)
);
reinterpret_cast<buf_block_t*>(bpage)->unfix(
);
return;
return;
case BUF_BLOCK_POOL_WATCH:
case BUF_BLOCK_POOL_WATCH:
...
...
storage/innobase/include/mtr0mtr.ic
View file @
39a8caa5
...
@@ -170,7 +170,7 @@ mtr_t::release_block_at_savepoint(
...
@@ -170,7 +170,7 @@ mtr_t::release_block_at_savepoint(
ut_a(slot->object == block);
ut_a(slot->object == block);
buf_block_unfix(reinterpret_cast<buf_block_t*>(block)
);
reinterpret_cast<buf_block_t*>(block)->unfix(
);
buf_page_release_latch(block, slot->type);
buf_page_release_latch(block, slot->type);
...
...
storage/innobase/mtr/mtr0mtr.cc
View file @
39a8caa5
...
@@ -191,7 +191,7 @@ memo_slot_release(mtr_memo_slot_t* slot)
...
@@ -191,7 +191,7 @@ memo_slot_release(mtr_memo_slot_t* slot)
block
=
reinterpret_cast
<
buf_block_t
*>
(
slot
->
object
);
block
=
reinterpret_cast
<
buf_block_t
*>
(
slot
->
object
);
b
uf_block_unfix
(
block
);
b
lock
->
unfix
(
);
buf_page_release_latch
(
block
,
slot
->
type
);
buf_page_release_latch
(
block
,
slot
->
type
);
break
;
break
;
}
}
...
@@ -228,7 +228,7 @@ memo_block_unfix(mtr_memo_slot_t* slot)
...
@@ -228,7 +228,7 @@ memo_block_unfix(mtr_memo_slot_t* slot)
case
MTR_MEMO_PAGE_S_FIX
:
case
MTR_MEMO_PAGE_S_FIX
:
case
MTR_MEMO_PAGE_X_FIX
:
case
MTR_MEMO_PAGE_X_FIX
:
case
MTR_MEMO_PAGE_SX_FIX
:
{
case
MTR_MEMO_PAGE_SX_FIX
:
{
buf_block_unfix
(
reinterpret_cast
<
buf_block_t
*>
(
slot
->
object
)
);
reinterpret_cast
<
buf_block_t
*>
(
slot
->
object
)
->
unfix
(
);
break
;
break
;
}
}
...
...
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