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
f87e4b4e
Commit
f87e4b4e
authored
Nov 24, 2020
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.5 into 10.6
parents
c2ea036b
1b12e251
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
22 deletions
+20
-22
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0buf.cc
+4
-12
storage/innobase/include/rw_lock.h
storage/innobase/include/rw_lock.h
+16
-10
No files found.
storage/innobase/buf/buf0buf.cc
View file @
f87e4b4e
...
...
@@ -281,25 +281,17 @@ the read requests for the whole area.
#ifndef UNIV_INNOCHECKSUM
void
page_hash_latch
::
read_lock_wait
()
{
auto
l
=
read_lock_yield
();
/* First, try busy spinning for a while. */
for
(
auto
spin
=
srv_n_spin_wait_rounds
;
spin
--
;
)
{
if
(
l
&
WRITER_PENDING
)
ut_delay
(
srv_spin_wait_delay
);
ut_delay
(
srv_spin_wait_delay
);
if
(
read_trylock
())
return
;
l
=
read_lock_yield
();
}
/* Fall back to yielding to other threads. */
for
(;;)
{
if
(
l
&
WRITER_PENDING
)
os_thread_yield
();
if
(
read_trylock
())
return
;
l
=
read_lock_yield
();
}
do
os_thread_yield
();
while
(
!
read_trylock
());
}
void
page_hash_latch
::
write_lock_wait
()
...
...
storage/innobase/include/rw_lock.h
View file @
f87e4b4e
...
...
@@ -36,17 +36,24 @@ class rw_lock
/** Flag to indicate that write_lock() or write_lock_wait() is pending */
static
constexpr
uint32_t
WRITER_PENDING
=
WRITER
|
WRITER_WAITING
;
/** Yield a read lock request due to a conflict with a write lock.
@return the lock value */
uint32_t
read_lock_yield
()
{
uint32_t
l
=
lock
.
fetch_sub
(
1
,
std
::
memory_order_relaxed
);
DBUG_ASSERT
(
l
&
~
WRITER_PENDING
);
return
l
;
}
/** Start waiting for an exclusive lock. */
void
write_lock_wait_start
()
{
lock
.
fetch_or
(
WRITER_WAITING
,
std
::
memory_order_relaxed
);
}
/** Try to acquire a shared lock.
@param l the value of the lock word
@return whether the lock was acquired */
bool
read_trylock
(
uint32_t
&
l
)
{
l
=
UNLOCKED
;
while
(
!
lock
.
compare_exchange_strong
(
l
,
l
+
1
,
std
::
memory_order_acquire
,
std
::
memory_order_relaxed
))
{
DBUG_ASSERT
(
!
(
WRITER
&
l
)
||
!
(
~
WRITER_PENDING
&
l
));
if
(
l
&
WRITER_PENDING
)
return
false
;
}
return
true
;
}
/** Wait for an exclusive lock.
@return whether the exclusive lock was acquired */
bool
write_lock_poll
()
...
...
@@ -80,8 +87,7 @@ class rw_lock
}
/** Try to acquire a shared lock.
@return whether the lock was acquired */
bool
read_trylock
()
{
return
!
(
lock
.
fetch_add
(
1
,
std
::
memory_order_acquire
)
&
WRITER_PENDING
);
}
bool
read_trylock
()
{
uint32_t
l
;
return
read_trylock
(
l
);
}
/** Try to acquire an exclusive lock.
@return whether the lock was acquired */
bool
write_trylock
()
...
...
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