Skip to content

Commit 7b86159

Browse files
committed
tools include UAPI: Sync linux/vhost.h with the kernel sources
To get the changes in: 228a27c ("vhost: Allow worker switching while work is queueing") c1ecd8e ("vhost: allow userspace to create workers") To pick up these changes and support them: $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before $ cp include/uapi/linux/vhost.h tools/include/uapi/linux/vhost.h $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after $ diff -u before after --- before 2023-07-14 09:58:14.268249807 -0300 +++ after 2023-07-14 09:58:23.041493892 -0300 @@ -10,6 +10,7 @@ [0x12] = "SET_VRING_BASE", [0x13] = "SET_VRING_ENDIAN", [0x14] = "GET_VRING_ENDIAN", + [0x15] = "ATTACH_VRING_WORKER", [0x20] = "SET_VRING_KICK", [0x21] = "SET_VRING_CALL", [0x22] = "SET_VRING_ERR", @@ -31,10 +32,12 @@ [0x7C] = "VDPA_SET_GROUP_ASID", [0x7D] = "VDPA_SUSPEND", [0x7E] = "VDPA_RESUME", + [0x9] = "FREE_WORKER", }; static const char *vhost_virtio_ioctl_read_cmds[] = { [0x00] = "GET_FEATURES", [0x12] = "GET_VRING_BASE", + [0x16] = "GET_VRING_WORKER", [0x26] = "GET_BACKEND_FEATURES", [0x70] = "VDPA_GET_DEVICE_ID", [0x71] = "VDPA_GET_STATUS", @@ -44,6 +47,7 @@ [0x79] = "VDPA_GET_CONFIG_SIZE", [0x7A] = "VDPA_GET_AS_NUM", [0x7B] = "VDPA_GET_VRING_GROUP", + [0x8] = "NEW_WORKER", [0x80] = "VDPA_GET_VQS_COUNT", [0x81] = "VDPA_GET_GROUP_NUM", }; $ For instance, see how those 'cmd' ioctl arguments get translated, now ATTACH_VRING_WORKER, GET_VRING_WORKER and NEW_WORKER, will be as well: # perf trace -a -e ioctl --max-events=10 0.000 ( 0.011 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1) = 0 21.353 ( 0.014 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1) = 0 25.766 ( 0.014 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740) = 0 25.845 ( 0.034 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70) = 0 25.916 ( 0.011 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0) = 0 25.941 ( 0.025 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ATOMIC, arg: 0x7ffe4a22c840) = 0 32.915 ( 0.009 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_RMFB, arg: 0x7ffe4a22cf9c) = 0 42.522 ( 0.013 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740) = 0 42.579 ( 0.031 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70) = 0 42.644 ( 0.010 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0) = 0 # Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Michael S. Tsirkin <[email protected]> Cc: Mike Christie <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/lkml/ZLFJ%[email protected]/ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 0e022f5 commit 7b86159

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tools/include/uapi/linux/vhost.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@
4545
#define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)
4646
/* Specify an eventfd file descriptor to signal on log write. */
4747
#define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int)
48+
/* By default, a device gets one vhost_worker that its virtqueues share. This
49+
* command allows the owner of the device to create an additional vhost_worker
50+
* for the device. It can later be bound to 1 or more of its virtqueues using
51+
* the VHOST_ATTACH_VRING_WORKER command.
52+
*
53+
* This must be called after VHOST_SET_OWNER and the caller must be the owner
54+
* of the device. The new thread will inherit caller's cgroups and namespaces,
55+
* and will share the caller's memory space. The new thread will also be
56+
* counted against the caller's RLIMIT_NPROC value.
57+
*
58+
* The worker's ID used in other commands will be returned in
59+
* vhost_worker_state.
60+
*/
61+
#define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state)
62+
/* Free a worker created with VHOST_NEW_WORKER if it's not attached to any
63+
* virtqueue. If userspace is not able to call this for workers its created,
64+
* the kernel will free all the device's workers when the device is closed.
65+
*/
66+
#define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state)
4867

4968
/* Ring setup. */
5069
/* Set number of descriptors in ring. This parameter can not
@@ -70,6 +89,18 @@
7089
#define VHOST_VRING_BIG_ENDIAN 1
7190
#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)
7291
#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state)
92+
/* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's
93+
* virtqueues.
94+
*
95+
* This will replace the virtqueue's existing worker. If the replaced worker
96+
* is no longer attached to any virtqueues, it can be freed with
97+
* VHOST_FREE_WORKER.
98+
*/
99+
#define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15, \
100+
struct vhost_vring_worker)
101+
/* Return the vring worker's ID */
102+
#define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16, \
103+
struct vhost_vring_worker)
73104

74105
/* The following ioctls use eventfd file descriptors to signal and poll
75106
* for events. */

0 commit comments

Comments
 (0)