[PATCH] D73055: [scudo][standalone] Allow sched_getaffinity to fail

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 06:48:56 PST 2020


cryptoad added inline comments.


================
Comment at: compiler-rt/lib/scudo/standalone/linux.cpp:133
 
+// sched_getaffinity can fail (no CAP_SYS_NICE, syscall filtering, etc), in
+// which case the function shall return 0.
----------------
hctim wrote:
> Should probably add comment about the zero error-condition to the shared header.
Ack


================
Comment at: compiler-rt/lib/scudo/standalone/tsd_shared.h:23
+    NumberOfTSDs =
+        (NumberOfCPUs == 0) ? MaxTSDCount : Min(NumberOfCPUs, MaxTSDCount);
     TSDs = reinterpret_cast<TSD<Allocator> *>(
----------------
hctim wrote:
> Should the fallback here still be `1` instead of `MaxTSDCount`? Seems to me like falling back to having a single TSD is safer than spawning 8 (for fuchsia) or 2 (for android) for a single-threaded program.
I debated this, and I think that having a fallback to 1 is very restricting, eg: a single cache/lock.
I think it's less limiting to fallback to multiple caches, it will potentially allow us to make use of multiple cores if there are more than 1. If not, everything still works but we use a bit more memory which I don't think is a big issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73055/new/

https://reviews.llvm.org/D73055





More information about the llvm-commits mailing list