Page MenuHomeFreeBSD

timecounter: Lock the timecounter list
ClosedPublic

Authored by markj on Oct 15 2021, 8:07 PM.
Tags
None
Referenced Files
F83245005: D32511.id96933.diff
Wed, May 8, 12:38 AM
Unknown Object (File)
Sat, May 4, 12:36 AM
Unknown Object (File)
Fri, May 3, 2:53 PM
Unknown Object (File)
Thu, May 2, 3:13 PM
Unknown Object (File)
Mon, Apr 29, 8:17 AM
Unknown Object (File)
Thu, Apr 25, 8:38 AM
Unknown Object (File)
Feb 13 2024, 4:31 AM
Unknown Object (File)
Jan 18 2024, 6:33 AM
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.