Skip to contentSkip to conversation

selftests: ftrace: Fix multiple-kprobe testcase

PATCH RESEND In review Masami Hiramatsu 3 participants 5 messages Jan 14, 2018 – Jan 16, 2018

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

cover selftests: ftrace: Fix multiple-kprobe testcase

Hi,

These patches are fixing a bug and improve testcase to ensure adding 256 kprobe events for test.

I've just updated to the latest kselftest/master branch.

Thank you,

---

Masami Hiramatsu (2):
[BUGFIX] selftest: ftrace: Fix to pick text symbols for kprobes
selftest: ftrace: Fix to add 256 kprobe events correctly

 .../ftrace/test.d/kprobe/multiple_kprobes.tc       |   21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

author maintainer
#1 lore raw

PATCH RESEND 1/2 selftest: ftrace: Fix to pick text symbols for kprobes

Fix to pick text symbols for multiple kprobe testcase. kallsyms shows text symbols with " t " or " T " but current testcase picks all symbols including "t", so it picks data symbols if it includes 't' (e.g. "str").

This fixes it to find symbol lines with " t " or " T " (including spaces).

---
 .../ftrace/test.d/kprobe/multiple_kprobes.tc       |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +2 -2
index bb16cf91f1b5..e297bd7a2e79 100644
@@ -12,8 +12,8 @@ case `uname -m` in
   *) OFFS=0;;
 esac
 
-echo "Setup up to 256 kprobes"
-grep t /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \
+echo "Setup up kprobes on first 256 text symbols"
+grep -i " t " /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \
 head -n 256 | while read i; do echo p ${i}+${OFFS} ; done > kprobe_events ||:
 
 echo 1 > events/kprobes/enable
author maintainer
#2 lore raw

PATCH RESEND 2/2 selftest: ftrace: Fix to add 256 kprobe events correctly

In reply to Masami Hiramatsu

Current multiple-kprobe testcase only tries to add kprobe events on first 256 text symbols. However kprobes fails to probe on some text symbols (like blacklisted symbols). Thus in the worst case, the test can not add any kprobe events.

To avoid that, continue to try adding kprobe events until 256 events. Also it confirms the number of registered kprobe events.

---
 .../ftrace/test.d/kprobe/multiple_kprobes.tc       |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +17 -2
index e297bd7a2e79..ce361b9d62cf 100644
@@ -12,9 +12,24 @@ case `uname -m` in
   *) OFFS=0;;
 esac
 
-echo "Setup up kprobes on first 256 text symbols"
+if [ -d events/kprobes ]; then
+  echo 0 > events/kprobes/enable
+  echo > kprobe_events
+fi
+
+N=0
+echo "Setup up kprobes on first available 256 text symbols"
 grep -i " t " /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \
-head -n 256 | while read i; do echo p ${i}+${OFFS} ; done > kprobe_events ||:
+while read i; do
+  echo p ${i}+${OFFS} >> kprobe_events && N=$((N+1)) ||:
+  test $N -eq 256 && break
+done
+
+L=`wc -l kprobe_events`
+if [ $L -ne $N ]; then
+  echo "The number of kprobes events ($L) is not $N"
+  exit_fail
+fi
 
 echo 1 > events/kprobes/enable
 echo 0 > events/kprobes/enable
maintainer Acked-by on the v1 series
#3 lore raw
In reply to Masami Hiramatsu

Shuah,

Want to take these in your tree? You can add:

-- Steve

Quoted 21 lines · On Sun, 14 Jan 2018 22:49:37 +0900 Masami Hiramatsu <[email protected]> wrote:

Hi,

These patches are fixing a bug and improve testcase to ensure adding 256 kprobe events for test.

I've just updated to the latest kselftest/master branch.

Thank you,

---

Masami Hiramatsu (2):
[BUGFIX] selftest: ftrace: Fix to pick text symbols for kprobes
selftest: ftrace: Fix to add 256 kprobe events correctly

 .../ftrace/test.d/kprobe/multiple_kprobes.tc       |   21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

maintainer
#4 lore raw
Quoted 8 lines · Steven Rostedt

Shuah,

Want to take these in your tree? You can add:

Acked-by Steven Rostedt (VMware) <rostedt at goodmis.org>

-- Steve

Thanks. 2 patches in the series are now in linux-kselftest next with Steve's Acked-by

thanks,
-- Shuah

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html