mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tracing: Record trace_clock and recover when reboot
Date: Fri, 18 Apr 2025 07:45:23 +0900	[thread overview]
Message-ID: <20250418074523.ae5e9f56950e431d60fc0c79@kernel.org> (raw)
In-Reply-To: <20250417101804.3117e478@gandalf.local.home>

On Thu, 17 Apr 2025 10:18:04 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 17 Apr 2025 14:17:29 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -6004,6 +6004,7 @@ struct trace_mod_entry {
> >  };
> >  
> >  struct trace_scratch {
> > +	char			clock[TRACE_CLOCK_NAME_MAX];
> >  	unsigned long		text_addr;
> >  	unsigned long		nr_entries;
> >  	struct trace_mod_entry	entries[];
> > @@ -6114,6 +6115,8 @@ static void update_last_data(struct trace_array *tr)
> >  	if (tr->scratch) {
> >  		struct trace_scratch *tscratch = tr->scratch;
> >  
> > +		strscpy(tscratch->clock, trace_clocks[tr->clock_id].name,
> 
> Why copy the name and not the clock_id?

The name is more robust if we rebooted in the different kernel.

> 
> The clock ids should not change between kernels.

Hmm, I thought it could be changed because we didn't define it.

----
static struct {
	u64 (*func)(void);
	const char *name;
	int in_ns;		/* is this clock in nanoseconds? */
} trace_clocks[] = {
	{ trace_clock_local,		"local",	1 },
	{ trace_clock_global,		"global",	1 },
	{ trace_clock_counter,		"counter",	0 },
	{ trace_clock_jiffies,		"uptime",	0 },
	{ trace_clock,			"perf",		1 },
	{ ktime_get_mono_fast_ns,	"mono",		1 },
	{ ktime_get_raw_fast_ns,	"mono_raw",	1 },
	{ ktime_get_boot_fast_ns,	"boot",		1 },
	{ ktime_get_tai_fast_ns,	"tai",		1 },
	ARCH_TRACE_CLOCKS
};
----

So the clock id is just an index of this array. That can be changed
easily between the kernel version. If we discard the previous boot
data in that case, I agree with using clock ids.

(Another reason for the implementation is that tracing_set_clock()
 only accepts a name, but this is just due to laziness on my part. :-( )

Thank you,

> 
> -- Steve
> 
> > +			TRACE_CLOCK_NAME_MAX);
> >  		memset(tscratch->entries, 0,
> >  		       flex_array_size(tscratch, entries, tscratch->nr_entries));
> >  		tscratch->nr_entries = 0;


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2025-04-17 22:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17  5:17 Masami Hiramatsu (Google)
2025-04-17 14:18 ` Steven Rostedt
2025-04-17 22:45   ` Masami Hiramatsu [this message]

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=20250418074523.ae5e9f56950e431d60fc0c79@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rostedt@goodmis.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®