Page MenuHomeFreeBSD

libthr: Reorder pthread mutex to prevent false sharing
ClosedPublic

Authored by aokblast on Wed, Oct 7, 7:25 AM.
Tags
None
Referenced Files
F176549591: D60434.id188945.diff
Mon, Oct 19, 6:33 PM
F176537903: D60434.id188992.diff
Mon, Oct 19, 4:02 PM
F176533292: D60434.id188945.diff
Mon, Oct 19, 3:14 PM
F176449533: D60434.id188945.diff
Sun, Oct 18, 11:15 PM
Unknown Object (File)
Sat, Oct 17, 5:52 PM
Unknown Object (File)
Fri, Oct 16, 1:07 PM
Unknown Object (File)
Fri, Oct 16, 5:50 AM
Unknown Object (File)
Wed, Oct 14, 10:57 PM
Subscribers

Details

Summary

On a 64 byte cache line CPU (amd64), m_owner is contended by all of
the shared processes. However, after finding one winner, mtx is
enqueued, which trigger a cache refresh from other processors. Reorder
mtx so that m_lock and m_qu will not be in the same cache line.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 77802
Build 74685: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Wed, Oct 7, 9:26 AM
markj added inline comments.
lib/libthr/thread/thr_private.h
177

I'd amend this comment to explain that it's preferable to keep the linkage fields in a separate cache line.

lib/libthr/thread/thr_private.h
177

Thanks! I will also add some assertion test on LPI64 to indicate that these should not be sit in the same cache line.