Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
d5d6e3d6
Commit
d5d6e3d6
authored
Aug 24, 2021
by
Antoine Kaufmann
Browse files
dist/common: batch polling for cleanup entries
parent
99ec2047
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
16 deletions
+22
-16
dist/common/net.c
dist/common/net.c
+22
-16
No files found.
dist/common/net.c
View file @
d5d6e3d6
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
static
const
uint64_t
kPollReportThreshold
=
128
;
static
const
uint64_t
kPollReportThreshold
=
128
;
static
const
uint64_t
kCleanReportThreshold
=
128
;
static
const
uint64_t
kCleanReportThreshold
=
128
;
static
const
uint64_t
kPollMax
=
8
;
static
const
uint64_t
kPollMax
=
8
;
static
const
uint64_t
kCleanupMax
=
16
;
static
size_t
shm_size
;
static
size_t
shm_size
;
void
*
shm_base
;
void
*
shm_base
;
...
@@ -400,33 +401,38 @@ static inline void PollPeerTransfer(struct Peer *peer, bool *report) {
...
@@ -400,33 +401,38 @@ static inline void PollPeerTransfer(struct Peer *peer, bool *report) {
}
}
static
inline
void
PollPeerCleanup
(
struct
Peer
*
peer
,
bool
*
report
)
{
static
inline
void
PollPeerCleanup
(
struct
Peer
*
peer
,
bool
*
report
)
{
// XXX: could also be batched
if
(
peer
->
cleanup_pos_next
==
peer
->
cleanup_pos_last
)
if
(
peer
->
cleanup_pos_next
==
peer
->
cleanup_pos_last
)
return
;
return
;
void
*
entry
=
bool
ready
;
(
peer
->
cleanup_base
+
peer
->
cleanup_pos_next
*
peer
->
cleanup_elen
);
uint64_t
cnt
=
0
;
bool
ready
;
do
{
if
(
peer
->
is_dev
)
{
void
*
entry
=
struct
SimbricksProtoNetN2DDummy
*
n2d
=
entry
;
(
peer
->
cleanup_base
+
peer
->
cleanup_pos_next
*
peer
->
cleanup_elen
);
ready
=
(
n2d
->
own_type
&
SIMBRICKS_PROTO_NET_N2D_OWN_MASK
)
==
if
(
peer
->
is_dev
)
{
SIMBRICKS_PROTO_NET_N2D_OWN_NET
;
struct
SimbricksProtoNetN2DDummy
*
n2d
=
entry
;
}
else
{
ready
=
(
n2d
->
own_type
&
SIMBRICKS_PROTO_NET_N2D_OWN_MASK
)
==
struct
SimbricksProtoNetD2NDummy
*
d2n
=
entry
;
SIMBRICKS_PROTO_NET_N2D_OWN_NET
;
ready
=
(
d2n
->
own_type
&
SIMBRICKS_PROTO_NET_D2N_OWN_MASK
)
==
}
else
{
SIMBRICKS_PROTO_NET_D2N_OWN_DEV
;
struct
SimbricksProtoNetD2NDummy
*
d2n
=
entry
;
}
ready
=
(
d2n
->
own_type
&
SIMBRICKS_PROTO_NET_D2N_OWN_MASK
)
==
SIMBRICKS_PROTO_NET_D2N_OWN_DEV
;
}
if
(
ready
)
{
if
(
!
ready
)
#ifdef DEBUG
break
;
#ifdef DEBUG
fprintf
(
stderr
,
"PollPeerCleanup: peer %s has clean entry at %u
\n
"
,
fprintf
(
stderr
,
"PollPeerCleanup: peer %s has clean entry at %u
\n
"
,
peer
->
sock_path
,
peer
->
cleanup_pos_next
);
peer
->
sock_path
,
peer
->
cleanup_pos_next
);
#endif
#endif
peer
->
cleanup_pos_next
+=
1
;
peer
->
cleanup_pos_next
+=
1
;
if
(
peer
->
cleanup_pos_next
>=
peer
->
cleanup_enum
)
if
(
peer
->
cleanup_pos_next
>=
peer
->
cleanup_enum
)
peer
->
cleanup_pos_next
-=
peer
->
cleanup_enum
;
peer
->
cleanup_pos_next
-=
peer
->
cleanup_enum
;
}
while
(
++
cnt
<=
kCleanupMax
&&
peer
->
cleanup_pos_next
!=
peer
->
cleanup_pos_last
);
if
(
cnt
>
0
)
{
uint64_t
unreported
=
(
peer
->
cleanup_pos_next
-
peer
->
cleanup_pos_reported
)
uint64_t
unreported
=
(
peer
->
cleanup_pos_next
-
peer
->
cleanup_pos_reported
)
%
peer
->
cleanup_enum
;
%
peer
->
cleanup_enum
;
if
(
unreported
>=
kCleanReportThreshold
)
if
(
unreported
>=
kCleanReportThreshold
)
...
...
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