Page MenuHomeFreeBSD

Add function to OSD to get values without taking the lock.
ClosedPublic

Authored by stevek on Apr 4 2024, 12:18 AM.
Tags
None
Referenced Files
F154031303: D44631.id.diff
Sat, Apr 25, 2:54 PM
F153990965: D44631.id138940.diff
Sat, Apr 25, 7:21 AM
F153926696: D44631.id.diff
Fri, Apr 24, 8:49 PM
Unknown Object (File)
Tue, Apr 21, 10:47 PM
Unknown Object (File)
Tue, Apr 21, 12:46 AM
Unknown Object (File)
Mon, Apr 20, 6:13 AM
Unknown Object (File)
Wed, Apr 15, 4:30 AM
Unknown Object (File)
Sat, Apr 11, 12:26 PM
Subscribers

Details

Summary

There are some cases of OSD use where the value is only initialized once
at a point where successive access of the value can be done so safely
without the need to take the lock.

Obtained from: Juniper Networks, Inc.

Diff Detail

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

Event Timeline

Some uses of OSD may do so in a way where the value is only set once at a point where successive get of the value can be done so safely without the need to take the lock.

I think this sentence is not quite right. :)

sys/kern/kern_osd.c
281

osd_get_unlocked() would be more consistent with this kind of pattern elsewhere in the tree.

291

Changed from _nolock to _unlocked in naming and updated commit log message.

sys/kern/kern_osd.c
291

Assuming you just didn't see it, I think this suggestion should still be applied. Or is there some reason not to?

sys/kern/kern_osd.c
291

I probably would not be necessary in the cases that I have seen where unlocked access makes sense. However, I suppose one could do this for some of the potential cases, but wouldn't atomic_store_ptr be necessary also in the osd_set_reserved() function if doing so?

sys/kern/kern_osd.c
291

It's not strictly necessary. Adding the atomic qualifier here 1) helpers readers understand that this isn't a normal, synchronized memory access, 2) provides more information to concurrency sanitizers to help avoid reporting false positives.

I think it would make sense to modify osd_set_reserved() too.

Use atomic to read OSD slot data

This revision is now accepted and ready to land.May 17 2024, 2:27 PM