This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Allow to specify the maximum number of TSDs at compile time
ClosedPublic

Authored by cryptoad on Oct 26 2017, 10:56 AM.

Details

Summary

This introduces SCUDO_MAX_CACHES allowing to define an upper bound to the
number of ScudoTSD created in the Shared TSD model (by default 32U).
This name felt clearer than SCUDO_MAX_TSDS which is technically what it really
is. I am opened to suggestions if that doesn't feel right.

Additionally change getNumberOfCPUs to return a u32 to be more consistent.

Event Timeline

cryptoad created this revision.Oct 26 2017, 10:56 AM
alekseyshl added inline comments.Oct 26 2017, 11:55 AM
lib/scudo/scudo_platform.h
44

SCUDO_MAX_SHARED_THREAD_CACHES, maybe?

cryptoad added inline comments.Oct 26 2017, 1:39 PM
lib/scudo/scudo_platform.h
44

I would vote for something shorter if possible :)

alekseyshl added inline comments.Oct 26 2017, 3:35 PM
lib/scudo/scudo_platform.h
44

SCUDO_MAX_CACHES is not clear at all, what kind of cache is governed by this define. Call it SCUDO_MAX_TSD_CACHES then.

cryptoad added inline comments.Oct 27 2017, 8:31 AM
lib/scudo/scudo_platform.h
44

After sleeping over this, I don't think the initial CACHE naming for that define was appropriate.
A TSD contains not only the Cache but the QuarantineCache, the Prng, and some other private members.
Something like SCUDO_MAX_SHARED_TSDS (the final S is somewhat awkward) would encompass the fact that it's a maximum value that only applies to shared TSDs.
My fear would be that to someone using this, the concept of Thread Specific Data might be foreign at best.

alekseyshl accepted this revision.Oct 27 2017, 10:36 AM
alekseyshl added inline comments.
lib/scudo/scudo_platform.h
44

I agree, but why would someone not aware of what TSD is want to change this value?

Another option, SCUDO_SHARED_TSD_POOL_SIZE, to avoid that S at the end.

This revision is now accepted and ready to land.Oct 27 2017, 10:37 AM
cryptoad updated this revision to Diff 120655.Oct 27 2017, 11:05 AM
cryptoad marked 5 inline comments as done.

Renaming the define to SCUDO_SHARED_TSD_POOL_SIZE.
Adding a static_cast<u32> to make sure it's unsigned.

cryptoad closed this revision.Oct 27 2017, 1:10 PM