Page MenuHomeFreeBSD

timecounter: Lock the timecounter list
ClosedPublic

Authored by markj on Oct 15 2021, 8:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 15, 3:25 AM
Unknown Object (File)
Oct 5 2024, 1:08 AM
Unknown Object (File)
Sep 30 2024, 1:02 AM
Unknown Object (File)
Sep 29 2024, 6:28 AM
Unknown Object (File)
Sep 23 2024, 8:26 PM
Unknown Object (File)
Sep 23 2024, 1:25 AM
Unknown Object (File)
Sep 22 2024, 11:23 PM
Unknown Object (File)
Sep 22 2024, 11:19 PM
Subscribers
None

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
Lint Not Applicable
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.