Re: Very Early boot time stamps support
From: Pavel Tatashin
Date: Wed Nov 29 2017 - 19:25:16 EST
Hi Abderrahmane,
> I'm implementing a feature in ftrace to enable very early function tracing,
> I'm using tsc when x86_tsc feature is available, but it seems that you did
> similar work in your patch "[PATCH v9 0/6] Early boot time stamps for x86".
>
> I need to record timestamps at the start of start_kernel(), the first
> function to be traced is set_task_stack_end_magic.
Early boot time stamps are available only after platforms are
initialized. This happens in:
start_kernel()
setup_arch()
kvmclock_init() <-- right after this call.
This was a request from Thomas, not to invent a new TSC calibration,
and instead rely on what is already available.
So, while not covering the whole boot process, early boot clock is
still initialized pretty early.
Here a few ideas how to make early boot clock to initialize earlier.
1. kvm clock init is ugly and out of place compared to other hypervisors:
1207#ifdef CONFIG_KVM_GUEST
1208 kvmclock_init();
1209#endif
It should really be a part of platform init inside:
setup_arch();
init_hypervisor_platform();
x86_init.hyper.init_platform();
The reason why it is done later compared to the rest of hypervisors,
is because kvm waits for memblock to be initialized, but in reality
allocated memory can be part of bss section. This way we could move
tsc calibration about 200 lines above in setup_arch() function.
2. We could initialize TSC earlier only on those CPUs where hardware
tells us specifically TSC frequency i.e. cpuinfo(15) is available. See
native_calibrate_tsc() for an example. This is true for all the latest
Intel CPUs. Unfortunately, this does not work with qemu, as it returns
some garbage in cpuinfo(15), even when processor supports this feature
natively.
Thank you,
Pavel
>
> How early does the patch provide stable tsc ?
>
> This is the patch that need to use very early time stamps :
> https://lkml.org/lkml/2017/11/8/1031
>