Re: [RFC PATCH v2] ftrace: support very early function tracing
From: Steven Rostedt
Date: Wed Nov 08 2017 - 11:08:03 EST
On Wed, 8 Nov 2017 09:10:58 +0100
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Tue, Nov 07, 2017 at 09:17:06PM -0500, Steven Rostedt wrote:
> > > +#ifdef CONFIG_X86_TSC
> > > + entry->clock = rdtsc();
> > > +#else
> > > + entry->clock = trace_clock_local();
> > > +#endif
>
> > > +#ifdef CONFIG_X86_TSC
> > > + cpu_khz = native_calibrate_cpu();
> > > +#endif
>
> > > +#ifdef CONFIG_X86_TSC
> > > + ns = cycles_to_ns(entry->clock, cpu_khz);
> > > +#else
> > > + ns = entry->clock;
> > > +#endif
>
> Yeah, no, not going to happen...
Agreed.
What you can do is have an:
arch_early_trace_clock();
and in trace.c have:
u64 __weak arch_early_trace_clock(void)
{
return trace_clock_local();
}
u64 __weak arch_early_trace_clock_to_ns(u64 clock)
{
return clock;
}
and in x86 have:
u64 arch_early_trace_clock(void)
{
return rdtsc();
}
u64 arch_early_trace_clock_to_ns(u64 clock)
{
return cycles_to_ns(clock, cpu_khz);
}
Is that acceptable?
-- Steve