From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Ingo Molnar" <mingo@kernel.org>,
"Clark Williams" <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Luis Cláudio Gonçalves" <lclaudio@redhat.com>,
"Namhyung Kim" <namhyung@kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Wang Nan" <wangnan0@huawei.com>
Subject: Re: [PATCH 16/16] tools include uapi: Sync linux/vhost.h with the kernel sources
Date: Wed, 9 Jan 2019 10:11:31 -0300 [thread overview]
Message-ID: <20190109131131.GB25192@kernel.org> (raw)
In-Reply-To: <20190108230822-mutt-send-email-mst@kernel.org>
Em Tue, Jan 08, 2019 at 11:10:10PM -0500, Michael S. Tsirkin escreveu:
> On Tue, Jan 08, 2019 at 04:59:10PM -0300, Arnaldo Carvalho de Melo wrote:
> > +++ b/tools/include/uapi/linux/vhost.h
> > @@ -11,94 +11,9 @@
> > * device configuration.
> > */
> > +#include <linux/vhost_types.h>
> Don't you then also need to import vhost_types.h?
If we were using this file as an include in a C source file, yes, but
we're just using it to generate a string table using regular
expressions:
[acme@quaco perf]$ tools/perf/trace/beauty/vhost_virtio_ioctl.sh
static const char *vhost_virtio_ioctl_cmds[] = {
[0x00] = "SET_FEATURES",
[0x01] = "SET_OWNER",
[0x02] = "RESET_OWNER",
[0x03] = "SET_MEM_TABLE",
[0x04] = "SET_LOG_BASE",
[0x07] = "SET_LOG_FD",
[0x10] = "SET_VRING_NUM",
[0x11] = "SET_VRING_ADDR",
[0x12] = "SET_VRING_BASE",
[0x13] = "SET_VRING_ENDIAN",
[0x14] = "GET_VRING_ENDIAN",
[0x20] = "SET_VRING_KICK",
[0x21] = "SET_VRING_CALL",
[0x22] = "SET_VRING_ERR",
[0x23] = "SET_VRING_BUSYLOOP_TIMEOUT",
[0x24] = "GET_VRING_BUSYLOOP_TIMEOUT",
[0x25] = "SET_BACKEND_FEATURES",
[0x30] = "NET_SET_BACKEND",
[0x40] = "SCSI_SET_ENDPOINT",
[0x41] = "SCSI_CLEAR_ENDPOINT",
[0x42] = "SCSI_GET_ABI_VERSION",
[0x43] = "SCSI_SET_EVENTS_MISSED",
[0x44] = "SCSI_GET_EVENTS_MISSED",
[0x60] = "VSOCK_SET_GUEST_CID",
[0x61] = "VSOCK_SET_RUNNING",
};
static const char *vhost_virtio_ioctl_read_cmds[] = {
[0x00] = "GET_FEATURES",
[0x12] = "GET_VRING_BASE",
[0x26] = "GET_BACKEND_FEATURES",
};
[acme@quaco perf]$
[acme@quaco perf]$ cat tools/perf/trace/beauty/vhost_virtio_ioctl.sh
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1
[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
printf "static const char *vhost_virtio_ioctl_cmds[] = {\n"
regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
egrep $regex ${header_dir}/vhost.h | \
sed -r "s/$regex/\2 \1/g" | \
sort | xargs printf "\t[%s] = \"%s\",\n"
printf "};\n"
printf "static const char *vhost_virtio_ioctl_read_cmds[] = {\n"
regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?R\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
egrep $regex ${header_dir}/vhost.h | \
sed -r "s/$regex/\2 \1/g" | \
sort | xargs printf "\t[%s] = \"%s\",\n"
printf "};\n"
[acme@quaco perf]$
This ends up being used in tools/perf/trace/beauty/ioctl.c, after that
trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c file (with the
vhost_virtio_ioctl_read_cmds and vhost_virtio_ioctl_cmds arrays) gets
generated by the tools/perf/Makefile.perf build process:
static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_t size)
{
#include "trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c"
static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds, "");
static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds, "");
struct strarray *s = (dir & _IOC_READ) ? &strarray__vhost_virtio_ioctl_read_cmds : &strarray__vhost_virtio_ioctl_cmds;
if (nr < s->nr_entries && s->entries[nr] != NULL)
return scnprintf(bf, size, "VHOST_%s", s->entries[nr]);
return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAF, nr, dir);
}
So, if at some point a tool needs to really #include that file, yeah,
then we will need to import vhost_types.h too.
- Arnaldo
next prev parent reply other threads:[~2019-01-09 13:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-08 19:58 [GIT PULL 00/16] perf/core fixes and improvements Arnaldo Carvalho de Melo
2019-01-08 19:58 ` [PATCH 01/16] perf trace: Fix ')' placement in "interrupted" syscall lines Arnaldo Carvalho de Melo
2019-01-08 19:58 ` [PATCH 02/16] perf trace: Fix alignment for [continued] lines Arnaldo Carvalho de Melo
2019-01-08 19:58 ` [PATCH 03/16] perf tools: Make find_vdso_map() more modular Arnaldo Carvalho de Melo
2019-01-08 19:58 ` [PATCH 04/16] perf tests: Add a test for the ARM 32-bit [vectors] page Arnaldo Carvalho de Melo
2019-01-08 19:58 ` [PATCH 05/16] tools lib traceevent: Introduce new libtracevent API: tep_override_comm() Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 06/16] tools lib traceevent: Initialize host_bigendian at tep_handle allocation Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 07/16] tools lib traceevent: Rename struct cmdline to struct tep_cmdline Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 08/16] tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 09/16] tools lib traceevent: Changed return logic of tep_register_event_handler() API Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 10/16] tools lib traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 11/16] tools lib traceevent: Remove tep_data_event_from_type() API Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 12/16] perf top: Lift restriction on using callchains without "sym" in --sort Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 13/16] tools include uapi: Grab a copy of linux/mount.h Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 14/16] perf beauty: Switch from using uapi/linux/fs.h to uapi/linux/mount.h Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 15/16] tools include uapi: Sync linux/fs.h copy with the kernel sources Arnaldo Carvalho de Melo
2019-01-08 19:59 ` [PATCH 16/16] tools include uapi: Sync linux/vhost.h " Arnaldo Carvalho de Melo
2019-01-09 4:10 ` Michael S. Tsirkin
2019-01-09 13:11 ` Arnaldo Carvalho de Melo [this message]
2019-01-09 7:05 ` [GIT PULL 00/16] perf/core fixes and improvements Ingo Molnar
2019-01-09 13:04 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190109131131.GB25192@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=jolsa@kernel.org \
--cc=lclaudio@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mst@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=wangnan0@huawei.com \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).