Skip to contentSkip to conversation

trace_uprobe: Display correct offset in uprobe_events

PATCH In review Ravi Bangoria 4 participants 6 messages Jan 6, 2018 – Jan 19, 2018 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace_uprobe: Display correct offset in uprobe_events

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

Before patch:

  # perf probe -vv -x /tmp/a.out main
  Opening /sys/kernel/debug/tracing//uprobe_events write=1
  Writing event: p:probe_a/main /tmp/a.out:0x58c
  # cat /sys/kernel/debug/tracing/uprobe_events
  p:probe_a/main /tmp/a.out:0x0000000049a0f352

After patch:

  # cat /sys/kernel/debug/tracing/uprobe_events
  p:probe_a/main /tmp/a.out:0x000000000000058c
---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +1 -1
index 40592e7b3568..268029ae1be6 100644
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:
Signature · 1 line
2.13.6
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Ravi Bangoria

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +0 -0
index 40592e7b3568..268029ae1be6 100644

kernel/trace/trace_uprobe.c static int probes_seq_show(struct seq_file *m, void *v) · line 614

Quoted 8 lines
kernel/trace/trace_uprobe.c +1 -1
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:

Looks good to me. Did you consider %pK instead of %px?

#2 lore raw
Quoted 18 lines · Srikar Dronamraju
Quoted 16 lines · Ravi Bangoria

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +0 -0
index 40592e7b3568..268029ae1be6 100644
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
Quoted 8 lines

kernel/trace/trace_uprobe.c static int probes_seq_show(struct seq_file *m, void *v) · line 614

Quoted 7 lines
kernel/trace/trace_uprobe.c +1 -1
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:

Looks good to me. Did you consider %pK instead of %px?

Thanks Srikar,

Checked %pK. But I see same issue with that:

perf probe:
  Opening /sys/kernel/debug/tracing//uprobe_events write=1 Writing event: p:probe_a/main /tmp/a.out:0x58c

cat /sys/kernel/debug/tracing/uprobe_events:
  p:probe_a/main /tmp/a.out:0x0000000014fd571e

Quoted 1 line
#3 lore raw
Quoted 32 lines · Ravi Bangoria
Quoted 18 lines · Srikar Dronamraju
Quoted 16 lines · Ravi Bangoria

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +0 -0
index 40592e7b3568..268029ae1be6 100644
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
Quoted 8 lines

kernel/trace/trace_uprobe.c static int probes_seq_show(struct seq_file *m, void *v) · line 614

Quoted 7 lines
kernel/trace/trace_uprobe.c +1 -1
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:

Looks good to me. Did you consider %pK instead of %px?

Thanks Srikar,

Quoted 8 lines

Checked %pK. But I see same issue with that:

perf probe:
  Opening /sys/kernel/debug/tracing//uprobe_events write=1 Writing event: p:probe_a/main /tmp/a.out:0x58c

cat /sys/kernel/debug/tracing/uprobe_events:
  p:probe_a/main /tmp/a.out:0x0000000014fd571e

%pK behaves the same as %p (hashes address) when kpt_restrict==0

Hope this helps,
Tobin.

#4 lore raw
Quoted 39 lines · Tobin C. Harding
Quoted 38 lines · Ravi Bangoria
Quoted 18 lines · Srikar Dronamraju
Quoted 16 lines · Ravi Bangoria

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_uprobe.c +0 -0
index 40592e7b3568..268029ae1be6 100644
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
Quoted 8 lines

kernel/trace/trace_uprobe.c static int probes_seq_show(struct seq_file *m, void *v) · line 614

Quoted 7 lines
kernel/trace/trace_uprobe.c +1 -1
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:

Looks good to me. Did you consider %pK instead of %px?

Thanks Srikar,

Checked %pK. But I see same issue with that:

perf probe:
  Opening /sys/kernel/debug/tracing//uprobe_events write=1 Writing event: p:probe_a/main /tmp/a.out:0x58c

Quoted 6 lines
Quoted 2 lines

cat /sys/kernel/debug/tracing/uprobe_events:
  p:probe_a/main /tmp/a.out:0x0000000014fd571e

%pK behaves the same as %p (hashes address) when kpt_restrict==0

Hope this helps,

Thanks Tobin for the clarification. So %px is the right choice.

Signature · 2 lines
thanks and regards
Srikar
maintainer
#5 lore raw
In reply to Ravi Bangoria
Quoted 11 lines · On Sat, 6 Jan 2018 11:12:46 +0530 Ravi Bangoria…

Recently, how the pointers being printed with %p has been changed by commit ad67b74d2469 ("printk: hash addresses printed with %p"). This is causing a regression while showing offset in the uprobe_events file. Instead of %p, use %px to display offset.

Before patch:

  # perf probe -vv -x /tmp/a.out main
  Opening /sys/kernel/debug/tracing//uprobe_events write=1
  Writing event: p:probe_a/main /tmp/a.out:0x58c
Quoted 8 lines
  # cat /sys/kernel/debug/tracing/uprobe_events
  p:probe_a/main /tmp/a.out:0x0000000049a0f352

After patch:

  # cat /sys/kernel/debug/tracing/uprobe_events
  p:probe_a/main /tmp/a.out:0x000000000000058c

Thanks, I'll pull this into my tree.

-- Steve