Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio/vhost updates from Michael Tsirkin:
 "virtio, vhost: fixes, cleanups, features

  This includes the disk/cache memory stats for for the virtio balloon,
  as well as multiple fixes and cleanups"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  vhost: don't hold onto file pointer for VHOST_SET_LOG_FD
  vhost: don't hold onto file pointer for VHOST_SET_VRING_ERR
  vhost: don't hold onto file pointer for VHOST_SET_VRING_CALL
  ringtest: ring.c malloc & memset to calloc
  virtio_vop: don't kfree device on register failure
  virtio_pci: don't kfree device on register failure
  virtio: split device_register into device_initialize and device_add
  vhost: remove unused lock check flag in vhost_dev_cleanup()
  vhost: Remove the unused variable.
  virtio_blk: print capacity at probe time
  virtio: make VIRTIO a menuconfig to ease disabling it all
  virtio/ringtest: virtio_ring: fix up need_event math
  virtio/ringtest: fix up need_event math
  virtio: virtio_mmio: make of_device_ids const.
  firmware: Use PTR_ERR_OR_ZERO()
  virtio-mmio: Use PTR_ERR_OR_ZERO()
  vhost/scsi: Improve a size determination in four functions
  virtio_balloon: include disk/file caches memory statistics
This commit is contained in:
Linus Torvalds
2018-02-08 10:41:00 -08:00
17 changed files with 120 additions and 131 deletions

View File

@@ -84,12 +84,11 @@ void alloc_ring(void)
perror("Unable to allocate ring buffer.\n");
exit(3);
}
event = malloc(sizeof *event);
event = calloc(1, sizeof(*event));
if (!event) {
perror("Unable to allocate event buffer.\n");
exit(3);
}
memset(event, 0, sizeof *event);
guest.avail_idx = 0;
guest.kicked_avail_idx = -1;
guest.last_used_idx = 0;
@@ -102,12 +101,11 @@ void alloc_ring(void)
ring[i] = desc;
}
guest.num_free = ring_size;
data = malloc(ring_size * sizeof *data);
data = calloc(ring_size, sizeof(*data));
if (!data) {
perror("Unable to allocate data buffer.\n");
exit(3);
}
memset(data, 0, ring_size * sizeof *data);
}
/* guest side */
@@ -188,16 +186,18 @@ bool enable_call()
void kick_available(void)
{
bool need;
/* Flush in previous flags write */
/* Barrier C (for pairing) */
smp_mb();
if (!need_event(event->kick_index,
guest.avail_idx,
guest.kicked_avail_idx))
return;
need = need_event(event->kick_index,
guest.avail_idx,
guest.kicked_avail_idx);
guest.kicked_avail_idx = guest.avail_idx;
kick();
if (need)
kick();
}
/* host side */
@@ -253,14 +253,18 @@ bool use_buf(unsigned *lenp, void **bufp)
void call_used(void)
{
bool need;
/* Flush in previous flags write */
/* Barrier D (for pairing) */
smp_mb();
if (!need_event(event->call_index,
need = need_event(event->call_index,
host.used_idx,
host.called_used_idx))
return;
host.called_used_idx);
host.called_used_idx = host.used_idx;
call();
if (need)
call();
}

View File

@@ -225,16 +225,18 @@ bool enable_call()
void kick_available(void)
{
bool need;
/* Flush in previous flags write */
/* Barrier C (for pairing) */
smp_mb();
if (!vring_need_event(vring_avail_event(&ring),
guest.avail_idx,
guest.kicked_avail_idx))
return;
need = vring_need_event(vring_avail_event(&ring),
guest.avail_idx,
guest.kicked_avail_idx);
guest.kicked_avail_idx = guest.avail_idx;
kick();
if (need)
kick();
}
/* host side */
@@ -316,14 +318,16 @@ bool use_buf(unsigned *lenp, void **bufp)
void call_used(void)
{
bool need;
/* Flush in previous flags write */
/* Barrier D (for pairing) */
smp_mb();
if (!vring_need_event(vring_used_event(&ring),
host.used_idx,
host.called_used_idx))
return;
need = vring_need_event(vring_used_event(&ring),
host.used_idx,
host.called_used_idx);
host.called_used_idx = host.used_idx;
call();
if (need)
call();
}