Commit d5d6e3d6 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

dist/common: batch polling for cleanup entries

parent 99ec2047
...@@ -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,14 +401,14 @@ static inline void PollPeerTransfer(struct Peer *peer, bool *report) { ...@@ -400,14 +401,14 @@ 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;
bool ready;
uint64_t cnt = 0;
do {
void *entry = void *entry =
(peer->cleanup_base + peer->cleanup_pos_next * peer->cleanup_elen); (peer->cleanup_base + peer->cleanup_pos_next * peer->cleanup_elen);
bool ready;
if (peer->is_dev) { if (peer->is_dev) {
struct SimbricksProtoNetN2DDummy *n2d = entry; struct SimbricksProtoNetN2DDummy *n2d = entry;
ready = (n2d->own_type & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) == ready = (n2d->own_type & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) ==
...@@ -418,15 +419,20 @@ static inline void PollPeerCleanup(struct Peer *peer, bool *report) { ...@@ -418,15 +419,20 @@ static inline void PollPeerCleanup(struct Peer *peer, bool *report) {
SIMBRICKS_PROTO_NET_D2N_OWN_DEV; 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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment