Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools include UAPI: Sync linux/vhost.h with the kernel sources

To get the changes in:

228a27cf78afc63a ("vhost: Allow worker switching while work is queueing")
c1ecd8e950079774 ("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 <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/ZLFJ%2FRsDGYiaH5nj@kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+31
+31
tools/include/uapi/linux/vhost.h
··· 45 45 #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64) 46 46 /* Specify an eventfd file descriptor to signal on log write. */ 47 47 #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) 48 67 49 68 /* Ring setup. */ 50 69 /* Set number of descriptors in ring. This parameter can not ··· 89 70 #define VHOST_VRING_BIG_ENDIAN 1 90 71 #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) 91 72 #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) 73 + /* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's 74 + * virtqueues. 75 + * 76 + * This will replace the virtqueue's existing worker. If the replaced worker 77 + * is no longer attached to any virtqueues, it can be freed with 78 + * VHOST_FREE_WORKER. 79 + */ 80 + #define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15, \ 81 + struct vhost_vring_worker) 82 + /* Return the vring worker's ID */ 83 + #define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16, \ 84 + struct vhost_vring_worker) 92 85 93 86 /* The following ioctls use eventfd file descriptors to signal and poll 94 87 * for events. */