From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [for-next][PATCH 10/19] tracing: Have the error logs show up in the proper instances
Date: Wed, 03 Apr 2019 21:37:31 -0400 [thread overview]
Message-ID: <20190404013744.737564971@goodmis.org> (raw)
In-Reply-To: 20190404013721.023858792@goodmis.org
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
As each instance has their own error_log file, it makes more sense that the
instances show the errors of their own instead of all error_logs having the
same data. Make it that the errors show up in the instance error_log file
that the error happens in. If no instance trace_array is available, then
NULL can be passed in which will create the error in the top level instance
(the one at the top of the tracefs directory).
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 55 ++++++++++++++++++++----------
kernel/trace/trace.h | 5 ++-
kernel/trace/trace_events_filter.c | 4 +--
kernel/trace/trace_events_hist.c | 3 +-
kernel/trace/trace_probe.c | 2 +-
5 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7978168f5041..3d55e9daae8c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6897,25 +6897,22 @@ struct tracing_log_err {
char cmd[MAX_FILTER_STR_VAL]; /* what caused err */
};
-static LIST_HEAD(tracing_err_log);
static DEFINE_MUTEX(tracing_err_log_lock);
-static unsigned int n_tracing_err_log_entries;
-
-struct tracing_log_err *get_tracing_log_err(void)
+struct tracing_log_err *get_tracing_log_err(struct trace_array *tr)
{
struct tracing_log_err *err;
- if (n_tracing_err_log_entries < TRACING_LOG_ERRS_MAX) {
+ if (tr->n_err_log_entries < TRACING_LOG_ERRS_MAX) {
err = kzalloc(sizeof(*err), GFP_KERNEL);
if (!err)
err = ERR_PTR(-ENOMEM);
- n_tracing_err_log_entries++;
+ tr->n_err_log_entries++;
return err;
}
- err = list_first_entry(&tracing_err_log, struct tracing_log_err, list);
+ err = list_first_entry(&tr->err_log, struct tracing_log_err, list);
list_del(&err->list);
return err;
@@ -6949,6 +6946,7 @@ unsigned int err_pos(char *cmd, const char *str)
/**
* tracing_log_err - write an error to the tracing error log
+ * @tr: The associated trace array for the error (NULL for top level array)
* @loc: A string describing where the error occurred
* @cmd: The tracing command that caused the error
* @errs: The array of loc-specific static error strings
@@ -6973,13 +6971,17 @@ unsigned int err_pos(char *cmd, const char *str)
* existing callers for examples of how static strings are typically
* defined for use with tracing_log_err().
*/
-void tracing_log_err(const char *loc, const char *cmd,
+void tracing_log_err(struct trace_array *tr,
+ const char *loc, const char *cmd,
const char **errs, u8 type, u8 pos)
{
struct tracing_log_err *err;
+ if (!tr)
+ tr = &global_trace;
+
mutex_lock(&tracing_err_log_lock);
- err = get_tracing_log_err();
+ err = get_tracing_log_err(tr);
if (PTR_ERR(err) == -ENOMEM) {
mutex_unlock(&tracing_err_log_lock);
return;
@@ -6993,34 +6995,38 @@ void tracing_log_err(const char *loc, const char *cmd,
err->info.pos = pos;
err->info.ts = local_clock();
- list_add_tail(&err->list, &tracing_err_log);
+ list_add_tail(&err->list, &tr->err_log);
mutex_unlock(&tracing_err_log_lock);
}
-static void clear_tracing_err_log(void)
+static void clear_tracing_err_log(struct trace_array *tr)
{
struct tracing_log_err *err, *next;
mutex_lock(&tracing_err_log_lock);
- list_for_each_entry_safe(err, next, &tracing_err_log, list) {
+ list_for_each_entry_safe(err, next, &tr->err_log, list) {
list_del(&err->list);
kfree(err);
}
- n_tracing_err_log_entries = 0;
+ tr->n_err_log_entries = 0;
mutex_unlock(&tracing_err_log_lock);
}
static void *tracing_err_log_seq_start(struct seq_file *m, loff_t *pos)
{
+ struct trace_array *tr = m->private;
+
mutex_lock(&tracing_err_log_lock);
- return seq_list_start(&tracing_err_log, *pos);
+ return seq_list_start(&tr->err_log, *pos);
}
static void *tracing_err_log_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
- return seq_list_next(v, &tracing_err_log, pos);
+ struct trace_array *tr = m->private;
+
+ return seq_list_next(v, &tr->err_log, pos);
}
static void tracing_err_log_seq_stop(struct seq_file *m, void *v)
@@ -7067,15 +7073,25 @@ static const struct seq_operations tracing_err_log_seq_ops = {
static int tracing_err_log_open(struct inode *inode, struct file *file)
{
+ struct trace_array *tr = inode->i_private;
int ret = 0;
+ if (trace_array_get(tr) < 0)
+ return -ENODEV;
+
/* If this file was opened for write, then erase contents */
if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC))
- clear_tracing_err_log();
+ clear_tracing_err_log(tr);
- if (file->f_mode & FMODE_READ)
+ if (file->f_mode & FMODE_READ) {
ret = seq_open(file, &tracing_err_log_seq_ops);
-
+ if (!ret) {
+ struct seq_file *m = file->private_data;
+ m->private = tr;
+ } else {
+ trace_array_put(tr);
+ }
+ }
return ret;
}
@@ -7091,6 +7107,7 @@ static const struct file_operations tracing_err_log_fops = {
.write = tracing_err_log_write,
.read = seq_read,
.llseek = seq_lseek,
+ .release = tracing_release_generic_tr,
};
static int tracing_buffers_open(struct inode *inode, struct file *filp)
@@ -8293,6 +8310,7 @@ struct trace_array *trace_array_create(const char *name)
INIT_LIST_HEAD(&tr->systems);
INIT_LIST_HEAD(&tr->events);
INIT_LIST_HEAD(&tr->hist_vars);
+ INIT_LIST_HEAD(&tr->err_log);
if (allocate_trace_buffers(tr, trace_buf_size) < 0)
goto out_free_tr;
@@ -9087,6 +9105,7 @@ __init static int tracer_alloc_buffers(void)
INIT_LIST_HEAD(&global_trace.systems);
INIT_LIST_HEAD(&global_trace.events);
INIT_LIST_HEAD(&global_trace.hist_vars);
+ INIT_LIST_HEAD(&global_trace.err_log);
list_add(&global_trace.list, &ftrace_trace_arrays);
apply_trace_boot_options();
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 809c5d7f0064..da00a3d508c1 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -293,11 +293,13 @@ struct trace_array {
int nr_topts;
bool clear_trace;
int buffer_percent;
+ unsigned int n_err_log_entries;
struct tracer *current_trace;
unsigned int trace_flags;
unsigned char trace_flags_index[TRACE_FLAGS_MAX_SIZE];
unsigned int flags;
raw_spinlock_t start_lock;
+ struct list_head err_log;
struct dentry *dir;
struct dentry *options;
struct dentry *percpu_dir;
@@ -1886,7 +1888,8 @@ extern ssize_t trace_parse_run_command(struct file *file,
int (*createfn)(int, char**));
extern unsigned int err_pos(char *cmd, const char *str);
-extern void tracing_log_err(const char *loc, const char *cmd,
+extern void tracing_log_err(struct trace_array *tr,
+ const char *loc, const char *cmd,
const char **errs, u8 type, u8 pos);
/*
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 2b63930cd3e6..180ecb390baa 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -949,12 +949,12 @@ static void append_filter_err(struct trace_array *tr,
if (pe->lasterr > 0) {
trace_seq_printf(s, "\n%*s", pos, "^");
trace_seq_printf(s, "\nparse_error: %s\n", err_text[pe->lasterr]);
- tracing_log_err("event filter parse error",
+ tracing_log_err(tr, "event filter parse error",
filter->filter_string, err_text,
pe->lasterr, pe->lasterr_pos);
} else {
trace_seq_printf(s, "\nError: (%d)\n", pe->lasterr);
- tracing_log_err("event filter parse error",
+ tracing_log_err(tr, "event filter parse error",
filter->filter_string, err_text,
FILT_ERR_ERRNO, 0);
}
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index a167e439e9a1..a1136e043f17 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -621,7 +621,8 @@ static void last_cmd_set(struct trace_event_file *file, char *str)
static void hist_err(struct trace_array *tr, u8 err_type, u8 err_pos)
{
- tracing_log_err(last_cmd_loc, last_cmd, err_text, err_type, err_pos);
+ tracing_log_err(tr, last_cmd_loc, last_cmd, err_text,
+ err_type, err_pos);
}
static void hist_err_clear(void)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index e11f98c49d72..4cc2d467d34c 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -186,7 +186,7 @@ void __trace_probe_log_err(int offset, int err_type)
}
*(p - 1) = '\0';
- tracing_log_err(trace_probe_log.subsystem, command,
+ tracing_log_err(NULL, trace_probe_log.subsystem, command,
trace_probe_err_text, err_type, pos + offset);
kfree(command);
--
2.20.1
next prev parent reply other threads:[~2019-04-04 1:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 1:37 [for-next][PATCH 00/19] tracing: Updates for 5.2 Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 01/19] ring-buffer: Fix ring buffer size in rb_write_something() Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 03/19] tracing: Add tracing error log Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 04/19] tracing: Save the last hist commands associated event name Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 05/19] tracing: Use tracing error_log with hist triggers Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 06/19] tracing: Use tracing error_log with trace event filters Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 07/19] tracing: Use tracing error_log with probe events Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 08/19] tracing: Add trace_array parameter to create_event_filter() Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 09/19] tracing: Have histogram code pass around trace_array for error handling Steven Rostedt
2019-04-04 1:37 ` Steven Rostedt [this message]
2019-04-04 1:37 ` [for-next][PATCH 11/19] selftests/ftrace: Add error_log testcase for probe errors Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 12/19] selftests/ftrace: Move kprobe/uprobe check_error() to test.d/functions Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 13/19] selftests/ftrace: Remove trigger-extended-error-support testcase Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 14/19] selftests/ftrace: Add tracing/error_log testcase Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 15/19] tracing: Add tracing/error_log Documentation Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 16/19] tracing: Add error_log to README Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 17/19] tracing: introduce TRACE_EVENT_NOP() Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 18/19] sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set Steven Rostedt
2019-04-04 1:37 ` [for-next][PATCH 19/19] rcu: validate arguments for rcu tracepoints Steven Rostedt
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=20190404013744.737564971@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tom.zanussi@linux.intel.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).