Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78ae255f authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio docs and tests from Michael Tsirkin:
 "This merely has some documentation and a new test, seems safe to
  merge"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  tools/virtio: add noring tool
  tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu
  tools/virtio/ringtest: add usage example to README
  MAINTAINERS: Add file patterns for virtio device tree bindings
parents 90effdcd 139ab4d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -12148,6 +12148,7 @@ VIRTIO CORE, NET AND BLOCK DRIVERS
M:	"Michael S. Tsirkin" <mst@redhat.com>
M:	"Michael S. Tsirkin" <mst@redhat.com>
L:	virtualization@lists.linux-foundation.org
L:	virtualization@lists.linux-foundation.org
S:	Maintained
S:	Maintained
F:	Documentation/devicetree/bindings/virtio/
F:	drivers/virtio/
F:	drivers/virtio/
F:	tools/virtio/
F:	tools/virtio/
F:	drivers/net/virtio_net.c
F:	drivers/net/virtio_net.c
+3 −1
Original line number Original line Diff line number Diff line
all:
all:


all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder
all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder noring


CFLAGS += -Wall
CFLAGS += -Wall
CFLAGS += -pthread -O2 -ggdb
CFLAGS += -pthread -O2 -ggdb
@@ -15,11 +15,13 @@ ring: ring.o main.o
virtio_ring_0_9: virtio_ring_0_9.o main.o
virtio_ring_0_9: virtio_ring_0_9.o main.o
virtio_ring_poll: virtio_ring_poll.o main.o
virtio_ring_poll: virtio_ring_poll.o main.o
virtio_ring_inorder: virtio_ring_inorder.o main.o
virtio_ring_inorder: virtio_ring_inorder.o main.o
noring: noring.o main.o
clean:
clean:
	-rm main.o
	-rm main.o
	-rm ring.o ring
	-rm ring.o ring
	-rm virtio_ring_0_9.o virtio_ring_0_9
	-rm virtio_ring_0_9.o virtio_ring_0_9
	-rm virtio_ring_poll.o virtio_ring_poll
	-rm virtio_ring_poll.o virtio_ring_poll
	-rm virtio_ring_inorder.o virtio_ring_inorder
	-rm virtio_ring_inorder.o virtio_ring_inorder
	-rm noring.o noring


.PHONY: all clean
.PHONY: all clean
+4 −0
Original line number Original line Diff line number Diff line
Partial implementation of various ring layouts, useful to tune virtio design.
Partial implementation of various ring layouts, useful to tune virtio design.
Uses shared memory heavily.
Uses shared memory heavily.

Typical use:

# sh run-on-all.sh perf stat -r 10 --log-fd 1 -- ./ring
+69 −0
Original line number Original line Diff line number Diff line
#define _GNU_SOURCE
#include "main.h"
#include <assert.h>

/* stub implementation: useful for measuring overhead */
void alloc_ring(void)
{
}

/* guest side */
int add_inbuf(unsigned len, void *buf, void *datap)
{
	return 0;
}

/*
 * skb_array API provides no way for producer to find out whether a given
 * buffer was consumed.  Our tests merely require that a successful get_buf
 * implies that add_inbuf succeed in the past, and that add_inbuf will succeed,
 * fake it accordingly.
 */
void *get_buf(unsigned *lenp, void **bufp)
{
	return "Buffer";
}

void poll_used(void)
{
}

void disable_call()
{
	assert(0);
}

bool enable_call()
{
	assert(0);
}

void kick_available(void)
{
	assert(0);
}

/* host side */
void disable_kick()
{
	assert(0);
}

bool enable_kick()
{
	assert(0);
}

void poll_avail(void)
{
}

bool use_buf(unsigned *lenp, void **bufp)
{
	return true;
}

void call_used(void)
{
	assert(0);
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -3,10 +3,10 @@
#use last CPU for host. Why not the first?
#use last CPU for host. Why not the first?
#many devices tend to use cpu0 by default so
#many devices tend to use cpu0 by default so
#it tends to be busier
#it tends to be busier
HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
HOST_AFFINITY=$(lscpu -p=cpu | tail -1)


#run command on all cpus
#run command on all cpus
for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
for cpu in $(seq 0 $HOST_AFFINITY)
do
do
	#Don't run guest and host on same CPU
	#Don't run guest and host on same CPU
	#It actually works ok if using signalling
	#It actually works ok if using signalling