Skip to contentSkip to conversation

tracing/probes: Fix a warning message to show correct maximum length

PATCH Superseded Masami Hiramatsu 3 participants 5 messages Feb 7, 2017 – Feb 14, 2017 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

PATCH 1/1 tracing/probes: Fix a warning message to show correct maximum length

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +2 -1
index 8c0553d..7138fea 100644
@@ -673,8 +673,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			*tmp = '\0';
 			size = tmp - kbuf + 1;
 		} else if (done + size < count) {
+			/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
+				WRITE_BUFSIZE - 2);
 			ret = -EINVAL;
 			goto out;
 		}
#1 lore raw
Quoted 14 lines · Masami Hiramatsu

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +0 -0
index 8c0553d..7138fea 100644

kernel/trace/trace_probe.c ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer, · line 678

Quoted 7 lines
kernel/trace/trace_probe.c +2 -1
@@ -673,8 +673,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			*tmp = '\0';
 			size = tmp - kbuf + 1;
 		} else if (done + size < count) {
+			/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
+				WRITE_BUFSIZE - 2);

The message should also indicate which kernel subsystem generated it - which is useful if the message is not immediately noticed in the kernel log.

You can do this by having something like this at the top of the trace_probe file:

  #define pr_fmt(fmt) "trace_probe: " fmt

Thanks,

Ingo

author maintainer
#2 lore raw
Quoted 28 lines · On Tue, 7 Feb 2017 08:41:48 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 14 lines · Masami Hiramatsu

Since tracing/*probe_events will accept a probe definition up to 4096 - 2 ('\n' and '\0') bytes, it must show 4094 instead of 4096 in warning message.

---
 kernel/trace/trace_probe.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +0 -0
index 8c0553d..7138fea 100644

kernel/trace/trace_probe.c ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer, · line 678

Quoted 7 lines
kernel/trace/trace_probe.c +2 -1
@@ -673,8 +673,9 @@ ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer,
 			*tmp = '\0';
 			size = tmp - kbuf + 1;
 		} else if (done + size < count) {
+			/* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */
 			pr_warn("Line length is too long: Should be less than %d\n",
-				WRITE_BUFSIZE);
+				WRITE_BUFSIZE - 2);

The message should also indicate which kernel subsystem generated it - which is useful if the message is not immediately noticed in the kernel log.

Quoted 3 lines

You can do this by having something like this at the top of the trace_probe file:

  #define pr_fmt(fmt) "trace_probe: " fmt

Ah, I got it. I'll make a separate patch for that.

Thank you!

Signature · 1 line
Masami Hiramatsu <[email protected]>
author maintainer
#3 lore raw

PATCH 1/1 tracing/probe: Show subsystem name in messages

In reply to Ingo Molnar

Show "trace_probe:", "trace_kprobe:" and "trace_uprobe:" headers for each warning/error/info message. This will help people to notice that kprobe/uprobe events caused those messages.

---
 kernel/trace/trace_kprobe.c |    1 +
 kernel/trace/trace_probe.c  |    1 +
 kernel/trace/trace_uprobe.c |    1 +
 3 files changed, 3 insertions(+)
kernel/trace/trace_kprobe.c +1 -0
index d3729bd..5f688cc 100644
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
kernel/trace/trace_probe.c +1 -0
index 7138fea..eda3a45 100644
@@ -21,6 +21,7 @@
  * Copyright (C) IBM Corporation, 2010-2011
  * Author:     Srikar Dronamraju
  */
+#define pr_fmt(fmt)	"trace_probe: " fmt
 
 #include "trace_probe.h"
 
kernel/trace/trace_uprobe.c +1 -0
index e5445ab..2c6b2d0c 100644
@@ -17,6 +17,7 @@
  * Copyright (C) IBM Corporation, 2010-2012
  * Author:	Srikar Dronamraju <[email protected]>
  */
+#define pr_fmt(fmt)	"trace_kprobe: " fmt
 
 #include <linux/module.h>
 #include <linux/uaccess.h>
maintainer Applied
#4 lore raw

Re: [PATCH tip/master] tracing/probe: Show subsystem name in messages

Quoted 6 lines · On Tue, 7 Feb 2017 20:21:28 +0900 Masami Hiramatsu <[email protected]> wrote:

Show "trace_probe:", "trace_kprobe:" and "trace_uprobe:" headers for each warning/error/info message. This will help people to notice that kprobe/uprobe events caused those messages.

Applied. Thanks!

-- Steve