From: Tom Zanussi <zanussi@kernel.org>
To: rostedt@goodmis.org
Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org,
bigeasy@linutronix.de, joel@joelfernandes.org,
linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: [RFC PATCH v2 4/5] tracing: Use tracing error_log with kprobe events (incomplete)
Date: Wed, 13 Feb 2019 12:17:55 -0600 [thread overview]
Message-ID: <db931dea3818fb79a710f7b83cb53b06cf565de1.1550074795.git.tom.zanussi@linux.intel.com> (raw)
In-Reply-To: <cover.1550074795.git.tom.zanussi@linux.intel.com>
In-Reply-To: <cover.1550074795.git.tom.zanussi@linux.intel.com>
From: Tom Zanussi <tom.zanussi@linux.intel.com>
Here are a few examples of replacing kprobe_events error handling with
tracing_log_err() from the new tracing error_log mechanism. Only a
few example errors are converted, and even these are incomplete, since
I didn't know where to get the current command and used a dummy string
for those. Also, these are completely untested, just provided for
RFC purposes.
With this change, users will find some kprobe_events errors in
tracing/error_log instead of dmesg.
TODO: If acceptable, convert all the rest of the kprobe errors and
figure out how to get the actual cmd logged along with the error.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
kernel/trace/trace_probe.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 9962cb5da8ac..3d7b195c943b 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -13,6 +13,22 @@
#include "trace_probe.h"
+#define ERRORS \
+ C(NONE, "No error"), \
+ C(INVALID_STRING_SPEC, "string only accepts memory or address."), \
+ C(ARG_TOO_LONG, "Argument is too long."), \
+ C(INVALID_ARG_NAME, "Invalid argument name"),
+
+#undef C
+#define C(a, b) KPROBE_ERR_##a
+
+enum { ERRORS };
+
+#undef C
+#define C(a, b) b
+
+static const char *err_text[] = { ERRORS };
+
const char *reserved_field_names[] = {
"common_type",
"common_flags",
@@ -384,7 +400,7 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
int ret, len;
if (strlen(arg) > MAX_ARGSTR_LEN) {
- pr_info("Argument is too long.: %s\n", arg);
+ tracing_log_err("kprobe_events", "replace this with command", err_text, KPROBE_ERR_ARG_TOO_LONG, err_pos("command", arg));
return -ENOSPC;
}
parg->comm = kstrdup(arg, GFP_KERNEL);
@@ -443,7 +459,8 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
if (!strcmp(parg->type->name, "string")) {
if (code->op != FETCH_OP_DEREF && code->op != FETCH_OP_IMM &&
code->op != FETCH_OP_COMM) {
- pr_info("string only accepts memory or address.\n");
+ tracing_log_err("kprobe_events", "replace this with command", err_text, KPROBE_ERR_INVALID_STRING_SPEC, 0);
+
ret = -EINVAL;
goto fail;
}
@@ -558,8 +575,7 @@ int traceprobe_parse_probe_arg(struct trace_probe *tp, int i, char *arg,
return -ENOMEM;
if (!is_good_name(parg->name)) {
- pr_info("Invalid argument[%d] name: %s\n",
- i, parg->name);
+ tracing_log_err("kprobe_events", "replace this with command", err_text, KPROBE_ERR_INVALID_ARG_NAME, err_pos("cmd", parg->name));
return -EINVAL;
}
--
2.14.1
next prev parent reply other threads:[~2019-02-13 18:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-13 18:17 [RFC PATCH v2 0/5] tracing: common error_log for ftrace Tom Zanussi
2019-02-13 18:17 ` [RFC PATCH v2 1/5] tracing: Add tracing error log Tom Zanussi
2019-02-13 18:17 ` [RFC PATCH v2 2/5] tracing: Save the last hist command's associated event name Tom Zanussi
2019-02-13 18:17 ` [RFC PATCH v2 3/5] tracing: Use tracing error_log with hist triggers Tom Zanussi
2019-02-13 18:17 ` Tom Zanussi [this message]
2019-02-14 3:13 ` [RFC PATCH v2 4/5] tracing: Use tracing error_log with kprobe events (incomplete) Masami Hiramatsu
2019-02-14 15:16 ` Tom Zanussi
2019-02-13 18:17 ` [RFC PATCH v2 5/5] tracing: Use tracing error_log with trace event filters Tom Zanussi
2019-02-13 18:27 ` [RFC PATCH v2 0/5] tracing: common error_log for ftrace Steven Rostedt
2019-02-14 3:13 ` Masami Hiramatsu
2019-02-14 15:15 ` Tom Zanussi
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=db931dea3818fb79a710f7b83cb53b06cf565de1.1550074795.git.tom.zanussi@linux.intel.com \
--to=zanussi@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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).