aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-08 13:41:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-08 13:41:00 -0500
commit846ade7dd2e630a309a8c57302046e8c4037b8df (patch)
tree021892148643db7cd0c898ad5939ecc7836a7330 /tools
parent977e41524dae8fed9c82e3dd298f3b48282fc0b8 (diff)
parentd25cc43c6775bff6b8e3dad97c747954b805e421 (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/virtio/ringtest/ring.c30
-rw-r--r--tools/virtio/ringtest/virtio_ring_0_9.c24
2 files changed, 31 insertions, 23 deletions
diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index 747c5dd47be8..5a41404aaef5 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -84,12 +84,11 @@ void alloc_ring(void)
84 perror("Unable to allocate ring buffer.\n"); 84 perror("Unable to allocate ring buffer.\n");
85 exit(3); 85 exit(3);
86 } 86 }
87 event = malloc(sizeof *event); 87 event = calloc(1, sizeof(*event));
88 if (!event) { 88 if (!event) {
89 perror("Unable to allocate event buffer.\n"); 89 perror("Unable to allocate event buffer.\n");
90 exit(3); 90 exit(3);
91 } 91 }
92 memset(event, 0, sizeof *event);
93 guest.avail_idx = 0; 92 guest.avail_idx = 0;
94 guest.kicked_avail_idx = -1; 93 guest.kicked_avail_idx = -1;
95 guest.last_used_idx = 0; 94 guest.last_used_idx = 0;
@@ -102,12 +101,11 @@ void alloc_ring(void)
102 ring[i] = desc; 101 ring[i] = desc;
103 } 102 }
104 guest.num_free = ring_size; 103 guest.num_free = ring_size;
105 data = malloc(ring_size * sizeof *data); 104 data = calloc(ring_size, sizeof(*data));
106 if (!data) { 105 if (!data) {
107 perror("Unable to allocate data buffer.\n"); 106 perror("Unable to allocate data buffer.\n");
108 exit(3); 107 exit(3);
109 } 108 }
110 memset(data, 0, ring_size * sizeof *data);
111} 109}
112 110
113/* guest side */ 111/* guest side */
@@ -188,16 +186,18 @@ bool enable_call()
188 186
189void kick_available(void) 187void kick_available(void)
190{ 188{
189 bool need;
190
191 /* Flush in previous flags write */ 191 /* Flush in previous flags write */
192 /* Barrier C (for pairing) */ 192 /* Barrier C (for pairing) */
193 smp_mb(); 193 smp_mb();
194 if (!need_event(event->kick_index, 194 need = need_event(event->kick_index,
195 guest.avail_idx, 195 guest.avail_idx,
196 guest.kicked_avail_idx)) 196 guest.kicked_avail_idx);
197 return;
198 197
199 guest.kicked_avail_idx = guest.avail_idx; 198 guest.kicked_avail_idx = guest.avail_idx;
200 kick(); 199 if (need)
200 kick();
201} 201}
202 202
203/* host side */ 203/* host side */
@@ -253,14 +253,18 @@ bool use_buf(unsigned *lenp, void **bufp)
253 253
254void call_used(void) 254void call_used(void)
255{ 255{
256 bool need;
257
256 /* Flush in previous flags write */ 258 /* Flush in previous flags write */
257 /* Barrier D (for pairing) */ 259 /* Barrier D (for pairing) */
258 smp_mb(); 260 smp_mb();
259 if (!need_event(event->call_index, 261
262 need = need_event(event->call_index,
260 host.used_idx, 263 host.used_idx,
261 host.called_used_idx)) 264 host.called_used_idx);
262 return;
263 265
264 host.called_used_idx = host.used_idx; 266 host.called_used_idx = host.used_idx;
265 call(); 267
268 if (need)
269 call();
266} 270}
diff --git a/tools/virtio/ringtest/virtio_ring_0_9.c b/tools/virtio/ringtest/virtio_ring_0_9.c
index bbc3043b2fb1..5fd3fbcb9e57 100644
--- a/tools/virtio/ringtest/virtio_ring_0_9.c
+++ b/tools/virtio/ringtest/virtio_ring_0_9.c
@@ -225,16 +225,18 @@ bool enable_call()
225 225
226void kick_available(void) 226void kick_available(void)
227{ 227{
228 bool need;
229
228 /* Flush in previous flags write */ 230 /* Flush in previous flags write */
229 /* Barrier C (for pairing) */ 231 /* Barrier C (for pairing) */
230 smp_mb(); 232 smp_mb();
231 if (!vring_need_event(vring_avail_event(&ring), 233 need = vring_need_event(vring_avail_event(&ring),
232 guest.avail_idx, 234 guest.avail_idx,
233 guest.kicked_avail_idx)) 235 guest.kicked_avail_idx);
234 return;
235 236
236 guest.kicked_avail_idx = guest.avail_idx; 237 guest.kicked_avail_idx = guest.avail_idx;
237 kick(); 238 if (need)
239 kick();
238} 240}
239 241
240/* host side */ 242/* host side */
@@ -316,14 +318,16 @@ bool use_buf(unsigned *lenp, void **bufp)
316 318
317void call_used(void) 319void call_used(void)
318{ 320{
321 bool need;
322
319 /* Flush in previous flags write */ 323 /* Flush in previous flags write */
320 /* Barrier D (for pairing) */ 324 /* Barrier D (for pairing) */
321 smp_mb(); 325 smp_mb();
322 if (!vring_need_event(vring_used_event(&ring), 326 need = vring_need_event(vring_used_event(&ring),
323 host.used_idx, 327 host.used_idx,
324 host.called_used_idx)) 328 host.called_used_idx);
325 return;
326 329
327 host.called_used_idx = host.used_idx; 330 host.called_used_idx = host.used_idx;
328 call(); 331 if (need)
332 call();
329} 333}