From: Slavomir Kaslev <kaslevs@vmware.com>
To: linux-trace-devel@vger.kernel.org
Cc: rostedt@goodmis.org, slavomir.kaslev@gmail.com
Subject: [RFC PATCH v8 06/13] trace-cmd: Add buffer instance flags for tracing in guest and agent context
Date: Fri, 22 Feb 2019 20:05:32 +0200 [thread overview]
Message-ID: <20190222180539.27439-7-kaslevs@vmware.com> (raw)
In-Reply-To: <20190222180539.27439-1-kaslevs@vmware.com>
Add BUFFER_FL_GUEST and BUFFER_FL_AGENT flags to differentiate when
trace-record.c is being called to trace guest or the VM tracing agent.
Also disable functions talking to the local tracefs when called in recording
guest instances context.
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
---
tracecmd/include/trace-local.h | 5 ++++
tracecmd/trace-record.c | 55 ++++++++++++++++++++++++++++++++--
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index a1a06e9..f43c9d8 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -149,6 +149,8 @@ char *strstrip(char *str);
enum buffer_instance_flags {
BUFFER_FL_KEEP = 1 << 0,
BUFFER_FL_PROFILE = 1 << 1,
+ BUFFER_FL_GUEST = 1 << 2,
+ BUFFER_FL_AGENT = 1 << 3,
};
struct func_list {
@@ -198,6 +200,9 @@ extern struct buffer_instance *first_instance;
#define for_all_instances(i) for (i = first_instance; i; \
i = i == &top_instance ? buffer_instances : (i)->next)
+#define is_agent(instance) ((instance)->flags & BUFFER_FL_AGENT)
+#define is_guest(instance) ((instance)->flags & BUFFER_FL_GUEST)
+
struct buffer_instance *create_instance(const char *name);
void add_instance(struct buffer_instance *instance, int cpu_count);
char *get_instance_file(struct buffer_instance *instance, const char *file);
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 88b4a55..69c8d67 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -781,6 +781,9 @@ static void __clear_trace(struct buffer_instance *instance)
FILE *fp;
char *path;
+ if (is_guest(instance))
+ return;
+
/* reset the trace */
path = get_instance_file(instance, "trace");
fp = fopen(path, "w");
@@ -1264,6 +1267,9 @@ set_plugin_instance(struct buffer_instance *instance, const char *name)
char *path;
char zero = '0';
+ if (is_guest(instance))
+ return;
+
path = get_instance_file(instance, "current_tracer");
fp = fopen(path, "w");
if (!fp) {
@@ -1360,6 +1366,9 @@ static void disable_func_stack_trace_instance(struct buffer_instance *instance)
int size;
int ret;
+ if (is_guest(instance))
+ return;
+
path = get_instance_file(instance, "current_tracer");
ret = stat(path, &st);
tracecmd_put_tracing_file(path);
@@ -1553,6 +1562,9 @@ reset_events_instance(struct buffer_instance *instance)
int i;
int ret;
+ if (is_guest(instance))
+ return;
+
if (use_old_event_method()) {
/* old way only had top instance */
if (!is_top_instance(instance))
@@ -1904,6 +1916,9 @@ static void write_tracing_on(struct buffer_instance *instance, int on)
int ret;
int fd;
+ if (is_guest(instance))
+ return;
+
fd = open_tracing_on(instance);
if (fd < 0)
return;
@@ -1923,6 +1938,9 @@ static int read_tracing_on(struct buffer_instance *instance)
char buf[10];
int ret;
+ if (is_guest(instance))
+ return -1;
+
fd = open_tracing_on(instance);
if (fd < 0)
return fd;
@@ -2156,6 +2174,9 @@ static void set_mask(struct buffer_instance *instance)
int fd;
int ret;
+ if (is_guest(instance))
+ return;
+
if (!instance->cpumask)
return;
@@ -2186,6 +2207,9 @@ static void enable_events(struct buffer_instance *instance)
{
struct event_list *event;
+ if (is_guest(instance))
+ return;
+
for (event = instance->events; event; event = event->next) {
if (!event->neg)
update_event(event, event->filter, 0, '1');
@@ -2209,6 +2233,9 @@ static void set_clock(struct buffer_instance *instance)
char *content;
char *str;
+ if (is_guest(instance))
+ return;
+
if (!instance->clock)
return;
@@ -2238,6 +2265,9 @@ static void set_max_graph_depth(struct buffer_instance *instance, char *max_grap
char *path;
int ret;
+ if (is_guest(instance))
+ return;
+
path = get_instance_file(instance, "max_graph_depth");
reset_save_file(path, RESET_DEFAULT_PRIO);
tracecmd_put_tracing_file(path);
@@ -2463,6 +2493,9 @@ static void expand_event_instance(struct buffer_instance *instance)
struct event_list *compressed_list = instance->events;
struct event_list *event;
+ if (is_guest(instance))
+ return;
+
reset_event_list(instance);
while (compressed_list) {
@@ -3337,6 +3370,9 @@ static void set_funcs(struct buffer_instance *instance)
int set_notrace = 0;
int ret;
+ if (is_guest(instance))
+ return;
+
ret = write_func_file(instance, "set_ftrace_filter", &instance->filter_funcs);
if (ret < 0)
die("set_ftrace_filter does not exist. Can not filter functions");
@@ -3633,6 +3669,9 @@ static void set_buffer_size_instance(struct buffer_instance *instance)
int ret;
int fd;
+ if (is_guest(instance))
+ return;
+
if (!buffer_size)
return;
@@ -3830,6 +3869,9 @@ static void make_instances(void)
int ret;
for_each_instance(instance) {
+ if (is_guest(instance))
+ continue;
+
path = get_instance_dir(instance);
ret = stat(path, &st);
if (ret < 0) {
@@ -3851,7 +3893,7 @@ void tracecmd_remove_instances(void)
for_each_instance(instance) {
/* Only delete what we created */
- if (instance->flags & BUFFER_FL_KEEP)
+ if (is_guest(instance) || (instance->flags & BUFFER_FL_KEEP))
continue;
if (instance->tracing_on_fd > 0) {
close(instance->tracing_on_fd);
@@ -3933,7 +3975,7 @@ static void check_function_plugin(void)
static int __check_doing_something(struct buffer_instance *instance)
{
- return (instance->flags & BUFFER_FL_PROFILE) ||
+ return is_guest(instance) || (instance->flags & BUFFER_FL_PROFILE) ||
instance->plugin || instance->events;
}
@@ -3955,6 +3997,9 @@ update_plugin_instance(struct buffer_instance *instance,
{
const char *plugin = instance->plugin;
+ if (is_guest(instance))
+ return;
+
if (!plugin)
return;
@@ -4054,6 +4099,9 @@ static void record_stats(void)
int cpu;
for_all_instances(instance) {
+ if (is_guest(instance))
+ continue;
+
s_save = instance->s_save;
s_print = instance->s_print;
for (cpu = 0; cpu < instance->cpu_count; cpu++) {
@@ -4080,6 +4128,9 @@ static void destroy_stats(void)
int cpu;
for_all_instances(instance) {
+ if (is_guest(instance))
+ continue;
+
for (cpu = 0; cpu < instance->cpu_count; cpu++) {
trace_seq_destroy(&instance->s_save[cpu]);
trace_seq_destroy(&instance->s_print[cpu]);
--
2.19.1
next prev parent reply other threads:[~2019-02-22 18:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 18:05 [RFC PATCH v8 00/13] Add VM kernel tracing over vsockets and FIFOs Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 01/13] trace-cmd: Minor cleanup in tracecmd_start_recording() Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 02/13] trace-cmd: Minor cleanup in print_stat() Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 03/13] trace-cmd: Detect if vsockets are available Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 04/13] trace-cmd: Add tracecmd_create_recorder_virt function Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 05/13] trace-cmd: Add TRACE_REQ and TRACE_RESP messages Slavomir Kaslev
2019-02-22 21:09 ` Steven Rostedt
2019-03-12 18:48 ` Slavomir Kaslev
2019-03-12 19:18 ` Steven Rostedt
2019-02-22 18:05 ` Slavomir Kaslev [this message]
2019-02-22 18:05 ` [RFC PATCH v8 07/13] trace-cmd: Add VM kernel tracing over vsockets transport Slavomir Kaslev
2019-03-12 19:23 ` Steven Rostedt
2019-03-12 23:07 ` Steven Rostedt
2019-02-22 18:05 ` [RFC PATCH v8 08/13] trace-cmd: Use splice(2) for vsockets if available Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 09/13] trace-cmd: Add `trace-cmd setup-guest` command Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 10/13] trace-cmd: Try to autodetect number of guest CPUs in setup-guest if not specified Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 11/13] trace-cmd: Add setup-guest flag for attaching FIFOs to the guest VM config Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 12/13] trace-cmd: Add splice() recording from FIFO without additional pipe buffer Slavomir Kaslev
2019-02-22 18:05 ` [RFC PATCH v8 13/13] trace-cmd: Add VM tracing over FIFOs transport Slavomir Kaslev
2019-03-12 19:28 ` Steven Rostedt
2019-04-02 13:42 [RFC PATCH v8 00/11] Add VM kernel tracing over vsockets and FIFOs Slavomir Kaslev
2019-04-02 13:42 ` [RFC PATCH v8 06/13] trace-cmd: Add buffer instance flags for tracing in guest and agent context Slavomir Kaslev
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=20190222180539.27439-7-kaslevs@vmware.com \
--to=kaslevs@vmware.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=slavomir.kaslev@gmail.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).