Page MenuHomeFreeBSD

Annotate parts of SYSINIT cpu with tslog
ClosedPublic

Authored by cperciva on May 30 2023, 3:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 7, 8:47 PM
Unknown Object (File)
Tue, May 7, 7:15 PM
Unknown Object (File)
Sat, May 4, 4:26 PM
Unknown Object (File)
Mar 19 2024, 7:19 PM
Unknown Object (File)
Mar 19 2024, 1:59 PM
Unknown Object (File)
Dec 26 2023, 3:58 PM
Unknown Object (File)
Dec 21 2023, 2:36 PM
Unknown Object (File)
Dec 20 2023, 3:46 AM
Subscribers

Details

Summary

Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM,
SYSINIT cpu takes roughly 2770 us:

  • 2280 us in vm_ksubmap_init
    • 535 us in kmem_malloc
      • 450 us in pmap_zero_page
    • 1720 us in pmap_growkernel
      • 1620 us in pmap_zero_page
  • 80 us in bufinit
  • 480 us in cpu_setregs
    • 430 us in cpu_setregs calling load_cr0

Much of this is hypervisor overhead: load_cr0 is slow because it traps
to the hypervisor, and 99% of the time in pmap_zero_page is spent when
we first touch the page, presumably due to the host Linux kernel
faulting in backing pages one by one.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

i wonder if this is the right approach to begin with

have you considered a different take on it: instrument all functions with a timestamp grab on entry/exit. this will have to make sure tail call is disabled. that what you will get an almost complete picture who takes time, but in some cases it may still require extra effort to find out why (say a func is long and is doing a bunch of unrelated ops).

sys/vm/vm_kern.c
747–748

missing tsexit

In D40327#918269, @mjg wrote:

i wonder if this is the right approach to begin with

have you considered a different take on it: instrument all functions with a timestamp grab on entry/exit. this will have to make sure tail call is disabled. that what you will get an almost complete picture who takes time, but in some cases it may still require extra effort to find out why (say a func is long and is doing a bunch of unrelated ops).

I considered that, but (quite apart from not being sure how to get the compiler to add that) there are functions which are called far too many times to be usefully logged (we only have a fixed size buffer). Annotating functions of interest has worked pretty well.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 4 2023, 5:19 PM
This revision was automatically updated to reflect the committed changes.