Commit graph

35713 commits

Author SHA1 Message Date
Elliott Hughes
ad12582726 Merge "strftime: format small positive integers ourselves." 2021-12-07 20:30:53 +00:00
Elliott Hughes
e4d5efe231 strftime: format small positive integers ourselves.
A decent chunk of the logcat profile is spent formatting the timestamps
for each line, and most of that time was going to snprintf(3). We should
find all the places that could benefit from a lighter-weight "format an
integer" and share something between them, but this is easy for now.

Before:

-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
BM_time_strftime        781 ns          775 ns       893102

After:

-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
BM_time_strftime        149 ns          147 ns      4750782

Much of the remaining time is in tzset() which seems unfortunate.

Test: treehugger
Change-Id: Ie0f7ee462ff1b1abea6f87d4a9a996d768e51056
2021-12-06 14:55:00 -08:00
Elliott Hughes
670acdbb1e Merge "Use -fno-builtin for libc and libm." am: bb802661af
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1909404

Change-Id: I15db9d94403480899a29b37e58b2d06bb63770b3
2021-12-03 16:11:08 +00:00
Elliott Hughes
bb802661af Merge "Use -fno-builtin for libc and libm." 2021-12-03 15:55:35 +00:00
Peter Collingbourne
3860403271 Merge "Fix a race condition in the bionic pthread tests." am: a43e7a87b3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1909043

Change-Id: If8069be6bbe928637233cd910fad31b2e5bbc206
2021-12-03 01:13:42 +00:00
Peter Collingbourne
a43e7a87b3 Merge "Fix a race condition in the bionic pthread tests." 2021-12-03 00:55:43 +00:00
Elliott Hughes
a13d0660fe Use -fno-builtin for libc and libm.
clang was getting in the way of a strftime(3) optimization, and smaller
hammers weren't working, and this seems like the right choice for libc
anyway? If we have code that can usefully be optimized, we should do it
in the source. In general, though, no libc/libm author should be
ignorant of memset(3) or memcpy(3), and would have used it themselves if
it made sense. (And the compiler isn't using profiling data or anything;
it's just always assuming it should use the functions, and doesn't
consider whether the cost of the calls can be amortized or not.)

Test: treehugger
Change-Id: Ia7e22623e47bfbfcfe46c1af0d95ef7e8669c0f6
2021-12-02 14:42:16 -08:00
Peter Collingbourne
c5b81844b6 Fix a race condition in the bionic pthread tests.
It's possible for the main thread to leave the RunTimedTest
function before the waiting thread has had a chance to call e.g.
pthread_cond_timedwait(). In this case, pthread_cond_timedwait()
will access the local variable ts after its lifetime has ended. Fix
the bug by making ts a field of pthread_CondWakeupTest instead. The
lifetime of pthread_CondWakeupTest is tied to that of the waiting
thread via the pthread_join() call.

Found with HWASan + uaccess logging.

Change-Id: Iefe8deb30a367dc518013d741c425b041596b0d3
2021-12-02 12:45:54 -08:00
Pirama Arumuga Nainar
1359b83d83 Merge "[versioner] Use libclang-cpp.so" am: 78051b771b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1901512

Change-Id: I19bf17bbcc46195910e463d5bf37004bff98cf68
2021-12-02 02:31:23 +00:00
Pirama Arumuga Nainar
78051b771b Merge "[versioner] Use libclang-cpp.so" 2021-12-02 02:07:14 +00:00
Treehugger Robot
14b886b1a5 Merge "Allow bpf() syscall" am: e48ea932c0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1907693

Change-Id: Icfa053fcb15d70117a6cd4ec958b67045347100d
2021-12-01 22:08:47 +00:00
Treehugger Robot
e48ea932c0 Merge "Allow bpf() syscall" 2021-12-01 21:51:30 +00:00
Alessio Balsini
5afe3f8a6a Allow bpf() syscall
The implementation of FUSE BPF requires the FUSE daemon to access BPF
functionalities, i.e., to get the fd of a pinned BPF prog and to update
maps.
In Android the FUSE daemon is part of MediaProvider which, belonging to
the apps domain, can only access the subset of syscalls allowed by
seccomp, of which bpf() is currently blocked.

This patch removes this limitation by adding the bpf() syscall to the
allowed seccomp syscalls.

Allowing the bpf() syscall is safe as its usage is still gated by
selinux and regular apps are not allowed to use it.

Bug: 202785178
Test: m
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I5887e8d22906c386307e54d3131c679fee0d9f26
2021-12-01 21:32:08 +00:00
Pirama Arumuga Nainar
5514287dc3 [versioner] Use libclang-cpp.so
Bug: http://b/150809112

This is a new upstream library that exports both the clang and LLVM C++
symbols and can replace libLLVM and (android-toolchain-only)
libclang_cxx.so.

Test: Build and run versioner
Change-Id: Ib711c29f478e00e39f26dd09917618b349f0c786
2021-12-01 03:15:30 -08:00
Treehugger Robot
7d0b40f150 Merge "Update OWNERS" am: 1d4272e3e4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1906725

Change-Id: I212ba52dedcd416df9d0763a6814b67c66c5fbf9
2021-12-01 02:42:01 +00:00
Treehugger Robot
1d4272e3e4 Merge "Update OWNERS" 2021-12-01 02:19:44 +00:00
Tom Cherry
d473a70693 Update OWNERS
jmgao@ and tomcherry@ are no longer on the team.

Test: n/a
Change-Id: I7f036f951ddf62afab3e541fa88622807bef54ec
2021-11-30 16:36:04 -08:00
Treehugger Robot
27bccb1c7c Merge "Remove boilerplate." am: a9ebf6f422
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1895823

Change-Id: I496c7e61f1320cfa8a78bf64787e7d0f70053101
2021-11-19 17:18:07 +00:00
Treehugger Robot
a9ebf6f422 Merge "Remove boilerplate." 2021-11-19 17:13:48 +00:00
Richard Fung
5b57d9cd84 Remove boilerplate.
The apex hash tree is automatically generated at compile time for
apexes in apexd-bootstrap, so there's no need to explicitly specify
anything here.

Bug: b/203820392, b/198361718
Test: presubmit
Change-Id: I5ff0363fde701e7fe4e3ed8ab274c6a57852828c
2021-11-19 17:13:18 +00:00
Elliott Hughes
539a4e884c Merge "mbrtoc16: explain the line that has no test coverage." am: f4c8b0da39
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1896951

Change-Id: I20a91abf4bf1ba685f1e2712133aaf84cd95f473
2021-11-19 17:11:08 +00:00
Elliott Hughes
f4c8b0da39 Merge "mbrtoc16: explain the line that has no test coverage." 2021-11-19 16:54:55 +00:00
Elliott Hughes
9d66092bfd mbrtoc16: explain the line that has no test coverage.
We could remove this line, but it seems reasonable to leave it in for
clarification/safety, especially if it's moved after the common success
case?

Test: treehugger
Change-Id: I5f7e0da8397f80018e6d55321b26371790087f5c
2021-11-18 10:11:07 -08:00
TreeHugger Robot
f480905b73 Merge "Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918" into stage-aosp-master 2021-11-17 19:23:55 +00:00
Evgenii Stepanov
39a051651c Merge "Regression test for scudo crash in resizeTaggedChunk." am: 19e63753d2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1894704

Change-Id: I3748ab959f64ea728ef6b0da11076c2ce91cfafd
2021-11-17 06:19:45 +00:00
Evgenii Stepanov
19e63753d2 Merge "Regression test for scudo crash in resizeTaggedChunk." 2021-11-17 06:04:01 +00:00
Evgenii Stepanov
f0d7a34e25 Regression test for scudo crash in resizeTaggedChunk.
This is a copy of the upstream scudo test for CTS:
https://reviews.llvm.org/rG913d78c40c37c9c3428285d868ce454b058e40f3

Bug: 206701345
Test: CtsBionicTestCases
Change-Id: I76b6b33c0665d7ad3bdd8c07d39a39d0d24d94df
2021-11-16 20:10:12 -08:00
Elliott Hughes
b832b2c2a1 Merge "Optimize the mbs fast path slightly." am: afd8fc3f35
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1894148

Change-Id: Idc3cb6d010b3aecb70470d4f2118a02cc30bf260
2021-11-16 22:27:17 +00:00
Elliott Hughes
9853cc6542 Merge "New multi-byte character benchmarks." am: 3fd4625614
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1894147

Change-Id: I5bfe50546cc790d3042041c50a3202ea745b5a21
2021-11-16 22:26:59 +00:00
Elliott Hughes
afd8fc3f35 Merge "Optimize the mbs fast path slightly." 2021-11-16 22:13:01 +00:00
Elliott Hughes
3fd4625614 Merge "New multi-byte character benchmarks." 2021-11-16 22:12:46 +00:00
Elliott Hughes
2c96639eb2 Optimize the mbs fast path slightly.
From a logcat profile:
```
     |--95.06%-- convertPrintable(char*, char const*, unsigned long)
     |    |--13.95%-- [hit in function]
     |    |
     |    |--35.96%-- mbrtoc32
     |    |    |--82.72%-- [hit in function]
     |    |    |
     |    |    |--11.07%-- mbsinit
     |    |    |
     |    |    |--5.96%-- @plt
```
I think we'd assumed that mbsinit() would be inlined, but since these
functions aren't all in wchar.cpp it wasn't being. This change moves the
implementation into a (more clearly named) inline function so we can
trivially reclaim that 11%+6%.

Benchmarks before:
```
-------------------------------------------------------------------
Benchmark                         Time             CPU   Iterations
-------------------------------------------------------------------
BM_stdlib_mbrtowc_1            8.03 ns         7.95 ns     87144997
BM_stdlib_mbrtowc_2            22.0 ns         21.8 ns     32002437
BM_stdlib_mbrtowc_3            30.0 ns         29.7 ns     23517699
BM_stdlib_mbrtowc_4            37.4 ns         37.1 ns     18895204
BM_stdlib_mbstowcs_ascii     792373 ns       782484 ns          890 bytes_per_second=609.389M/s
BM_stdlib_mbstowcs_wide    15836785 ns     15678316 ns           44 bytes_per_second=30.4138M/s
```

Benchmarks after:
```
-------------------------------------------------------------------
Benchmark                         Time             CPU   Iterations
-------------------------------------------------------------------
BM_stdlib_mbrtowc_1            5.76 ns         5.72 ns    121863813
BM_stdlib_mbrtowc_2            17.1 ns         16.9 ns     41487260
BM_stdlib_mbrtowc_3            24.2 ns         24.0 ns     29141629
BM_stdlib_mbrtowc_4            30.3 ns         30.1 ns     23229291
BM_stdlib_mbstowcs_ascii     783506 ns       775389 ns          903 bytes_per_second=614.965M/s
BM_stdlib_mbstowcs_wide    12787003 ns     12672642 ns           55 bytes_per_second=37.6273M/s
```

Bug: http://b/206523398
Test: treehugger
Change-Id: If8c6c39880096ddd2cbd323c68dca82e9849ace6
2021-11-16 11:03:19 -08:00
Elliott Hughes
09bf432be4 New multi-byte character benchmarks.
I don't think the old benchmarks made any sense; going through all the
characters might have made sense as a unit test, but I'm not sure how
actionable they were for realistic cases. In particular, "all ASCII" is
a common special case that's worth measuring separately. I'm still not
hugely convinced, but at least separating the "ASCII" and "wide" paths
is an improvement. I can't think of a case where we did optimization
work on this kind of code without considering those two paths
separately.

I've added to the single-character benchmarks by splitting out the
separate cases instead --- one benchmark each for single-byte up to
4-byte characters.

Bug: http://b/206523398
Test: treehugger
Change-Id: I58cbfedb4b497a55580857eff307a024938cf006
2021-11-16 10:51:12 -08:00
Zijun Zhao
7b796506dd Merge "Fix incorrect API level for wcstombs and mbstowcs." am: 02ed7ea425
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1870080

Change-Id: Ie103eabcb55d7578a33862f94f451bb9ab05d066
2021-11-12 01:50:05 +00:00
Zijun Zhao
02ed7ea425 Merge "Fix incorrect API level for wcstombs and mbstowcs." 2021-11-12 01:32:47 +00:00
Treehugger Robot
2ee9abe69f Merge "Remove outdated ld.bfd usage." am: fe254da88f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1888176

Change-Id: Iddc2492a46a335412098102d96ba99f5caa3fc5d
2021-11-11 17:24:18 +00:00
Treehugger Robot
fe254da88f Merge "Remove outdated ld.bfd usage." 2021-11-11 17:12:48 +00:00
Stephen Hines
30cd30f644 Remove outdated ld.bfd usage.
LLD supports `-z global`, unlike ld.gold, which this was previously a
workaround for.

Test: mm in test dir
Change-Id: I1f621c329accfb31912a19544e34447aff0dfa28
2021-11-10 18:09:49 -08:00
Xin Li
e6b2f0fc4e Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: I3908b0b506b7062e644da8b1dbb12e5e39eedafc
Change-Id: Icc732497519ce78dda180abb30194b73941ec896
2021-11-10 08:05:26 +00:00
ZijunZhao
57474c89fe Fix incorrect API level for wcstombs and mbstowcs.
Mbstowcs and wcstombs cannot get correct return value when called in the environment below api 21, and need to raise the API level to solve the problem.

Test: None
fix bug 1108 https://github.com/android/ndk/issues/1108

Change-Id: Iabcf1bff0be087288646687732ef68870630b48a
2021-11-09 23:29:33 +00:00
Treehugger Robot
157d55fb5a Merge "uchar.h tests: small improvements." am: 4b6ae54acf
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1883331

Change-Id: I1df98a5052654fc7a9cc133cf0820ac28d9eefb0
2021-11-09 19:11:46 +00:00
Treehugger Robot
4b6ae54acf Merge "uchar.h tests: small improvements." 2021-11-09 18:48:20 +00:00
Elliott Hughes
3d8156d3ec uchar.h tests: small improvements.
Explicitly test an invalid 5-byte UTF-8 sequence with mbrtoc16(3); the
fact that we weren't testing this was shown by coverage data.

Merge the surrogate pair tests in with their fewer-byte siblings to make
it clearer to a human reader that we've covered both cases.

Clear errno to make assertions about errno more convincing.

Test: treehugger
Change-Id: I485a48cc141f3e52058e2138326f3134d41b2243
2021-11-05 17:49:36 -07:00
Elliott Hughes
4b2ae78043 Merge "Add the missing '--' to shell invocations." am: 5205e8ac5e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1881791

Change-Id: Ie6dc2cb49f7ae38a90d8ee923fda494b486ed914
2021-11-05 21:35:17 +00:00
Elliott Hughes
5205e8ac5e Merge "Add the missing '--' to shell invocations." 2021-11-05 21:16:12 +00:00
Treehugger Robot
2de1071db7 Merge "Remove references to nonplat sepolicy" am: f1c36760be
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1882069

Change-Id: I06a7bd921d11d7ae007bfe53760105100d56810c
2021-11-05 15:54:03 +00:00
Treehugger Robot
f1c36760be Merge "Remove references to nonplat sepolicy" 2021-11-05 15:40:25 +00:00
Jeff Vander Stoep
70aa88c66c Remove references to nonplat sepolicy
"nonplat" was renamed to "vendor" in Android Pie, but was retained
here for Treble compatibility.

We're now outside of the compatbility window for these devices so
it can safely be removed.

Test: build boot cuttlefish device. adb remount, modify
/system/etc/selinux/plat_sepolicy_and_mapping.sha256 to force
on-device policy compilation. reboot. Verify that device boots
without new selinux denials.

Change-Id: I663a524670120ee19dfe785aa5f89b3981bdd378
2021-11-05 09:30:25 +01:00
Elliott Hughes
b6b7e2ee2e Add the missing '--' to shell invocations.
This came up with POSIX recently. Doesn't seem like it matters since
everyone's had this wrong for 40 years, but "meh" --- it's a trivial
fix, and it's strictly correct even if nobody needs this, so let's just
do it...

(Geoff Clare pointed out that my app compat concern "what if someone's
relying on this bug to pass flags to the shell?" isn't relevant because
while you can indeed do that, you then can't pass a command!)

Bug: https://austingroupbugs.net/view.php?id=1440
Test: treehugger
Change-Id: I64f6440da55e2dc29d0136ee62007197d2f00d46
2021-11-04 17:29:35 -07:00
Yi Kong
c7b2bd6f1d Merge "Re-enable LTO for linker" am: 7d3f322e64
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1873884

Change-Id: Ia6a2157d9392f20590febaa883d587818a4a4107
2021-11-04 10:50:28 +00:00