Page MenuHomeFreeBSD

cam_sim: harmonize code related to acquiring a mtx
ClosedPublic

Authored by bz on Sep 1 2020, 8:14 PM.
Tags
None
Referenced Files
F105957216: D26286.diff
Mon, Dec 23, 2:44 AM
Unknown Object (File)
Sun, Dec 1, 10:57 PM
Unknown Object (File)
Mon, Nov 25, 11:15 PM
Unknown Object (File)
Oct 1 2024, 10:17 PM
Unknown Object (File)
Sep 30 2024, 4:26 AM
Unknown Object (File)
Sep 30 2024, 12:03 AM
Unknown Object (File)
Sep 28 2024, 5:29 PM
Unknown Object (File)
Sep 21 2024, 6:38 AM
Subscribers

Details

Summary

cam_sim_free(), cam_sim_release(), and cam_sim_hold() all assign
a mtx variable during declaration and then if NULL or the mtx is
held may re-asign the variable and/or acquire/release a lock.

Harmonize the code, avoiding double assignments and make it look
the same for all three function (with cam_sim_free() not needing
an extra case).

No functional changes intended.

Reviewed by: ..
MFC after: ..
Test Plan

I came across this code trying to debug a hang on I believe
cam_sim_free_mtx (though it should not be) as the msleep()
seems to have never been woken up and found the locking
contracts quite confusing. I keep wondering if it should be
simplified a lot but that would require reading a lot of
consumers.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.Sep 1 2020, 8:14 PM

This looks fine to me.

though I wonder when mtx is NULL these days... I thought all the sims had been fixed.

This revision is now accepted and ready to land.Sep 2 2020, 7:00 PM

I don't see a point, but if you do -- I have no objections.

@imp NULL there is when SIM does not require external locking, for example, NVMe or CTL CAM frontend. It is a new feature for few years now rather than something that should be fixed.

Yeah, what Warner is thinking of is when sim->mtx == &Giant. I think we've removed all of that code.

This revision was automatically updated to reflect the committed changes.