Skip to content

Commit

Permalink
samples/kretprobe: convert the printk to pr_info/pr_err
Browse files Browse the repository at this point in the history
We prefer to use the pr_* to print out the log now, this patch converts
the printk to pr_info.  In the error path, use the pr_err to replace the
printk.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Huang Shijie <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Steve Capper <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Huang Shijie authored and torvalds committed Aug 4, 2016
1 parent 468b889 commit 6134131
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions samples/kprobes/kretprobe_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)

now = ktime_get();
delta = ktime_to_ns(ktime_sub(now, data->entry_stamp));
printk(KERN_INFO "%s returned %d and took %lld ns to execute\n",
pr_info("%s returned %d and took %lld ns to execute\n",
func_name, retval, (long long)delta);
return 0;
}
Expand All @@ -82,23 +82,21 @@ static int __init kretprobe_init(void)
my_kretprobe.kp.symbol_name = func_name;
ret = register_kretprobe(&my_kretprobe);
if (ret < 0) {
printk(KERN_INFO "register_kretprobe failed, returned %d\n",
ret);
pr_err("register_kretprobe failed, returned %d\n", ret);
return -1;
}
printk(KERN_INFO "Planted return probe at %s: %p\n",
pr_info("Planted return probe at %s: %p\n",
my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);
return 0;
}

static void __exit kretprobe_exit(void)
{
unregister_kretprobe(&my_kretprobe);
printk(KERN_INFO "kretprobe at %p unregistered\n",
my_kretprobe.kp.addr);
pr_info("kretprobe at %p unregistered\n", my_kretprobe.kp.addr);

/* nmissed > 0 suggests that maxactive was set too low. */
printk(KERN_INFO "Missed probing %d instances of %s\n",
pr_info("Missed probing %d instances of %s\n",
my_kretprobe.nmissed, my_kretprobe.kp.symbol_name);
}

Expand Down

0 comments on commit 6134131

Please sign in to comment.