rteval-loads/SOURCES/0017-core-ftrace-remove-set...

91 lines
2.8 KiB
Diff

From 5dfc5ed3e0d92507e482529aae21090278fbd677 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 08:25:43 +0100
Subject: [PATCH 17/28] core-ftrace: remove setting of set_event_pid and
refactor code
Some of the ftrace settings were extraneous, remove these down to the
bare minimum required for ftrace to be enabled.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-ftrace.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/core-ftrace.c b/core-ftrace.c
index a612d5701315..d759ec8988e0 100644
--- a/core-ftrace.c
+++ b/core-ftrace.c
@@ -242,12 +242,12 @@ static int stress_ftrace_parse_stat_files(const char *path, const bool start)
}
/*
- * stress_ftrace_set_pid_file()
+ * stress_ftrace_add_pid()
* enable/append/stop tracing on specific events.
* if pid < 0 then tracing pids are all removed otherwise
* the pid is added to the tracing events
*/
-static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
+void stress_ftrace_add_pid(const pid_t pid)
{
char filename[PATH_MAX];
char *path;
@@ -255,11 +255,14 @@ static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
int fd;
ssize_t ret;
+ if (!(g_opt_flags & OPT_FLAGS_FTRACE))
+ return;
+
path = stress_ftrace_get_debugfs_path();
if (!path)
return;
- (void)snprintf(filename, sizeof(filename), "%s/tracing/%s", path, file);
+ (void)snprintf(filename, sizeof(filename), "%s/tracing/set_ftrace_pid", path);
fd = open(filename, O_WRONLY | (pid < 0 ? O_TRUNC : O_APPEND));
if (fd < 0)
return;
@@ -273,15 +276,6 @@ static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
(void)close(fd);
}
-void stress_ftrace_add_pid(const pid_t pid)
-{
- if (!(g_opt_flags & OPT_FLAGS_FTRACE))
- return;
-
- stress_ftrace_set_pid_file(pid, "set_event_pid");
- stress_ftrace_set_pid_file(pid, "set_ftrace_pid");
-}
-
/*
* stress_ftrace_start()
* start ftracing function calls
@@ -306,13 +300,6 @@ int stress_ftrace_start(void)
return -1;
}
- (void)snprintf(filename, sizeof(filename), "%s/tracing/current_tracer", path);
- if (system_write(filename, "nop", 3) < 0) {
- pr_inf("ftrace: cannot disable the current tracer, errno=%d (%s)\n",
- errno, strerror(errno));
- return -1;
- }
- (void)snprintf(filename, sizeof(filename), "%s/tracing/function_profile_enabled", path);
if (system_write(filename, "0", 1) < 0) {
pr_inf("ftrace: cannot enable function profiling, errno=%d (%s)\n",
errno, strerror(errno));
@@ -407,7 +394,6 @@ int stress_ftrace_stop(void)
}
(void)snprintf(filename, sizeof(filename), "%s/tracing/trace_stat", path);
-
if (stress_ftrace_parse_stat_files(path, false) < 0)
return -1;
stress_ftrace_analyze();
--
2.21.3