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
c5856b0a
Commit
c5856b0a
authored
Feb 08, 2020
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-21351: Allocate aligned memory
recv_sys_t::ALIGNMENT: The recv_sys_t::alloc() alignment
parent
6eed99f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
storage/innobase/include/log0recv.h
storage/innobase/include/log0recv.h
+3
-0
storage/innobase/log/log0recv.cc
storage/innobase/log/log0recv.cc
+8
-4
No files found.
storage/innobase/include/log0recv.h
View file @
c5856b0a
...
...
@@ -365,6 +365,9 @@ struct recv_sys_t{
return
true
;
}
/** The alloc() memory alignment, in bytes */
static
constexpr
size_t
ALIGNMENT
=
sizeof
(
size_t
);
/** Get the memory block for storing recv_t and redo log data
@param[in] len length of the data to be stored
@param[in] store_recv whether to store recv_t object
...
...
storage/innobase/log/log0recv.cc
View file @
c5856b0a
...
...
@@ -892,14 +892,17 @@ inline byte* recv_sys_t::alloc(size_t len, bool store_recv)
{
create_block:
block
=
buf_block_alloc
(
nullptr
);
block
->
page
.
access_time
=
1U
<<
16
|
static_cast
<
uint16_t
>
(
len
);
block
->
page
.
access_time
=
1U
<<
16
|
ut_calc_align
<
uint16_t
>
(
static_cast
<
uint16_t
>
(
len
),
ALIGNMENT
);
static_assert
(
ut_is_2pow
(
ALIGNMENT
),
"ALIGNMENT must be a power of 2"
);
UT_LIST_ADD_FIRST
(
blocks
,
block
);
UNIV_MEM_INVALID
(
block
->
frame
,
len
);
UNIV_MEM_FREE
(
block
->
frame
+
len
,
srv_page_size
-
len
);
return
block
->
frame
;
return
my_assume_aligned
<
ALIGNMENT
>
(
block
->
frame
)
;
}
size_t
free_offset
=
static_cast
<
uint16_t
>
(
block
->
page
.
access_time
);
ut_ad
(
!
ut_2pow_remainder
(
free_offset
,
ALIGNMENT
));
if
(
UNIV_UNLIKELY
(
!
free_offset
))
{
ut_ad
(
srv_page_size
==
65536
);
...
...
@@ -915,9 +918,9 @@ inline byte* recv_sys_t::alloc(size_t len, bool store_recv)
goto
create_block
;
block
->
page
.
access_time
=
((
block
->
page
.
access_time
>>
16
)
+
1
)
<<
16
|
static_cast
<
uint16_t
>
(
free_offset
);
ut_calc_align
<
uint16_t
>
(
static_cast
<
uint16_t
>
(
free_offset
),
ALIGNMENT
);
UNIV_MEM_ALLOC
(
block
->
frame
+
free_offset
-
len
,
len
);
return
block
->
frame
+
free_offset
-
len
;
return
my_assume_aligned
<
ALIGNMENT
>
(
block
->
frame
+
free_offset
-
len
)
;
}
...
...
@@ -925,6 +928,7 @@ inline byte* recv_sys_t::alloc(size_t len, bool store_recv)
@param data buffer returned by alloc() */
inline
void
recv_sys_t
::
free
(
const
void
*
data
)
{
ut_ad
(
!
ut_align_offset
(
data
,
ALIGNMENT
));
data
=
page_align
(
data
);
ut_ad
(
mutex_own
(
&
mutex
));
for
(
buf_block_t
*
block
=
UT_LIST_GET_LAST
(
blocks
);
...
...
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