mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Jeff Xie <xiehuan09@gmail.com>
Cc: mingo@redhat.com, mhiramat@kernel.org, zanussi@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] tracing: make tp_printk work on syscall tracepoints
Date: Fri, 8 Apr 2022 17:18:08 -0400	[thread overview]
Message-ID: <20220408171808.762c5c8b@gandalf.local.home> (raw)
In-Reply-To: <20220329163931.710555-4-xiehuan09@gmail.com>

On Wed, 30 Mar 2022 00:39:31 +0800
Jeff Xie <xiehuan09@gmail.com> wrote:

First, patch 1 and 2 can be folded into this patch. Making something
"available for future use" is not a reason to break up patches. It will not
help in bisecting, and its not something to be backported.

Next, the tracing subsystem follows the "Capitalize first letter" for
subjects:

 "tracing: Make tp_printk work on syscall tracepoints"

> Adding printk for syscall tracepoints for the tp_printk work.

Need to add much more content to the above. Your cover letter would work.

    Currently the tp_printk option has no effect on syscall tracepoint.
    When adding the kernel option parameter tp_printk, then:

    echo 1 > /sys/kernel/debug/tracing/events/syscalls/enable

    When running any application, no trace information is printed on the
    terminal.

    Now added printk for syscall tracepoints.

As commit logs should be self explanatory per commit. The cover letter was,
but this patch was lacking.


> 
> Signed-off-by: Jeff Xie <xiehuan09@gmail.com>
> ---
>  kernel/trace/trace_syscalls.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index f755bde42fd0..9798122166d3 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -290,6 +290,25 @@ static int __init syscall_enter_define_fields(struct trace_event_call *call)
>  	return ret;
>  }
>  
> +static void syscall_output_printk(struct trace_entry *ent,
> +		struct trace_event_file *trace_file, struct trace_array *tr)
> +{
> +	unsigned long flags;
> +	struct trace_iterator *iter = tracepoint_print_iter;
> +	struct trace_event *event = &trace_file->event_call->event;
> +
> +	spin_lock_irqsave(&tracepoint_iter_lock, flags);
> +
> +	trace_seq_init(&iter->seq);
> +	iter->ent = ent;
> +	iter->tr = tr;
> +	event->funcs->trace(iter, 0, event);
> +	trace_seq_putc(&iter->seq, 0);
> +	pr_info("%s", iter->seq.buffer);
> +
> +	spin_unlock_irqrestore(&tracepoint_iter_lock, flags);
> +}
> +
>  static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  {
>  	struct trace_array *tr = data;
> @@ -333,6 +352,9 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  	syscall_get_arguments(current, regs, args);
>  	memcpy(entry->args, args, sizeof(unsigned long) * sys_data->nb_args);
>  
> +	if (static_key_false(&tracepoint_printk_key.key))
> +		syscall_output_printk(&entry->ent, trace_file, tr);
> +
>  	event_trigger_unlock_commit(trace_file, buffer, event, entry,
>  				    trace_ctx);


>  }
> @@ -376,6 +398,9 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>  	entry->nr = syscall_nr;
>  	entry->ret = syscall_get_return_value(current, regs);
>  
> +	if (static_key_false(&tracepoint_printk_key.key))
> +		syscall_output_printk(&entry->ent, trace_file, tr);
> +

Instead of reimplementing the logic, just convert the syscall code to use,
trace_event_buffer_reserve() and trace_event_buffer_commit(), and then you
not only get tp_printk() for syscalls, but also other features as well.

-- Steve


>  	event_trigger_unlock_commit(trace_file, buffer, event, entry,
>  				    trace_ctx);
>  }


  reply	other threads:[~2022-04-08 21:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 16:39 [PATCH 0/3] " Jeff Xie
2022-03-29 16:39 ` [PATCH 1/3] tracing: make tracepoint_iter_lock public Jeff Xie
2022-03-29 16:39 ` [PATCH 2/3] tracing: make tracepoint_printk_key public Jeff Xie
2022-03-29 16:39 ` [PATCH 3/3] tracing: make tp_printk work on syscall tracepoints Jeff Xie
2022-04-08 21:18   ` Steven Rostedt [this message]
2022-04-09  2:17     ` Jeff Xie
2022-04-08 14:21 ` [PATCH 0/3] " Jeff Xie
2022-04-08 21:03   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220408171808.762c5c8b@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=xiehuan09@gmail.com \
    --cc=zanussi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®