Page MenuHomeFreeBSD

cam: Make cam_debug macros atomic
ClosedPublic

Authored by imp on Oct 31 2023, 3:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 30 2024, 3:45 PM
Unknown Object (File)
Nov 30 2024, 3:45 PM
Unknown Object (File)
Nov 30 2024, 3:45 PM
Unknown Object (File)
Nov 30 2024, 3:41 PM
Unknown Object (File)
Nov 30 2024, 3:41 PM
Unknown Object (File)
Nov 30 2024, 3:41 PM
Unknown Object (File)
Nov 27 2024, 4:55 PM
Unknown Object (File)
Nov 7 2024, 5:39 PM
Subscribers
None

Details

Summary

The CAM_DEBUG* macros use multiple printfs to dump the data. This is
suboptimal when tracing things that produce even a moderate amount since
it gets intertwingled. I can't even turn on tracing with a 24-disk HBA
on boot without it getting messed up. Add helper routines to work around
clang's over-use of the stack: that way we only pay the stack penalty
when a trace hits.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Oct 31 2023, 3:56 AM

(a) instead of a in arg expansions (except printfargs)

Good idea. Sbuf didn't exist back when the debug macros were written, this is an improvement.

This revision is now accepted and ready to land.Oct 31 2023, 1:36 PM
sys/cam/cam_debug.h
88

Won't this eat 100 bytes of stack for each use? Since these are maros, not functions, does compiler free the stack once it get out of scope?

sys/cam/cam_debug.h
88

Yes. The stack doesn't appear to be used unless the scope is entered. And is freed when the scope exits (at least in simple tests I've written). Would you like me to confirm?

sys/cam/cam_debug.h
88

I have feeling that I saw opposite long ago, but may be it has changed or I misunderstood it back then. Would be good to confirm.

This revision now requires review to proceed.Oct 31 2023, 6:00 PM
imp added inline comments.
sys/cam/cam_debug.h
88

Further tests, on the actual code, show that clang, at least, moves the stack the amount of the sum of the scopes in-scope at once. This behaves like you say when we have char buffers like this... the tests I did wound up being bogus because clang completely eliminated the inner scope (doh! Stupid clang getting so smart). I've moved to helper routines to get around this issue.

121

This is unused, so I just removed it.

sys/cam/cam_xpt.c
5547

The observant may discover these are close, but not quite the same as, other routines. Some refactoring (and moving the delay back into the macro) wouldn't be a bad thing, but is beyond the scope for this thing.

mav added inline comments.
sys/cam/cam_xpt.c
3716

Looking on xpt_path_sbuf() I wonder if this should be something like xpt_device_sbuf() with xpt_print_device() as a wrapper, if needed.

This revision is now accepted and ready to land.Oct 31 2023, 6:18 PM
sys/cam/cam_xpt.c
3716

I think we can just rename it because the only use of it was in these debugging macros.
Good suggestion.

rename to xpt_device_sbuf

This revision now requires review to proceed.Oct 31 2023, 6:29 PM
This revision was not accepted when it landed; it landed in state Needs Review.Nov 3 2023, 4:18 PM
This revision was automatically updated to reflect the committed changes.