This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Allow sched_getaffinity to fail
ClosedPublic

Authored by cryptoad on Jan 20 2020, 9:51 AM.

Details

Summary

In some configuration, sched_getaffinity can fail. Some reasons for
that being the lack of CAP_SYS_NICE capability or some syscall
filtering and so on.

This should not be fatal to the allocator, so in this situation, we
will fallback to the MaxTSDCount value specified in the allocator
configuration.

Diff Detail

Event Timeline

cryptoad created this revision.Jan 20 2020, 9:51 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 20 2020, 9:51 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Unit tests: pass. 62019 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

hctim added inline comments.Jan 20 2020, 3:41 PM
compiler-rt/lib/scudo/standalone/linux.cpp
133

Should probably add comment about the zero error-condition to the shared header.

compiler-rt/lib/scudo/standalone/tsd_shared.h
23

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.

cryptoad added inline comments.Jan 21 2020, 6:41 AM
compiler-rt/lib/scudo/standalone/linux.cpp
133

Ack

compiler-rt/lib/scudo/standalone/tsd_shared.h
23

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.

cryptoad updated this revision to Diff 239334.Jan 21 2020, 8:30 AM

Commenting getNumberOfCPUs to indicate failure value in common.h,
moving sched_getaffinity comment in linux.cpp in body of function.

Unit tests: pass. 62019 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

cryptoad marked 2 inline comments as done.Jan 21 2020, 8:43 AM
eugenis accepted this revision.Jan 21 2020, 11:18 AM

LGTM

compiler-rt/lib/scudo/standalone/tsd_shared.h
23

I think I also prefer to fallback to MaxTSDCount.

This revision is now accepted and ready to land.Jan 21 2020, 11:18 AM
This revision was automatically updated to reflect the committed changes.