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,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)
......
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