Page MenuHomeFreeBSD

(2/2) threads: reimplement tid allocation on top of a bitmap
ClosedPublic

Authored by mjg on Nov 5 2020, 6:48 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 6:21 PM
Unknown Object (File)
Mon, Nov 18, 6:04 PM
Unknown Object (File)
Sat, Nov 2, 3:07 AM
Unknown Object (File)
Oct 18 2024, 6:46 AM
Unknown Object (File)
Oct 4 2024, 4:11 AM
Unknown Object (File)
Oct 2 2024, 8:33 AM
Unknown Object (File)
Sep 27 2024, 5:55 AM
Unknown Object (File)
Sep 24 2024, 2:27 PM
Subscribers

Details

Summary

There are workloads with very bursty tid allocation and since unr tries very hard to have small-sized bitmaps it keeps reallocating memory. Just doing buildkernel gives almost 150k calls to free coming from unr.

This also gets rid of the hack which tried to postpone TID reuse.

Diff Detail

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

Event Timeline

mjg requested review of this revision.Nov 5 2020, 6:48 AM
sys/kern/kern_thread.c
142 ↗(On Diff #79203)

Can't both tid_bitmap and tid_lock be static?

198 ↗(On Diff #79203)

Shouldn't it be trytid = tid + 1?

  • staticize tid_lock and tid_bitmap
  • store tid + 1
mjg marked 2 inline comments as done.Nov 5 2020, 2:39 PM
sys/kern/kern_thread.c
200 ↗(On Diff #79216)

Isn't this off by one ? NO_PID should not be used.

sys/kern/kern_thread.c
200 ↗(On Diff #79216)

NO_PID == 100000 goes to thread0 both before and after the patch.

kib added inline comments.
sys/kern/kern_thread.c
200 ↗(On Diff #79216)

Ah ok, it is consumed immediately.

This revision is now accepted and ready to land.Nov 5 2020, 5:24 PM
This revision was automatically updated to reflect the committed changes.