Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
e917ab25
Commit
e917ab25
authored
12 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
mempool: use a mutex instead of a spinlock
Mutexes are now allocation free and thus safe for use within the allocator.
parent
cbec141a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/mempool.cc
+6
-6
6 additions, 6 deletions
core/mempool.cc
include/mempool.hh
+1
-1
1 addition, 1 deletion
include/mempool.hh
with
7 additions
and
7 deletions
core/mempool.cc
+
6
−
6
View file @
e917ab25
...
...
@@ -56,7 +56,7 @@ pool::page_header* pool::to_header(free_object* object)
void
*
pool
::
alloc
()
{
std
::
lock_guard
<
spinlock
>
guard
(
_lock
);
std
::
lock_guard
<
mutex
>
guard
(
_lock
);
if
(
_free
.
empty
())
{
add_page
();
}
...
...
@@ -92,7 +92,7 @@ void pool::add_page()
void
pool
::
free
(
void
*
object
)
{
std
::
lock_guard
<
spinlock
>
guard
(
_lock
);
std
::
lock_guard
<
mutex
>
guard
(
_lock
);
auto
obj
=
static_cast
<
free_object
*>
(
object
);
auto
header
=
to_header
(
obj
);
if
(
!--
header
->
nalloc
)
{
...
...
@@ -146,7 +146,7 @@ struct addr_cmp {
namespace
bi
=
boost
::
intrusive
;
spinlock
free_page_ranges_lock
;
mutex
free_page_ranges_lock
;
bi
::
set
<
page_range
,
bi
::
compare
<
addr_cmp
>
,
bi
::
member_hook
<
page_range
,
...
...
@@ -159,7 +159,7 @@ void* malloc_large(size_t size)
size
=
(
size
+
page_size
-
1
)
&
~
(
page_size
-
1
);
size
+=
page_size
;
std
::
lock_guard
<
spinlock
>
guard
(
free_page_ranges_lock
);
std
::
lock_guard
<
mutex
>
guard
(
free_page_ranges_lock
);
for
(
auto
i
=
free_page_ranges
.
begin
();
i
!=
free_page_ranges
.
end
();
++
i
)
{
auto
header
=
&*
i
;
...
...
@@ -200,7 +200,7 @@ void free_large(void* obj)
obj
-=
page_size
;
auto
header
=
static_cast
<
page_range
*>
(
obj
);
std
::
lock_guard
<
spinlock
>
guard
(
free_page_ranges_lock
);
std
::
lock_guard
<
mutex
>
guard
(
free_page_ranges_lock
);
auto
i
=
free_page_ranges
.
insert
(
*
header
).
first
;
if
(
i
!=
free_page_ranges
.
begin
())
{
...
...
@@ -220,7 +220,7 @@ unsigned large_object_size(void *obj)
void
*
alloc_page
()
{
std
::
lock_guard
<
spinlock
>
guard
(
free_page_ranges_lock
);
std
::
lock_guard
<
mutex
>
guard
(
free_page_ranges_lock
);
assert
(
!
free_page_ranges
.
empty
());
auto
p
=
&*
free_page_ranges
.
begin
();
...
...
This diff is collapsed.
Click to expand it.
include/mempool.hh
+
1
−
1
View file @
e917ab25
...
...
@@ -37,7 +37,7 @@ private:
void
add_page
();
static
page_header
*
to_header
(
free_object
*
object
);
private:
spinlock
_lock
;
mutex
_lock
;
unsigned
_size
;
struct
page_header
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment