Commenter Max noted that the maximum number of TLS slots is 1088 and wondered why such a strange number. “I mean, it does not look like a perfect number in terms of 2-based numeric system.”
It looks a little better in base 2. The value is 10001000000
which breaks down as 1024 + 64.
When TLS was first introduced, the number of available TLS slots was 64, and those slots were pre-allocated as part of the thread control block. Over time, 64 slots turn out not to be enough, so the kernel team modified the code to allocate a page of data per thread once the 65th request for a TLS slot was made. A page of data is 4KB, which has enough room for 1024 32-bit values. That’s why the total is 1088. It’s the original 64 slots, plus an addition 1024 slots.
Note that the statement that “the maximum number of slots is 1088” is a statement of current implementation, not a contractual obligation. The contractual obligation is that there will always be at least TLS_
MINIMUM_
AVAILABLE
slots available. Any more than that is just gravy.
0 comments