summaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)Author
2022-05-13bionic: Switch to jemalloc memory allocatorHEADsugisawa-mr1Danny Lin
Overall, jemalloc performs significantly better than Scudo in Bionic's real-world memory_replay traces (all times in milliseconds): +----------------+-------+----------+ | Trace | Scudo | jemalloc | +----------------+-------+----------+ | SQL | 27 | 21 | | Angry Birds 2 | 2236 | 1501 | | Camera | 4251 | 979 | | Candy Crush | 2197 | 1325 | | Gmail | 594 | 463 | | Maps | 434 | 344 | | Photos | 1330 | 477 | | PUBG | 666 | 416 | | surfaceflinger | 221 | 192 | | system_server | 1921 | 1416 | | SystemUI | 102 | 79 | | YouTube | 363 | 294 | +----------------+-------+----------+ jemalloc also tends to use slightly less memory than Scudo for most traces. These tests were conducted on desktop x86 Linux with glibc and the latest stable version of each allocator, but they should still be relevant. RSS values in KiB: +----------------+--------+----------+ | Trace | Scudo | jemalloc | +----------------+--------+----------+ | Angry Birds 2 | 793948 | 746992 | | Camera | 219372 | 251888 | | Candy Crush | 548288 | 550148 | | Gmail | 195236 | 193048 | | Maps | 159860 | 159816 | | Photos | 175436 | 171872 | | PUBG | 233752 | 223572 | | surfaceflinger | 94736 | 107068 | | system_server | 471048 | 484392 | | SystemUI | 54432 | 60740 | | YouTube | 139376 | 142252 | +----------------+--------+----------+ While not representative of real-world usage, jemalloc also performs fairly well in synthetic benchmarks (all times in nanoseconds): +-----------------+---------+----------+ | Benchmark | Scudo | jemalloc | +-----------------+---------+----------+ | alloc 8 | 87.9 | 60.1 | | alloc 16 | 87.9 | 60 | | alloc 32 | 88.6 | 60.7 | | alloc 64 | 88.6 | 59.7 | | alloc 512 | 89.2 | 60 | | alloc 1024 | 89.4 | 59.8 | | alloc 8192 | 89.8 | 65.2 | | alloc 16384 | 92.7 | 69.1 | | alloc 32768 | 97.2 | 74 | | alloc 65536 | 109 | 83.8 | | alloc 131072 | 41536 | 42720 | | alloc40x 8 | 2156 | 2556 | | alloc40x 16 | 2155 | 2244 | | alloc40x 32 | 2234 | 2312 | | alloc40x 64 | 2234 | 2289 | | alloc40x 512 | 2274 | 8171 | | alloc40x 1024 | 2397 | 2162 | | alloc40x 8192 | 3550 | 78880 | | alloc40x 16384 | 3732 | 124454 | | alloc40x 32768 | 3849 | 275460 | | alloc40x 65536 | 4987 | 727598 | | alloc40x 131072 | 2745207 | 3067980 | | alloc8192 1x | 464 | 454 | | alloc8192 2x | 510 | 488 | | alloc8192 3x | 587 | 523 | | alloc8192 4x | 665 | 557 | | alloc8192 5x | 742 | 598 | | alloc8192 6x | 818 | 633 | | alloc8192 7x | 884 | 669 | | alloc8192 8x | 960 | 699 | | alloc8192 9x | 1045 | 734 | | alloc8192 10x | 1131 | 770 | | alloc8192 11x | 1207 | 806 | | alloc8192 12x | 1282 | 841 | | alloc8192 13x | 1363 | 877 | | alloc8192 14x | 1442 | 912 | | alloc8192 15x | 1512 | 944 | | alloc8192 16x | 1587 | 978 | | alloc8192 24x | 2256 | 21195 | | alloc8192 32x | 2867 | 45446 | | alloc8192 40x | 3522 | 71618 | | alloc8192 48x | 4126 | 89740 | | alloc8192 56x | 4786 | 114990 | | alloc8192 64x | 5412 | 141082 | | alloc8192 72x | 6049 | 170742 | | alloc8192 80x | 6712 | 198480 | | alloc8192 88x | 7331 | 221557 | | alloc8192 96x | 7976 | 251462 | | alloc8192 104x | 8581 | 281626 | | alloc8192 112x | 9245 | 313164 | | alloc8192 120x | 9914 | 353147 | | alloc8192 128x | 10514 | 376625 | | alloc8192 136x | 11187 | 408194 | | alloc8192 144x | 11802 | 445694 | | alloc8192 160x | 13083 | 514547 | | alloc8192 176x | 14414 | 582501 | | alloc8192 192x | 15746 | 654346 | | alloc8192 208x | 17044 | 712620 | | alloc8192 224x | 18405 | 769963 | | alloc8192 240x | 19744 | 843969 | | alloc8192 256x | 21160 | 917803 | +-----------------+---------+----------+ Scudo performs fairly well for a hardened memory allocator, but we're optimizing for performance. Full benchmark data with graphs: https://docs.google.com/spreadsheets/d/1LG_kxaK5cI14gGtnyM-nNNmfpMdV9Vh-LtYoq7H5J4s/edit Change-Id: Ia4901eedfaa2c9779678c5b6532979de4919ee01
2021-08-18Dynamic handling of memcpy based on BTI supportVinay Verma
CRs-Fixed: 3017053 Change-Id: I80cd3a88efb175ee155c534c3548e70613df5947
2021-08-04Merge SP1A.210803.001Scott Lobdell
Change-Id: Ib79c79d88ec6388533e450dae94239e736f40fcb
2021-07-27Merge SP1A.210723.002Scott Lobdell
Change-Id: I0fe27377cab01d329a1e8fbe80c2f9d8a0e35a30
2021-07-22Revert "Adding system property tracing"Bowgo Tsai
Revert submission 1403568-sysprop_trace Reason for revert: makes property get/set non-reentrant Reverted Changes: I6f85f3f52:Add systrace tag for system property Id2b93acb2:Adding system property tracing Id78992d23:Add systrace tag for system property I1ba9fc7bd:Add systrace tag for system property Bug: 193050299 Test: build and boot a device Change-Id: Ic7a83fb01a39113d408ed0c95d27f694d5a2649c Merged-In: Ic7a83fb01a39113d408ed0c95d27f694d5a2649c (cherry picked from commit 61a5a8380d6417e9b85bb2f6a4a694ef4222031f)
2021-07-22Revert "bionic_systrace: moving global static variables"Bowgo Tsai
This reverts commit 1e1c7845aab0542306f61d8e8c880aca096ea336. Reason for revert: makes property get/set non-reentrant Bug: 193050299 Test: build and boot a device Change-Id: If59e3dc25684a3c2b1d3ff74f995311afe6c6e89 Merged-In: If59e3dc25684a3c2b1d3ff74f995311afe6c6e89 (cherry picked from commit 3ec21f527acbaefb5f7a114125bc7a93baa780c7)
2021-07-15Fix race when frees after main thread finishes.Christopher Ferris
When the main thread is exiting, the code deleted the g_debug global pointer and destroys the disable pthread key. Unfortunately, if malloc debug was enabled in a way that requires a header for the pointer, any frees that occur after the main thread is torn down result in calls to the underlying allocator with bad pointers. To avoid this, don't delete the g_debug pointer and don't destroy the disable pthread key. Added a new system test that allocates a lot of pointers and frees them after letting the main thread finish. Also, fix one test that can fail sporadically due to a lack of unwinding information on arm32. Bug: 189541929 Test: Passes new system tests. Change-Id: I1cfe868987a8f0dc880a5b65de6709f44a5f1988 Merged-In: I1cfe868987a8f0dc880a5b65de6709f44a5f1988 (cherry picked from commit 33d73379aad3ed7dcbb9b10f945d3bc6264b79bd)
2021-07-12Merge SP1A.210709.002Haamed Gheibi
Change-Id: Ifb03c531ae205a26e8e324f4b9ee4b9ae7b1062a
2021-07-08Merge "Allow the kernel to upgrade ASYNC mode processes to SYNC mode." into ↵Peter Collingbourne
sc-dev
2021-07-07Allow the kernel to upgrade ASYNC mode processes to SYNC mode.Peter Collingbourne
On devices where the performance of ASYNC mode is similar to SYNC mode on certain CPUs, OEMs may choose to configure the kernel to prefer SYNC mode on those CPUs by writing the value "sync" to the sysfs node: /sys/devices/system/cpu/cpu<N>/mte_tcf_preferred The kernel will only respect the per-CPU preference if the user program allows this by specifying the preferred mode as a member of a set of allowed modes. Since only kernels with r.android.com/1754670 support specifying multiple modes, fall back to trying to specify a single mode if that doesn't work. Bug: 189966263 Change-Id: Ie7ada3b073178b7967f0819cbdadc2d8e3a2c648 Merged-In: Ie7ada3b073178b7967f0819cbdadc2d8e3a2c648
2021-06-24Add definition of M_MEMTAG_TUNING.Evgenii Stepanov
Bug: 191769584 Test: N/A Merged-In: Ief77f95a04411528563787a9fc6d10738fc5688f Change-Id: Ief77f95a04411528563787a9fc6d10738fc5688f (cherry picked from commit d8d561c98457409c0003b37b9c1f84bb7d988e04)
2021-06-18Merge SP1A.210616.001Daniel Norman
Change-Id: Iaee20aa65555899f2491489489edf90f69364041
2021-06-18Merge "Merge SP1A.210604.001 Change-Id: ↵Daniel Norman
Id2e423c8ff6a838a96260a5b919810d4ef11e8db" into s-keystone-qcom-dev
2021-06-09Merge "Disable return PAC in __pthread_start." into sc-devTreeHugger Robot
2021-06-09Disable return PAC in __pthread_start.Peter Collingbourne
This function doesn't return, but it does appear in stack traces. Avoid using return PAC in this function because we may end up resetting IA, which may confuse unwinders due to mismatching keys. Bug: 189808795 Change-Id: I953da9078acd1d43eb7a47fb11f75caa0099fa12 (cherry picked from commit 26d83ba7abcbfa725794c144411214d16f64b75a) CRs-Fixed:2965421
2021-06-08Disable return PAC in __pthread_start.Peter Collingbourne
This function doesn't return, but it does appear in stack traces. Avoid using return PAC in this function because we may end up resetting IA, which may confuse unwinders due to mismatching keys. Bug: 189808795 Change-Id: I953da9078acd1d43eb7a47fb11f75caa0099fa12 Merged-In: I953da9078acd1d43eb7a47fb11f75caa0099fa12
2021-06-04Merge SP1A.210604.001Scott Lobdell
Change-Id: Id2e423c8ff6a838a96260a5b919810d4ef11e8db
2021-06-04Fix dangling pointer in heapprofd API.Florian Mayer
We would dlopen heapprofd_client.so, which has a static initializer [1] that passes a pointer to of its functions to heapprofd_client_api.so. If we dlclose heapprofd_client.so, this pointer is dangling. [1]: https://cs.android.com/android/platform/superproject/+/master:external/perfetto/src/profiling/memory/malloc_interceptor_bionic_hooks.cc?q=symbol:g_heap_id This is a cherry-pick of 85c7838bd9cb40949c08d957499357547c7cd687. Bug: 189332777 Change-Id: Ia4a9d9dd7c89eceec86c6fac5f4b66de85d7604e
2021-05-13Merge "Update API of MapInfo from libunwindstack"David Srbecky
2021-05-13Update API of MapInfo from libunwindstackDavid Srbecky
Use accessors to for all the fields. Test: build Change-Id: I6ae458002e059ef2f9d73931cc68f2f698f85d7e
2021-05-10Merge SP1A.210510.001Brian Orr
Change-Id: I3f1de8b84f5e253d6a659de6a2ed75e674b7f5a5
2021-05-07Clear the stack frame pointer in _start and __bionic_cloneChris Wailes
This CL adds an instruction to the _start label that clears the frame pointer. This allows stack walking code to determine when it has reached the end of the stack. The __bionic_clone function is similarly modified, for architectures that weren't already doing both. Test: bionic-unit-tests Test: CtsBionicTestCases Change-Id: Iea3949f52c44f7931f9fff2d60d4d9e5c742c120
2021-05-03Update to v5.12 kernel headers.Christopher Ferris
Kernel headers coming from: Git: https://android.googlesource.com/kernel/common/ Branch: android-mainline Tag: android-mainline-5.12 Test: Boots flame device and runs bionic unit tests. Test: Boots acloud device and runs bionic unit tests. Change-Id: I8ac107ce9d4978be3ef9517b90ad6ecafd06785a
2021-04-26Replace llndk_library with llndk clause in cc_libraryColin Cross
Remove the vestigial llndk_library and replace it with properties in the llndk clause of the implementation cc_library. In order to reduce duplication of the arch-specific headers used by the implementation and LLNDK, rename libc_headers_arch to libc_llndk_headers and hoist the "include" directory out of it, since that directory is preproccessed separately for LLNDK libraries. Bug: 170784825 Test: m checkbuild Test: compare out/soong/build.ninja Change-Id: I75f0ff9129d910640da55eee6a6387467e6e4a9d
2021-04-25Merge SP1A.210425.001Scott Lobdell
Change-Id: If71c56f3e2e9fbbeffc7096a560a5ef8b8cd8566
2021-04-25Merge SP1A.210412.001Scott Lobdell
Change-Id: Icb74f1a8f5ef597ea95b8d4b2d6689a66e8753b8
2021-04-23Avoid prctl(PR_PAC_RESET_KEYS) on devices without PAC support.Peter Collingbourne
Processes loaded from vendor partitions may have their own sandboxes that would reject the prctl. Because no devices launched with PAC enabled before S, we can avoid issues on upgrading devices by checking for PAC support before issuing the prctl. Bug: 186117046 CRs-Fixed: 2918473 (cherry picked from commit dcbacd676f302e94f2d8e571f195d0492c686457) Change-Id: I9905b963df01c9007d9fb4527273062ea87a5075
2021-04-23Merge "Reorder libc.llndk headers to match libc_headers_arch"Treehugger Robot
2021-04-22Merge "Avoid prctl(PR_PAC_RESET_KEYS) on devices without PAC support."Peter Collingbourne
2021-04-22Avoid prctl(PR_PAC_RESET_KEYS) on devices without PAC support.Peter Collingbourne
Processes loaded from vendor partitions may have their own sandboxes that would reject the prctl. Because no devices launched with PAC enabled before S, we can avoid issues on upgrading devices by checking for PAC support before issuing the prctl. Bug: 186117046 Change-Id: I9905b963df01c9007d9fb4527273062ea87a5075
2021-04-22Add missing liblog_headers dependency to libc_defaults.Rupert Shuttleworth
This unblocks several targets building with Bazel, see https://android-review.googlesource.com/c/platform/build/soong/+/1677125. Test: bp2build; bazel build //bionic/... Change-Id: I4206241fc56cf4df5d5f1e65a367844da85a1360
2021-04-21Reorder libc.llndk headers to match libc_headers_archColin Cross
Ease later comparisons by making libc.llndk match libc_headers_arch. Bug: 170784825 Test: m checkbuild Change-Id: I90162c0bc5f6f0e79fe974208fde47cca7489fa1
2021-04-21Merge "Fix last python3 issues."Christopher Ferris
2021-04-20Fix last python3 issues.Christopher Ferris
Includes pointing to the python3 version of the clang bindings. Also, remove stale .gitignore line. Test: Ran bionic/libc/kernel/tools/update_all.py and verified Test: the files generated the same exact way. Change-Id: I4eb9dd7382bca013f70d921b6ef48c7e7478615a
2021-04-20Fix overly-zealous strip.Dan Albert
The argument to this is the characters to strip, so `line.strip(line)` just returns the empty string. Test: None? Bug: None Change-Id: I4f62bffcd00936e4eef837a28b78023fcad54bb0
2021-04-20Merge "Update for python3."Christopher Ferris
2021-04-20Merge "Ignore backup files left by emacs."Treehugger Robot
2021-04-19Update for python3.Christopher Ferris
This fixes all of the problems with our kernel scripts, but not the clang python script problems. I also removed the updateGitFiles function since that code was just silently failing any way. I replaced all calls with updateFiles. Test: Ran script using python2 to verify it still works. Test: Run script in python3 verifying that it starts to run. Change-Id: I223a31a8324c59e6bc4067f48a6110361b3e26e8
2021-04-19Ignore backup files left by emacs.Dan Albert
Test: Added a file like this locally and the upload hook didn't care Bug: None Change-Id: I4c33f2517a9a83c7797d3ea9074fffeedf85dcaa
2021-04-15Force everything to use python3 for consistency.Elliott Hughes
Rather than "whatever people have installed as 'python' on their machine". I've removed check-symbols.py because that's been broken for years and we never even noticed, and I'm not sure it's worth fixing. Test: treehugger, manual Change-Id: Ieb996bbdf790a18d4b1fb46a409cc240ba2a2a49
2021-04-15Make gensyscalls.py compatible with Python 3.Rupert Shuttleworth
Test: Fixes bp2build; bazel build //bionic/... Change-Id: I6ab66e99935b962f1ff99e478c0f55188f31b495
2021-04-13Reset PAC keys on thread creation instead of on zygote fork.Peter Collingbourne
Resetting PAC keys on fork appears to lead to a number of problems. One problem is that we are constrained in where we can run C++ code after forking, and with ART those places are implementation-defined. For example, in app zygotes, ART turns out to insert "interpreter frames" in the stack trace. Returning into these interpreter frames may lead to crashes due to failing the ROP protection check on return. It seems better to reset keys on thread creation instead. We only need to reset IA because only this key needs to be reset for reverse-edge PAC, and resetting the other keys may be incompatible with future ABIs. Chrome (and potentially other applications) has a sandbox that prevents the use of the prctl, so we restrict its use to applications targeting S and above. Bug: 183024045 CRs-Fixed: 2918473 (cherry picked from commit 811d180e892f757d052cf9d6c6b7494a8c4a8c2f) Change-Id: I1e6502a7d7df319d424e2b0f653aad9a343ae71b
2021-04-12Merge "Make res_init() work again."Elliott Hughes
2021-04-09Merge "Revert "Reland: Soft-enable MAC address restrictions with allowlist.""Bram Bonné
2021-04-09Merge "Disable fdtrack post-fork."Josh Gao
2021-04-08Make res_init() work again.Elliott Hughes
Change 75830fb836621ebbcf68155e466983eb231f9ca1 to fix _nres initialization to be thread safe accidentally introduced a behavior change whereby res_init() became a no-op. It also failed to remove all direct accesses to _nres. Move the file over to C++ so we can let RAII ensure we're always holding a lock while using the global state, make all callers access the global state via this class, and restore the previous behavior of res_init(). Test: atest DnsResolverTest Bug: 166235340 Change-Id: Ib390a7eac063bc0ff5eeba755e8c74ef1383004e
2021-04-08Revert "Reland: Soft-enable MAC address restrictions with allowlist."Bram Bonné
Revert "Updates CTS tests for MAC address restrictions." Revert submission 1528409-mac-softrestrict Reason for revert: App compatibility Reverted Changes: I74a50b990:Return anonymized MAC for apps targeting SDK < 30 I8738f7912:Reland: Soft-enable MAC address restrictions with ... Id13670747:Updates CTS tests for MAC address restrictions. Change-Id: I64e17cb04acf2862bc657e60694067a456b4f936
2021-04-08Merge SP1A.210407.002Scott Lobdell
Change-Id: Idd8ceba51b13323ecdee0d34a328b9648f888693
2021-04-08Merge "Initialize _nres only once"Luke Huang
2021-04-07Disable fdtrack post-fork.Josh Gao
Also delete some fdsan code that attempts to check for the post-fork state, but never will, because we update the cached pid upon fork. Bug: http://b/174542867 Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests Test: treehugger Change-Id: I9b748dac9de9b4c741897d93e64d31737e52bf8e