feeling_lonely
feeling_lonely

Reputation: 6883

How to time functions in Linux Kernel's start_kernel function?

I need to figure out the time function calls take inside Linux kernel's start_kernel function.

Why this is a problem is because the kernel would not boot if I put a ktime_get() function call before the timekeeping_init() function call inside that same function.

In my setup I think most likely the kernel spends a lot of time inside mm_init(). But I can not verify due to the above mention problem.

Any ideas on how to get around this?

Thanks.

Upvotes: 0

Views: 165

Answers (1)

ephemient
ephemient

Reputation: 204994

This early in the boot there's not really much that's available. printk should work, though.

If you're on x86, you could use rdtsc(). There's only 1 CPU running at this time, so the usual warnings about confusing results don't apply yet.

Upvotes: 1

Related Questions