Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
slash
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
slash
Commits
6a180e45
Unverified
Commit
6a180e45
authored
Dec 14, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buddy pools: Add check for available allocations
parent
edea7f6b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
buddy.c
src/buddy.c
+3
-0
buddy.h
src/buddy.h
+17
-0
No files found.
src/buddy.c
View file @
6a180e45
...
@@ -2823,6 +2823,8 @@ t_pool_fill(struct buddy_reqs *reqs, const void *priv)
...
@@ -2823,6 +2823,8 @@ t_pool_fill(struct buddy_reqs *reqs, const void *priv)
// defines t_pool_s_get()
// defines t_pool_s_get()
BUDDY_POOL_GET_FUNC
(
t_pool_s
,
static
)
BUDDY_POOL_GET_FUNC
(
t_pool_s
,
static
)
// defines t_pool_s_avail()
BUDDY_POOL_AVAIL_FUNC
(
t_pool_s
,
static
)
/*
/*
* get allocations from a pool and return them
* get allocations from a pool and return them
...
@@ -2847,6 +2849,7 @@ t_pool(void)
...
@@ -2847,6 +2849,7 @@ t_pool(void)
for
(
u
=
0
;
u
<
42
;
u
++
)
{
for
(
u
=
0
;
u
<
42
;
u
++
)
{
reqs
=
t_pool_s_get
(
pool
,
NULL
);
reqs
=
t_pool_s_get
(
pool
,
NULL
);
AN
(
t_pool_s_avail
(
pool
));
alloc
=
buddy_get_next_ptr_page
(
reqs
);
alloc
=
buddy_get_next_ptr_page
(
reqs
);
assert
(
alloc
.
ptr
>
0
);
assert
(
alloc
.
ptr
>
0
);
do
{
do
{
...
...
src/buddy.h
View file @
6a180e45
...
@@ -626,6 +626,23 @@ name ## _get(struct name *poolp, const void *priv) \
...
@@ -626,6 +626,23 @@ name ## _get(struct name *poolp, const void *priv) \
WRONG("Expected second return() to be hit"); \
WRONG("Expected second return() to be hit"); \
}
}
// return available allocations, does not block
#define BUDDY_POOL_AVAIL_FUNC(name, decl) \
decl unsigned \
name ## _avail(struct name *poolp) \
{ \
struct buddy_reqs *reqs; \
unsigned u, avail = 0; \
\
CHECK_OBJ_NOTNULL(poolp, BUDDY_POOL_MAGIC); \
for (u = 0; u < 2; u++) { \
reqs = &((poolp)->reqs[u].reqs); \
CHECK_OBJ_NOTNULL(reqs, BUDDY_REQS_MAGIC); \
avail += buddy_reqs_next_ready(reqs); \
} \
return (avail); \
}
#define BUDDY_POOL_INIT(poolp, b, f, p) do { \
#define BUDDY_POOL_INIT(poolp, b, f, p) do { \
INIT_OBJ(poolp, BUDDY_POOL_MAGIC); \
INIT_OBJ(poolp, BUDDY_POOL_MAGIC); \
poolp->fill = f; \
poolp->fill = f; \
...
...
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