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)
Wed, Apr 17, 10:20 AM
Unknown Object (File)
Dec 20 2023, 1:43 AM
Unknown Object (File)
Dec 8 2023, 3:36 AM
Unknown Object (File)
Dec 1 2023, 2:14 PM
Unknown Object (File)
Nov 11 2023, 8:56 PM
Unknown Object (File)
Nov 10 2023, 8:01 PM
Unknown Object (File)
Nov 10 2023, 11:30 AM
Unknown Object (File)
Nov 9 2023, 8:58 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.