Loading tools/virtio/ringtest/main.c +12 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,12 @@ void set_affinity(const char *arg) assert(!ret); } void poll_used(void) { while (used_empty()) busy_wait(); } static void __attribute__((__flatten__)) run_guest(void) { int completed_before; Loading Loading @@ -149,6 +155,12 @@ static void __attribute__((__flatten__)) run_guest(void) } } void poll_avail(void) { while (avail_empty()) busy_wait(); } static void __attribute__((__flatten__)) run_host(void) { int completed_before; Loading tools/virtio/ringtest/main.h +2 −2 Original line number Diff line number Diff line Loading @@ -56,15 +56,15 @@ void alloc_ring(void); int add_inbuf(unsigned, void *, void *); void *get_buf(unsigned *, void **); void disable_call(); bool used_empty(); bool enable_call(); void kick_available(); void poll_used(); /* host side */ void disable_kick(); bool avail_empty(); bool enable_kick(); bool use_buf(unsigned *, void **); void call_used(); void poll_avail(); /* implemented by main */ extern bool do_sleep; Loading tools/virtio/ringtest/noring.c +4 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,9 @@ void *get_buf(unsigned *lenp, void **bufp) return "Buffer"; } void poll_used(void) bool used_empty() { return false; } void disable_call() Loading Loading @@ -54,8 +55,9 @@ bool enable_kick() assert(0); } void poll_avail(void) bool avail_empty() { return false; } bool use_buf(unsigned *lenp, void **bufp) Loading tools/virtio/ringtest/ptr_ring.c +4 −18 Original line number Diff line number Diff line Loading @@ -133,18 +133,9 @@ void *get_buf(unsigned *lenp, void **bufp) return datap; } void poll_used(void) bool used_empty() { void *b; do { if (tailcnt == headcnt || __ptr_ring_full(&array)) { b = NULL; barrier(); } else { b = "Buffer\n"; } } while (!b); return (tailcnt == headcnt || __ptr_ring_full(&array)); } void disable_call() Loading Loading @@ -173,14 +164,9 @@ bool enable_kick() assert(0); } void poll_avail(void) bool avail_empty() { void *b; do { barrier(); b = __ptr_ring_peek(&array); } while (!b); return !__ptr_ring_peek(&array); } bool use_buf(unsigned *lenp, void **bufp) Loading tools/virtio/ringtest/ring.c +6 −12 Original line number Diff line number Diff line Loading @@ -163,12 +163,11 @@ void *get_buf(unsigned *lenp, void **bufp) return datap; } void poll_used(void) bool used_empty() { unsigned head = (ring_size - 1) & guest.last_used_idx; while (ring[head].flags & DESC_HW) busy_wait(); return (ring[head].flags & DESC_HW); } void disable_call() Loading @@ -180,13 +179,11 @@ void disable_call() bool enable_call() { unsigned head = (ring_size - 1) & guest.last_used_idx; event->call_index = guest.last_used_idx; /* Flush call index write */ /* Barrier D (for pairing) */ smp_mb(); return ring[head].flags & DESC_HW; return used_empty(); } void kick_available(void) Loading @@ -213,20 +210,17 @@ void disable_kick() bool enable_kick() { unsigned head = (ring_size - 1) & host.used_idx; event->kick_index = host.used_idx; /* Barrier C (for pairing) */ smp_mb(); return !(ring[head].flags & DESC_HW); return avail_empty(); } void poll_avail(void) bool avail_empty() { unsigned head = (ring_size - 1) & host.used_idx; while (!(ring[head].flags & DESC_HW)) busy_wait(); return !(ring[head].flags & DESC_HW); } bool use_buf(unsigned *lenp, void **bufp) Loading Loading
tools/virtio/ringtest/main.c +12 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,12 @@ void set_affinity(const char *arg) assert(!ret); } void poll_used(void) { while (used_empty()) busy_wait(); } static void __attribute__((__flatten__)) run_guest(void) { int completed_before; Loading Loading @@ -149,6 +155,12 @@ static void __attribute__((__flatten__)) run_guest(void) } } void poll_avail(void) { while (avail_empty()) busy_wait(); } static void __attribute__((__flatten__)) run_host(void) { int completed_before; Loading
tools/virtio/ringtest/main.h +2 −2 Original line number Diff line number Diff line Loading @@ -56,15 +56,15 @@ void alloc_ring(void); int add_inbuf(unsigned, void *, void *); void *get_buf(unsigned *, void **); void disable_call(); bool used_empty(); bool enable_call(); void kick_available(); void poll_used(); /* host side */ void disable_kick(); bool avail_empty(); bool enable_kick(); bool use_buf(unsigned *, void **); void call_used(); void poll_avail(); /* implemented by main */ extern bool do_sleep; Loading
tools/virtio/ringtest/noring.c +4 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,9 @@ void *get_buf(unsigned *lenp, void **bufp) return "Buffer"; } void poll_used(void) bool used_empty() { return false; } void disable_call() Loading Loading @@ -54,8 +55,9 @@ bool enable_kick() assert(0); } void poll_avail(void) bool avail_empty() { return false; } bool use_buf(unsigned *lenp, void **bufp) Loading
tools/virtio/ringtest/ptr_ring.c +4 −18 Original line number Diff line number Diff line Loading @@ -133,18 +133,9 @@ void *get_buf(unsigned *lenp, void **bufp) return datap; } void poll_used(void) bool used_empty() { void *b; do { if (tailcnt == headcnt || __ptr_ring_full(&array)) { b = NULL; barrier(); } else { b = "Buffer\n"; } } while (!b); return (tailcnt == headcnt || __ptr_ring_full(&array)); } void disable_call() Loading Loading @@ -173,14 +164,9 @@ bool enable_kick() assert(0); } void poll_avail(void) bool avail_empty() { void *b; do { barrier(); b = __ptr_ring_peek(&array); } while (!b); return !__ptr_ring_peek(&array); } bool use_buf(unsigned *lenp, void **bufp) Loading
tools/virtio/ringtest/ring.c +6 −12 Original line number Diff line number Diff line Loading @@ -163,12 +163,11 @@ void *get_buf(unsigned *lenp, void **bufp) return datap; } void poll_used(void) bool used_empty() { unsigned head = (ring_size - 1) & guest.last_used_idx; while (ring[head].flags & DESC_HW) busy_wait(); return (ring[head].flags & DESC_HW); } void disable_call() Loading @@ -180,13 +179,11 @@ void disable_call() bool enable_call() { unsigned head = (ring_size - 1) & guest.last_used_idx; event->call_index = guest.last_used_idx; /* Flush call index write */ /* Barrier D (for pairing) */ smp_mb(); return ring[head].flags & DESC_HW; return used_empty(); } void kick_available(void) Loading @@ -213,20 +210,17 @@ void disable_kick() bool enable_kick() { unsigned head = (ring_size - 1) & host.used_idx; event->kick_index = host.used_idx; /* Barrier C (for pairing) */ smp_mb(); return !(ring[head].flags & DESC_HW); return avail_empty(); } void poll_avail(void) bool avail_empty() { unsigned head = (ring_size - 1) & host.used_idx; while (!(ring[head].flags & DESC_HW)) busy_wait(); return !(ring[head].flags & DESC_HW); } bool use_buf(unsigned *lenp, void **bufp) Loading