Page MenuHomeFreeBSD

timecounter: Lock the timecounter list
ClosedPublic

Authored by markj on Oct 15 2021, 8:07 PM.

Details

Summary

Timecounter registration is dynamic, i.e., there is no requirement that
timecounters must be registered during single-threaded boot. Loadable
drivers may in principle register timecounters (which can be switched to
automatically). Timecounters cannot be unregistered, though this could
be implemented.

Registered timecounters belong to a global linked list. Add a mutex to
synchronize insertions and the traversals done by (mpsafe) sysctl
handlers. No functional change intended.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj requested review of this revision.Oct 15 2021, 8:07 PM
markj created this revision.
This revision is now accepted and ready to land.Oct 15 2021, 8:09 PM
sys/kern/kern_tc.c
1550

Doesn't drain function for sysctl sbufs do copyout? It might do it over the wired userspace memory, but I do not think it would help against pagefaults while owning the mutex.

sys/kern/kern_tc.c
1550

The pages should indeed be wired. Certainly spurious faults are possible, but isn't it legal to hold a mutex there nonetheless? I thought that was the whole point of sbuf_new_for_sysctl(): to permit non-sleepable locks to be held while writing to the output buffer.

kib added inline comments.
sys/kern/kern_tc.c
1550

Yes, it uses copyout_nofault() in the end. So tc_lock suddently appears before pmap locks on some arches, ok.

markj added inline comments.
sys/kern/kern_tc.c
1550

You are right though that an explicit sysctl_wire_old_buffer() call is needed. I thought sbuf_new_for_sysctl() handled it.

markj marked an inline comment as done.

Need sysctl_wire_old_buffer()

This revision now requires review to proceed.Oct 15 2021, 8:52 PM
This revision is now accepted and ready to land.Oct 15 2021, 9:17 PM
This revision was automatically updated to reflect the committed changes.