Page MenuHomeFreeBSD

EPOCH tracing support for debugging.
ClosedPublic

Authored by glebius on Sep 11 2019, 9:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 8:10 AM
Unknown Object (File)
Sun, Dec 8, 9:29 PM
Unknown Object (File)
Nov 22 2024, 4:48 PM
Unknown Object (File)
Nov 22 2024, 12:00 PM
Unknown Object (File)
Nov 22 2024, 5:17 AM
Unknown Object (File)
Nov 22 2024, 2:12 AM
Unknown Object (File)
Nov 18 2024, 3:37 AM
Unknown Object (File)
Nov 18 2024, 1:18 AM
Subscribers

Details

Summary

Add a debugging kernel option that allows to check whether we are
entering epochs recursively or nest them improperly.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26680
Build 25048: arc lint + arc unit

Event Timeline

sys/kern/subr_epoch.c
213

What do you do if "et" is already in td->td_epochs? panic?

sys/sys/epoch.h
80

Maybe call this EPOCH_TRACE_FILE_LINE

89

(epoch)->epoch (et)->et

Arguments are already comma separated.

sys/sys/proc.h
370

When you are in an epoch section, the CPU is pinned. Are you sure you cannot use the per-cpu epoch lists for this. I.E. have a pointer to the thread from the epoch tracker to avoid mangling the thread structure.

glebius added inline comments.
sys/kern/subr_epoch.c
213

I'm sure we will panic anyway in this case. Typical double insertion, single removal into a list. Already covered by INVARIANTS and probably QUEUE_MACRO_DEBUG.

sys/sys/epoch.h
80

Makes sense.

sys/sys/proc.h
370

Pinned, but we aren't in critical section. CPU may work with a different thread that also uses epoch.

glebius marked 3 inline comments as done.
  • Improve per Hans's suggestions.
sys/sys/proc.h
370

The per-CPU list can be accessed in a critial section w/o risk of other CPU's modifying it. Can you explain again why this is not possible? I still need some more time to review your patch.

sys/kern/subr_epoch.c
209

You could do a critical enter here and iterate the per-cpu list instead, because we are not allowed to switch CPU in an EPOCH section. I really want to try to avoid adding new members to struct thread.

sys/kern/subr_epoch.c
209

I would still need to link threads into the list, so instead of SLIST_HEAD in the thread, I would need SLIST_ENTRY.

Also, I'm not sure entering the critical section during list iteration would be enough to preserve integrity.

P.S. struct thread will lose some other epoch related fields soon, once I sweep through all NIC drivers that use if_addr_lock().

sys/kern/subr_epoch.c
209

For the non-preemtive epochs, there is not a per-thread SLIST, but for the preemptive ones there is the epoch tracker structure.

I guess you are aware about that?

sys/kern/subr_epoch.c
209

Sure. The scope of this patch is only preemptive epochs, since they are more widely used in the kernel and they also cover large branches of code, hence the need for a tracing facility.

sys/kern/kern_thread.c
671

When a thread is destroyed, should we assert that this list is empty?
Does this init also cover thread0 ?

I'm fine with the "epoch->e_name = name;" change and its dependencies. Can this be committed separately?

  • Merge remote-tracking branch 'FreeBSD/master' into epoch-trace
  • More from Hans's review.
This revision is now accepted and ready to land.Sep 25 2019, 7:32 AM