Skip to content

Commit 3539d09

Browse files
mhiramatIngo Molnar
authored andcommitted
kprobes: Improve smoke test to check preemptibility
Add preemptible check to each handler. Handlers are called with non-preemtible, which is guaranteed by Documentation/kprobes.txt. Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E . McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/150581513991.32348.7956810394499654272.stgit@devbox Signed-off-by: Ingo Molnar <[email protected]>
1 parent a8976fc commit 3539d09

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

kernel/test_kprobes.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ static noinline u32 kprobe_target(u32 value)
3434

3535
static int kp_pre_handler(struct kprobe *p, struct pt_regs *regs)
3636
{
37+
if (preemptible()) {
38+
handler_errors++;
39+
pr_err("pre-handler is preemptible\n");
40+
}
3741
preh_val = (rand1 / div_factor);
3842
return 0;
3943
}
4044

4145
static void kp_post_handler(struct kprobe *p, struct pt_regs *regs,
4246
unsigned long flags)
4347
{
48+
if (preemptible()) {
49+
handler_errors++;
50+
pr_err("post-handler is preemptible\n");
51+
}
4452
if (preh_val != (rand1 / div_factor)) {
4553
handler_errors++;
4654
pr_err("incorrect value in post_handler\n");
@@ -156,6 +164,10 @@ static int test_kprobes(void)
156164

157165
static u32 j_kprobe_target(u32 value)
158166
{
167+
if (preemptible()) {
168+
handler_errors++;
169+
pr_err("jprobe-handler is preemptible\n");
170+
}
159171
if (value != rand1) {
160172
handler_errors++;
161173
pr_err("incorrect value in jprobe handler\n");
@@ -232,6 +244,10 @@ static u32 krph_val;
232244

233245
static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
234246
{
247+
if (preemptible()) {
248+
handler_errors++;
249+
pr_err("kretprobe entry handler is preemptible\n");
250+
}
235251
krph_val = (rand1 / div_factor);
236252
return 0;
237253
}
@@ -240,6 +256,10 @@ static int return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
240256
{
241257
unsigned long ret = regs_return_value(regs);
242258

259+
if (preemptible()) {
260+
handler_errors++;
261+
pr_err("kretprobe return handler is preemptible\n");
262+
}
243263
if (ret != (rand1 / div_factor)) {
244264
handler_errors++;
245265
pr_err("incorrect value in kretprobe handler\n");

0 commit comments

Comments
 (0)