linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources
@ 2024-03-21 20:41 Arnaldo Carvalho de Melo
  2024-04-02 21:04 ` Namhyung Kim
  2024-04-02 21:23 ` Michael S. Tsirkin
  0 siblings, 2 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-03-21 20:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Michael S. Tsirkin, Namhyung Kim, Zhu Lingshan

tldr; Just FYI, I'm carrying this on the perf tools tree.

Full explanation:

There used to be no copies, with tools/ code using kernel headers
directly. From time to time tools/perf/ broke due to legitimate kernel
hacking. At some point Linus complained about such direct usage. Then we
adopted the current model.

The way these headers are used in perf are not restricted to just
including them to compile something.

There are sometimes used in scripts that convert defines into string
tables, etc, so some change may break one of these scripts, or new MSRs
may use some different #define pattern, etc.

E.g.:

  $ ls -1 tools/perf/trace/beauty/*.sh | head -5
  tools/perf/trace/beauty/arch_errno_names.sh
  tools/perf/trace/beauty/drm_ioctl.sh
  tools/perf/trace/beauty/fadvise.sh
  tools/perf/trace/beauty/fsconfig.sh
  tools/perf/trace/beauty/fsmount.sh
  $
  $ tools/perf/trace/beauty/fadvise.sh
  static const char *fadvise_advices[] = {
        [0] = "NORMAL",
        [1] = "RANDOM",
        [2] = "SEQUENTIAL",
        [3] = "WILLNEED",
        [4] = "DONTNEED",
        [5] = "NOREUSE",
  };
  $

The tools/perf/check-headers.sh script, part of the tools/ build
process, points out changes in the original files.

So its important not to touch the copies in tools/ when doing changes in
the original kernel headers, that will be done later, when
check-headers.sh inform about the change to the perf tools hackers.

To get the changes in:

  1496c47065f9f841 ("vhost-vdpa: uapi to support reporting per vq size")

To pick up these changes and support them:

  $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
  $ cp include/uapi/linux/vhost.h tools/perf/trace/beauty/include/uapi/linux/vhost.h
  $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
  $ diff -u before after
  --- before	2024-03-21 17:33:58.878173388 -0300
  +++ after	2024-03-21 17:34:07.687563333 -0300
  @@ -49,6 +49,7 @@
   	[0x7B] = "VDPA_GET_VRING_GROUP",
   	[0x7F] = "VDPA_GET_VRING_DESC_GROUP",
   	[0x80] = "VDPA_GET_VQS_COUNT",
  +	[0x80] = "VDPA_GET_VRING_SIZE",
   	[0x81] = "VDPA_GET_GROUP_NUM",
   	[0x8] = "NEW_WORKER",
   };
  $

For instance, see how those 'cmd' ioctl arguments get translated, now
VDPA_GET_VRING_SIZE 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: Kan Liang <kan.liang@linux.intel.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zhu Lingshan <lingshan.zhu@intel.com>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/trace/beauty/include/uapi/linux/vhost.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/trace/beauty/include/uapi/linux/vhost.h b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
index 649560c685f13b73..bea6973906134656 100644
--- a/tools/perf/trace/beauty/include/uapi/linux/vhost.h
+++ b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
@@ -227,4 +227,11 @@
  */
 #define VHOST_VDPA_GET_VRING_DESC_GROUP	_IOWR(VHOST_VIRTIO, 0x7F,	\
 					      struct vhost_vring_state)
+
+/* Get the queue size of a specific virtqueue.
+ * userspace set the vring index in vhost_vring_state.index
+ * kernel set the queue size in vhost_vring_state.num
+ */
+#define VHOST_VDPA_GET_VRING_SIZE	_IOWR(VHOST_VIRTIO, 0x80,	\
+					      struct vhost_vring_state)
 #endif
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources
  2024-03-21 20:41 [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources Arnaldo Carvalho de Melo
@ 2024-04-02 21:04 ` Namhyung Kim
  2024-04-02 21:15   ` Michael S. Tsirkin
  2024-04-02 21:39   ` Arnaldo Carvalho de Melo
  2024-04-02 21:23 ` Michael S. Tsirkin
  1 sibling, 2 replies; 5+ messages in thread
From: Namhyung Kim @ 2024-04-02 21:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Michael S. Tsirkin
  Cc: linux-kernel, Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Zhu Lingshan

On Thu, Mar 21, 2024 at 1:41 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> tldr; Just FYI, I'm carrying this on the perf tools tree.

Have you applied this to perf-tools-next?

>
> Full explanation:
>
> There used to be no copies, with tools/ code using kernel headers
> directly. From time to time tools/perf/ broke due to legitimate kernel
> hacking. At some point Linus complained about such direct usage. Then we
> adopted the current model.
>
> The way these headers are used in perf are not restricted to just
> including them to compile something.
>
> There are sometimes used in scripts that convert defines into string
> tables, etc, so some change may break one of these scripts, or new MSRs
> may use some different #define pattern, etc.
>
> E.g.:
>
>   $ ls -1 tools/perf/trace/beauty/*.sh | head -5
>   tools/perf/trace/beauty/arch_errno_names.sh
>   tools/perf/trace/beauty/drm_ioctl.sh
>   tools/perf/trace/beauty/fadvise.sh
>   tools/perf/trace/beauty/fsconfig.sh
>   tools/perf/trace/beauty/fsmount.sh
>   $
>   $ tools/perf/trace/beauty/fadvise.sh
>   static const char *fadvise_advices[] = {
>         [0] = "NORMAL",
>         [1] = "RANDOM",
>         [2] = "SEQUENTIAL",
>         [3] = "WILLNEED",
>         [4] = "DONTNEED",
>         [5] = "NOREUSE",
>   };
>   $
>
> The tools/perf/check-headers.sh script, part of the tools/ build
> process, points out changes in the original files.
>
> So its important not to touch the copies in tools/ when doing changes in
> the original kernel headers, that will be done later, when
> check-headers.sh inform about the change to the perf tools hackers.
>
> To get the changes in:
>
>   1496c47065f9f841 ("vhost-vdpa: uapi to support reporting per vq size")
>
> To pick up these changes and support them:
>
>   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
>   $ cp include/uapi/linux/vhost.h tools/perf/trace/beauty/include/uapi/linux/vhost.h
>   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
>   $ diff -u before after
>   --- before    2024-03-21 17:33:58.878173388 -0300
>   +++ after     2024-03-21 17:34:07.687563333 -0300
>   @@ -49,6 +49,7 @@
>         [0x7B] = "VDPA_GET_VRING_GROUP",
>         [0x7F] = "VDPA_GET_VRING_DESC_GROUP",
>         [0x80] = "VDPA_GET_VQS_COUNT",
>   +     [0x80] = "VDPA_GET_VRING_SIZE",

This gives me a build error:

  CC      trace/beauty/ioctl.o
In file included from trace/beauty/ioctl.c:93:
linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:
   In function ‘ioctl__scnprintf_vhost_virtio_cmd’:
linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:53:18:
   error: initialized field overwritten [-Werror=override-init]
   53 |         [0x80] = "VDPA_GET_VRING_SIZE",
      |                  ^~~~~~~~~~~~~~~~~~~~~
linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:53:18:
   note: (near initialization for ‘vhost_virtio_ioctl_read_cmds[128]’)

Because there are two entries for 0x80 now.

Is it ok for vhost to have the same number for VQS_COUNT
and VRING_SIZE?

Thanks,
Namhyung


>         [0x81] = "VDPA_GET_GROUP_NUM",
>         [0x8] = "NEW_WORKER",
>    };
>   $
>
> For instance, see how those 'cmd' ioctl arguments get translated, now
> VDPA_GET_VRING_SIZE 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: Kan Liang <kan.liang@linux.intel.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zhu Lingshan <lingshan.zhu@intel.com>
> Link: https://lore.kernel.org/lkml/
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/trace/beauty/include/uapi/linux/vhost.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/trace/beauty/include/uapi/linux/vhost.h b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> index 649560c685f13b73..bea6973906134656 100644
> --- a/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> +++ b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> @@ -227,4 +227,11 @@
>   */
>  #define VHOST_VDPA_GET_VRING_DESC_GROUP        _IOWR(VHOST_VIRTIO, 0x7F,       \
>                                               struct vhost_vring_state)
> +
> +/* Get the queue size of a specific virtqueue.
> + * userspace set the vring index in vhost_vring_state.index
> + * kernel set the queue size in vhost_vring_state.num
> + */
> +#define VHOST_VDPA_GET_VRING_SIZE      _IOWR(VHOST_VIRTIO, 0x80,       \
> +                                             struct vhost_vring_state)
>  #endif
> --
> 2.44.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources
  2024-04-02 21:04 ` Namhyung Kim
@ 2024-04-02 21:15   ` Michael S. Tsirkin
  2024-04-02 21:39   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2024-04-02 21:15 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, linux-kernel, Adrian Hunter,
	Ian Rogers, Jiri Olsa, Kan Liang, Zhu Lingshan, Jason Wang

On Tue, Apr 02, 2024 at 02:04:39PM -0700, Namhyung Kim wrote:
> On Thu, Mar 21, 2024 at 1:41 PM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > tldr; Just FYI, I'm carrying this on the perf tools tree.
> 
> Have you applied this to perf-tools-next?
> 
> >
> > Full explanation:
> >
> > There used to be no copies, with tools/ code using kernel headers
> > directly. From time to time tools/perf/ broke due to legitimate kernel
> > hacking. At some point Linus complained about such direct usage. Then we
> > adopted the current model.
> >
> > The way these headers are used in perf are not restricted to just
> > including them to compile something.
> >
> > There are sometimes used in scripts that convert defines into string
> > tables, etc, so some change may break one of these scripts, or new MSRs
> > may use some different #define pattern, etc.
> >
> > E.g.:
> >
> >   $ ls -1 tools/perf/trace/beauty/*.sh | head -5
> >   tools/perf/trace/beauty/arch_errno_names.sh
> >   tools/perf/trace/beauty/drm_ioctl.sh
> >   tools/perf/trace/beauty/fadvise.sh
> >   tools/perf/trace/beauty/fsconfig.sh
> >   tools/perf/trace/beauty/fsmount.sh
> >   $
> >   $ tools/perf/trace/beauty/fadvise.sh
> >   static const char *fadvise_advices[] = {
> >         [0] = "NORMAL",
> >         [1] = "RANDOM",
> >         [2] = "SEQUENTIAL",
> >         [3] = "WILLNEED",
> >         [4] = "DONTNEED",
> >         [5] = "NOREUSE",
> >   };
> >   $
> >
> > The tools/perf/check-headers.sh script, part of the tools/ build
> > process, points out changes in the original files.
> >
> > So its important not to touch the copies in tools/ when doing changes in
> > the original kernel headers, that will be done later, when
> > check-headers.sh inform about the change to the perf tools hackers.
> >
> > To get the changes in:
> >
> >   1496c47065f9f841 ("vhost-vdpa: uapi to support reporting per vq size")
> >
> > To pick up these changes and support them:
> >
> >   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
> >   $ cp include/uapi/linux/vhost.h tools/perf/trace/beauty/include/uapi/linux/vhost.h
> >   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
> >   $ diff -u before after
> >   --- before    2024-03-21 17:33:58.878173388 -0300
> >   +++ after     2024-03-21 17:34:07.687563333 -0300
> >   @@ -49,6 +49,7 @@
> >         [0x7B] = "VDPA_GET_VRING_GROUP",
> >         [0x7F] = "VDPA_GET_VRING_DESC_GROUP",
> >         [0x80] = "VDPA_GET_VQS_COUNT",
> >   +     [0x80] = "VDPA_GET_VRING_SIZE",
> 
> This gives me a build error:
> 
>   CC      trace/beauty/ioctl.o
> In file included from trace/beauty/ioctl.c:93:
> linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:
>    In function ‘ioctl__scnprintf_vhost_virtio_cmd’:
> linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:53:18:
>    error: initialized field overwritten [-Werror=override-init]
>    53 |         [0x80] = "VDPA_GET_VRING_SIZE",
>       |                  ^~~~~~~~~~~~~~~~~~~~~
> linux/tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:53:18:
>    note: (near initialization for ‘vhost_virtio_ioctl_read_cmds[128]’)
> 
> Because there are two entries for 0x80 now.
> 
> Is it ok for vhost to have the same number for VQS_COUNT
> and VRING_SIZE?
> 
> Thanks,
> Namhyung

Oh!
This is a bug in:

commit 1496c47065f9f8413296780c63374daee9bdae20
Author: Zhu Lingshan <lingshan.zhu@intel.com>
Date:   Sat Feb 3 00:38:56 2024 +0800

    vhost-vdpa: uapi to support reporting per vq size
    
    The size of a virtqueue is a per vq configuration.
    This commit introduce a new ioctl uAPI to support this flexibility.
    
    Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
    Message-Id: <20240202163905.8834-2-lingshan.zhu@intel.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>


It's great that you noticed. It works by chance because one is IOR the
other IOWR and the size is different.

But yes we must fix it - it is not too late this is just in an rc not
in any released kernels.

Will send a fix soon!

> 
> >         [0x81] = "VDPA_GET_GROUP_NUM",
> >         [0x8] = "NEW_WORKER",
> >    };
> >   $
> >
> > For instance, see how those 'cmd' ioctl arguments get translated, now
> > VDPA_GET_VRING_SIZE 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: Kan Liang <kan.liang@linux.intel.com>
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Zhu Lingshan <lingshan.zhu@intel.com>
> > Link: https://lore.kernel.org/lkml/
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > ---
> >  tools/perf/trace/beauty/include/uapi/linux/vhost.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/tools/perf/trace/beauty/include/uapi/linux/vhost.h b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> > index 649560c685f13b73..bea6973906134656 100644
> > --- a/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> > +++ b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> > @@ -227,4 +227,11 @@
> >   */
> >  #define VHOST_VDPA_GET_VRING_DESC_GROUP        _IOWR(VHOST_VIRTIO, 0x7F,       \
> >                                               struct vhost_vring_state)
> > +
> > +/* Get the queue size of a specific virtqueue.
> > + * userspace set the vring index in vhost_vring_state.index
> > + * kernel set the queue size in vhost_vring_state.num
> > + */
> > +#define VHOST_VDPA_GET_VRING_SIZE      _IOWR(VHOST_VIRTIO, 0x80,       \
> > +                                             struct vhost_vring_state)
> >  #endif
> > --
> > 2.44.0
> >


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources
  2024-03-21 20:41 [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources Arnaldo Carvalho de Melo
  2024-04-02 21:04 ` Namhyung Kim
@ 2024-04-02 21:23 ` Michael S. Tsirkin
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2024-04-02 21:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Namhyung Kim, Zhu Lingshan

On Thu, Mar 21, 2024 at 05:41:54PM -0300, Arnaldo Carvalho de Melo wrote:
> tldr; Just FYI, I'm carrying this on the perf tools tree.
> 
> Full explanation:
> 
> There used to be no copies, with tools/ code using kernel headers
> directly. From time to time tools/perf/ broke due to legitimate kernel
> hacking. At some point Linus complained about such direct usage. Then we
> adopted the current model.
> 
> The way these headers are used in perf are not restricted to just
> including them to compile something.
> 
> There are sometimes used in scripts that convert defines into string
> tables, etc, so some change may break one of these scripts, or new MSRs
> may use some different #define pattern, etc.
> 
> E.g.:
> 
>   $ ls -1 tools/perf/trace/beauty/*.sh | head -5
>   tools/perf/trace/beauty/arch_errno_names.sh
>   tools/perf/trace/beauty/drm_ioctl.sh
>   tools/perf/trace/beauty/fadvise.sh
>   tools/perf/trace/beauty/fsconfig.sh
>   tools/perf/trace/beauty/fsmount.sh
>   $
>   $ tools/perf/trace/beauty/fadvise.sh
>   static const char *fadvise_advices[] = {
>         [0] = "NORMAL",
>         [1] = "RANDOM",
>         [2] = "SEQUENTIAL",
>         [3] = "WILLNEED",
>         [4] = "DONTNEED",
>         [5] = "NOREUSE",
>   };
>   $
> 
> The tools/perf/check-headers.sh script, part of the tools/ build
> process, points out changes in the original files.
> 
> So its important not to touch the copies in tools/ when doing changes in
> the original kernel headers, that will be done later, when
> check-headers.sh inform about the change to the perf tools hackers.
> 
> To get the changes in:
> 
>   1496c47065f9f841 ("vhost-vdpa: uapi to support reporting per vq size")
> 
> To pick up these changes and support them:
> 
>   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
>   $ cp include/uapi/linux/vhost.h tools/perf/trace/beauty/include/uapi/linux/vhost.h
>   $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
>   $ diff -u before after
>   --- before	2024-03-21 17:33:58.878173388 -0300
>   +++ after	2024-03-21 17:34:07.687563333 -0300
>   @@ -49,6 +49,7 @@
>    	[0x7B] = "VDPA_GET_VRING_GROUP",
>    	[0x7F] = "VDPA_GET_VRING_DESC_GROUP",
>    	[0x80] = "VDPA_GET_VQS_COUNT",
>   +	[0x80] = "VDPA_GET_VRING_SIZE",
>    	[0x81] = "VDPA_GET_GROUP_NUM",
>    	[0x8] = "NEW_WORKER",
>    };
>   $
> 
> For instance, see how those 'cmd' ioctl arguments get translated, now
> VDPA_GET_VRING_SIZE 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: Kan Liang <kan.liang@linux.intel.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zhu Lingshan <lingshan.zhu@intel.com>
> Link: https://lore.kernel.org/lkml/
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


Thanks a lot for taking care of this! So given the header is actually
buggy pls hang on to this change until I merge the fix for the header
(you were CC'd on the patch).
It's great we have this redundancy which allowed us to catch the bug
in time, and many thanks to Namhyung Kim for reporting the issue!


> ---
>  tools/perf/trace/beauty/include/uapi/linux/vhost.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/perf/trace/beauty/include/uapi/linux/vhost.h b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> index 649560c685f13b73..bea6973906134656 100644
> --- a/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> +++ b/tools/perf/trace/beauty/include/uapi/linux/vhost.h
> @@ -227,4 +227,11 @@
>   */
>  #define VHOST_VDPA_GET_VRING_DESC_GROUP	_IOWR(VHOST_VIRTIO, 0x7F,	\
>  					      struct vhost_vring_state)
> +
> +/* Get the queue size of a specific virtqueue.
> + * userspace set the vring index in vhost_vring_state.index
> + * kernel set the queue size in vhost_vring_state.num
> + */
> +#define VHOST_VDPA_GET_VRING_SIZE	_IOWR(VHOST_VIRTIO, 0x80,	\
> +					      struct vhost_vring_state)
>  #endif
> -- 
> 2.44.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources
  2024-04-02 21:04 ` Namhyung Kim
  2024-04-02 21:15   ` Michael S. Tsirkin
@ 2024-04-02 21:39   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-04-02 21:39 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Michael S. Tsirkin, linux-kernel, Adrian Hunter, Ian Rogers,
	Jiri Olsa, Kan Liang, Zhu Lingshan

On Tue, Apr 02, 2024 at 02:04:39PM -0700, Namhyung Kim wrote:
> On Thu, Mar 21, 2024 at 1:41 PM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > tldr; Just FYI, I'm carrying this on the perf tools tree.
> 
> Have you applied this to perf-tools-next?

Nope.
 
> >   +++ after     2024-03-21 17:34:07.687563333 -0300
> >   @@ -49,6 +49,7 @@
> >         [0x7B] = "VDPA_GET_VRING_GROUP",
> >         [0x7F] = "VDPA_GET_VRING_DESC_GROUP",
> >         [0x80] = "VDPA_GET_VQS_COUNT",
> >   +     [0x80] = "VDPA_GET_VRING_SIZE",
> 
> This gives me a build error:

I noticed it and removed it.

⬢[acme@toolbox perf-tools-next]$ git log --oneline perf-tools-next/perf-tools-next torvalds/master.. | grep vhost
4962e1949608fed9 perf beauty: Move uapi/linux/vhost.h copy out of the directory used to build perf
⬢[acme@toolbox perf-tools-next]$ 

Thanks for double checking!

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-02 21:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 20:41 [PATCH fyi 1/1] perf trace beauty: Sync linux/vhost.h with the kernel sources Arnaldo Carvalho de Melo
2024-04-02 21:04 ` Namhyung Kim
2024-04-02 21:15   ` Michael S. Tsirkin
2024-04-02 21:39   ` Arnaldo Carvalho de Melo
2024-04-02 21:23 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).