Page MenuHomeFreeBSD

timecounter: Lock the timecounter list

Authored by markj on Oct 15 2021, 8:07 PM.
Referenced Files
Unknown Object (File)
Feb 13 2024, 4:31 AM
Unknown Object (File)
Jan 18 2024, 6:33 AM
Unknown Object (File)
Dec 30 2023, 3:04 PM
Unknown Object (File)
Dec 24 2023, 6:03 AM
Unknown Object (File)
Dec 22 2023, 9:48 PM
Unknown Object (File)
Dec 18 2023, 5:54 AM
Unknown Object (File)
Dec 11 2023, 11:31 PM
Unknown Object (File)
Nov 22 2023, 7:56 PM



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

rG FreeBSD src repository
Lint Not Applicable
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

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.


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.

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

markj added inline comments.

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.