All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Michał Leszczyński" <michal.leszczynski@cert.pl>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>, "Wei Liu" <wl@xen.org>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Tamas K Lengyel" <tamas@tklengyel.com>
Subject: [PATCH v7 03/10] tools/[lib]xl: Add vmtrace_buf_size parameter
Date: Thu, 21 Jan 2021 21:27:11 +0000	[thread overview]
Message-ID: <20210121212718.2441-4-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20210121212718.2441-1-andrew.cooper3@citrix.com>

From: Michał Leszczyński <michal.leszczynski@cert.pl>

Allow to specify the size of per-vCPU trace buffer upon
domain creation. This is zero by default (meaning: not enabled).

Signed-off-by: Michał Leszczyński <michal.leszczynski@cert.pl>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <iwj@xenproject.org>
CC: Wei Liu <wl@xen.org>
CC: Anthony PERARD <anthony.perard@citrix.com>
CC: Michał Leszczyński <michal.leszczynski@cert.pl>
CC: Tamas K Lengyel <tamas@tklengyel.com>

v7:
 * Use the name 'vmtrace' consistently.
---
 docs/man/xl.cfg.5.pod.in             | 9 +++++++++
 tools/golang/xenlight/helpers.gen.go | 2 ++
 tools/golang/xenlight/types.gen.go   | 1 +
 tools/include/libxl.h                | 7 +++++++
 tools/libs/light/libxl_create.c      | 2 ++
 tools/libs/light/libxl_types.idl     | 4 ++++
 tools/xl/xl_parse.c                  | 4 ++++
 7 files changed, 29 insertions(+)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index c8e017f950..86963298a3 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -681,6 +681,15 @@ Windows).
 
 If this option is not specified then it will default to B<false>.
 
+=item B<vmtrace_buf_kb=KBYTES>
+
+Specifies the size of vmtrace buffer that would be allocated for each
+vCPU belonging to this domain.  Disabled (i.e.  B<vmtrace_buf_kb=0>) by
+default.
+
+B<NOTE>: Acceptable values are platform specific.  For Intel Processor
+Trace, this value must be a power of 2 between 4k and 16M.
+
 =back
 
 =head2 Devices
diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 62fb98ba30..1e22a407bf 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1114,6 +1114,7 @@ return fmt.Errorf("invalid union key '%v'", x.Type)}
 x.ArchArm.GicVersion = GicVersion(xc.arch_arm.gic_version)
 x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart)
 x.Altp2M = Altp2MMode(xc.altp2m)
+x.VmtraceBufKb = int(xc.vmtrace_buf_kb)
 
  return nil}
 
@@ -1589,6 +1590,7 @@ return fmt.Errorf("invalid union key '%v'", x.Type)}
 xc.arch_arm.gic_version = C.libxl_gic_version(x.ArchArm.GicVersion)
 xc.arch_arm.vuart = C.libxl_vuart_type(x.ArchArm.Vuart)
 xc.altp2m = C.libxl_altp2m_mode(x.Altp2M)
+xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb)
 
  return nil
  }
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 369da6dd1e..130524dce9 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -513,6 +513,7 @@ GicVersion GicVersion
 Vuart VuartType
 }
 Altp2M Altp2MMode
+VmtraceBufKb int
 }
 
 type domainBuildInfoTypeUnion interface {
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index c4d920f1e5..7606a21219 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -471,6 +471,13 @@
 #define LIBXL_HAVE_PHYSINFO_CAP_VMTRACE 1
 
 /*
+ * LIBXL_HAVE_VMTRACE_BUF_KB indicates that libxl_domain_create_info has a
+ * vmtrace_buf_kb parameter, which allows to enable pre-allocation of
+ * processor tracing buffers of given size.
+ */
+#define LIBXL_HAVE_VMTRACE_BUF_KB 1
+
+/*
  * libxl ABI compatibility
  *
  * The only guarantee which libxl makes regarding ABI compatibility
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 86f4a8369d..d4a9380357 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -607,6 +607,8 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
             .max_evtchn_port = b_info->event_channels,
             .max_grant_frames = b_info->max_grant_frames,
             .max_maptrack_frames = b_info->max_maptrack_frames,
+            .vmtrace_frames = DIV_ROUNDUP(b_info->vmtrace_buf_kb,
+                                          XC_PAGE_SIZE >> 10),
         };
 
         if (info->type != LIBXL_DOMAIN_TYPE_PV) {
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index b43d5f1265..c092c31b5e 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -646,6 +646,10 @@ libxl_domain_build_info = Struct("domain_build_info",[
     # supported by x86 HVM and ARM support is planned.
     ("altp2m", libxl_altp2m_mode),
 
+    # Size of preallocated vmtrace trace buffers (in KBYTES).
+    # Use zero value to disable this feature.
+    ("vmtrace_buf_kb", integer),
+
     ], dir=DIR_IN,
        copy_deprecated_fn="libxl__domain_build_info_copy_deprecated",
 )
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 4ebf39620a..ca99af8d1b 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1863,6 +1863,10 @@ void parse_config_data(const char *config_source,
         }
     }
 
+    if (!xlu_cfg_get_long(config, "vmtrace_buf_kb", &l, 1) && l) {
+        b_info->vmtrace_buf_kb = l;
+    }
+
     if (!xlu_cfg_get_list(config, "ioports", &ioports, &num_ioports, 0)) {
         b_info->num_ioports = num_ioports;
         b_info->ioports = calloc(num_ioports, sizeof(*b_info->ioports));
-- 
2.11.0



  parent reply	other threads:[~2021-01-21 21:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21 21:27 [PATCH v7 00/10] Implement support for external IPT monitoring Andrew Cooper
2021-01-21 21:27 ` [PATCH v7 01/10] xen+tools: Introduce XEN_SYSCTL_PHYSCAP_vmtrace Andrew Cooper
2021-01-22 15:28   ` Ian Jackson
2021-01-26  8:58   ` Julien Grall
2021-01-26 10:04     ` Andrew Cooper
2021-01-21 21:27 ` [PATCH v7 02/10] xen/domain: Add vmtrace_frames domain creation parameter Andrew Cooper
2021-01-25 15:08   ` Jan Beulich
2021-01-25 17:17     ` Andrew Cooper
2021-01-26 10:51       ` Jan Beulich
2021-01-29 16:37     ` Jan Beulich
2021-01-21 21:27 ` Andrew Cooper [this message]
2021-01-22 15:29   ` [PATCH v7 03/10] tools/[lib]xl: Add vmtrace_buf_size parameter Ian Jackson
2021-01-21 21:27 ` [PATCH v7 04/10] xen/memory: Add a vmtrace_buf resource type Andrew Cooper
2021-01-25 16:31   ` Jan Beulich
2021-01-26  7:37     ` Jan Beulich
2021-01-26  9:58       ` Andrew Cooper
2021-01-26 10:30         ` Jan Beulich
2021-01-21 21:27 ` [PATCH v7 05/10] x86/vmx: Add Intel Processor Trace support Andrew Cooper
2021-01-26 13:35   ` Jan Beulich
2021-01-29 22:08     ` Andrew Cooper
2021-01-21 21:27 ` [PATCH v7 06/10] xen/domctl: Add XEN_DOMCTL_vmtrace_op Andrew Cooper
2021-01-26 14:18   ` Jan Beulich
2021-01-29 23:01     ` Andrew Cooper
2021-01-21 21:27 ` [PATCH v7 07/10] tools/libxc: Add xc_vmtrace_* functions Andrew Cooper
2021-01-22 15:29   ` Ian Jackson
2021-01-21 21:27 ` [PATCH v7 08/10] tools/misc: Add xen-vmtrace tool Andrew Cooper
2021-01-22 15:33   ` Ian Jackson
2021-01-25 15:30     ` Andrew Cooper
2021-01-26 11:59       ` Ian Jackson
2021-01-26 12:55         ` Andrew Cooper
2021-01-26 13:32           ` Ian Jackson
2021-01-26 15:59             ` Andrew Cooper
2021-01-21 21:27 ` [PATCH v7 09/10] xen/vmtrace: support for VM forks Andrew Cooper
2021-01-26 14:21   ` Jan Beulich
2021-01-27 15:50     ` Lengyel, Tamas
2021-01-21 21:27 ` [PATCH v7 10/10] x86/vm_event: Carry Processor Trace buffer offset in vm_event Andrew Cooper
2021-01-26 14:27   ` Jan Beulich
2021-01-29 23:22     ` Andrew Cooper
2021-01-29 23:40       ` Tamas K Lengyel
2021-02-01  8:55         ` Jan Beulich
2021-02-01  9:06           ` Andrew Cooper

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=20210121212718.2441-4-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=michal.leszczynski@cert.pl \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.