This change introduces scudo_tls.h & scudo_tls_linux.cpp, where we move the
thread local variables used by the allocator, namely the cache, quarantine
cache & prng. ScudoThreadContext will hold those. This patch doesn't
introduce any new platform support yet, this will be the object of a later
patch. This also changes the PRNG so that the structure can be POD.
Details
Diff Detail
- Build Status
Buildable 5940 Build 5940: arc lint + arc unit
Event Timeline
lib/scudo/scudo_tls_linux.cpp | ||
---|---|---|
31 | That is a valid point. I'm going to change it. |
otherwise looks good
lib/scudo/scudo_tls_linux.cpp | ||
---|---|---|
60 | The fast path needs to be inlinable (defined in header file). |
lib/scudo/scudo_tls_linux.cpp | ||
---|---|---|
60 | Previous reviews of similar changes have edged towards less ifdef and a clear separation of the platform specific codes in separate cpp, yielding less complicated code. The issue I can see happening is multiplication of ifdefs in this header when SANITIZER_ANDROID comes into play next if defining the fast path in the header. Is this OK? |
lib/scudo/scudo_tls_linux.cpp | ||
---|---|---|
60 | You can do the same we do for source files. Namely: // scudo_tls.h ... #include <scudo_tls_linux.h> #include <scudo_tls_android.h> ... // scudo_tls_linux.h #if SANITIZER_LINUX ... necessary declarations and bodies of inline functions go here ... #endif // scudo_tls_android.h #if SANITIZER_ANDROID ... necessary declarations and bodies of inline functions go here ... #endif I understand their concerns, but some pieces of sanitizer runtimes are kinda performance-critical. We do have mixed per-platform code in interception.h library, in tsan_platform.h. And tsan_update_shadow_word_inl.h is just awful in the name of performance. These are intentional compromises. |
Addressing Dmitry's comments.
Introduce a scudo_tls_linux.h file, included within scudo_tls.h with fastpath
functions definition (initThreadMaybe & getThreadContext).
An additionaly change is aligning ScudoThreadContext on 64-bytes.
lib/scudo/scudo_tls_linux.h | ||
---|---|---|
35 | Why not ALWAYS_INLINE then? |
Other than these minor comments, LGTM.
lib/scudo/scudo_allocator.cpp | ||
---|---|---|
209 | What was the reason of removing it? This thread implements RSS checks and heap profiling, don't you want this functionality supported in Scusdo too? |
lib/scudo/scudo_allocator.cpp | ||
---|---|---|
209 | I removed it (for now) for a couple of reasons:
My plan is to have a second look once things stabilize a bit so that this function can be of use, but I figure it wasn't needed for now. Let me know if that makes sense, or if you'd rather have it stay! |
lib/scudo/scudo_allocator.cpp | ||
---|---|---|
209 | I was merely curious and you explained the reasoning, no need to bring it back. Thanks! |
Thank you Dmitry & Aleksey.
I appreciate the time you guys are spending reviewing those changes, and the valuable feedback you are providing!
Two more spaces indent.