lkml.org 
[lkml]   [2022]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH bpf v2 1/2] fprobe: samples: Add use_trace option and show hit/missed counter
On Wed,  8 Jun 2022 01:11:02 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

>
> static void sample_entry_handler(struct fprobe *fp, unsigned long ip, struct pt_regs *regs)
> {
> - pr_info("Enter <%pS> ip = 0x%p\n", (void *)ip, (void *)ip);
> + if (use_trace)
> + trace_printk("Enter <%pS> ip = 0x%p\n", (void *)ip, (void *)ip);

Could we add a comment stating something like "this is just an example, no
kernel code should call trace_printk() except when actively debugging".

-- Steve


> + else
> + pr_info("Enter <%pS> ip = 0x%p\n", (void *)ip, (void *)ip);
> + nhit++;
> if (stackdump)
> show_backtrace();
> }
> @@ -49,8 +56,13 @@ static void sample_exit_handler(struct fprobe *fp, unsigned long ip, struct pt_r
> {
> unsigned long rip = instruction_pointer(regs);
>
> - pr_info("Return from <%pS> ip = 0x%p to rip = 0x%p (%pS)\n",
> - (void *)ip, (void *)ip, (void *)rip, (void *)rip);
> + if (use_trace)
> + trace_printk("Return from <%pS> ip = 0x%p to rip = 0x%p (%pS)\n",
> + (void *)ip, (void *)ip, (void *)rip, (void *)rip);
> + else
> + pr_info("Return from <%pS> ip = 0x%p to rip = 0x%p (%pS)\n",
> + (void *)ip, (void *)ip, (void *)rip, (void *)rip);
> + nhit++;
> if (stackdump)
> show_backtrace();

\
 
 \ /
  Last update: 2022-06-17 18:08    [W:0.051 / U:0.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site