Page MenuHomeFreeBSD

vm_page_xbusy_claim(): Use atomics to update busy lock state.
ClosedPublic

Authored by markj on Jul 28 2020, 3:08 PM.
Tags
None
Referenced Files
F80134231: D25859.id.diff
Thu, Mar 28, 9:17 AM
Unknown Object (File)
Nov 22 2023, 8:58 AM
Unknown Object (File)
Jul 19 2023, 3:22 PM
Unknown Object (File)
Jul 9 2023, 4:28 PM
Unknown Object (File)
Jul 9 2023, 4:24 PM
Unknown Object (File)
Jul 5 2023, 2:43 AM
Unknown Object (File)
Jul 5 2023, 2:32 AM
Unknown Object (File)
May 5 2023, 5:34 PM
Subscribers

Details

Summary

vm_page_xbusy_claim() could clobber the waiter bit. For its original
use, kernel memory pages, this was not a problem since nothing would
ever block on the busy lock for such pages. r363607 introduced a new
use where this could in principle be a problem.

Fix the problem by using atomic_cmpset. Since this macro is defined
only for INVARIANTS kernels, the extra overhead doesn't seem
prohibitive.

Reported by: vangyzen

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32621
Build 30077: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jul 28 2020, 3:08 PM
markj created this revision.
kib added inline comments.
sys/vm/vm_page.h
775

I think you want to use _busy_lock as a name. If user code (in kernel) defines a busy_lock macro, we have conflict. The _[a-z0-9] namespace is reserved by std for file-local impl symbols.

This revision is now accepted and ready to land.Jul 28 2020, 3:43 PM
markj marked an inline comment as done.

Put the local var in the file-local namespace.

This revision now requires review to proceed.Jul 28 2020, 4:08 PM
This revision is now accepted and ready to land.Jul 28 2020, 4:22 PM
vangyzen added inline comments.
sys/vm/vm_page.h
780

I was expecting fcmpset, but this works, too.

sys/vm/vm_page.h
780

I initially wrote it with fcmpset but I find this is a bit clearer. I don't see any real reason to prefer one over the other.