summaryrefslogtreecommitdiff
path: root/libs/binder/ProcessState.cpp
AgeCommit message (Collapse)Author
2025-01-28Enable compilation of libbinder on Fuchsia Kevin Lindkvist
This ensures that getMinSchedulerPolicy and getMinSchedulerPriority are only called on Linux as they are only defined here. This replaces some __ANDROID__ ifdef's with BINDER_WITH_KERNEL_IPC. Change-Id: Idec83bf1715ac3c62ac7a849aa188aa491a19fda
2024-12-13libbinder: log when threads requested, not started Steven Moreland
Few bugs about this over the years, so adding a log for it. Bug: 383234630 Test: no logs added on CF boot: `adb logcat -d | grep "Thread pool configuration"` Change-Id: I14382ee5d7e9cd56c245eb6d3883e7db14ff935b
2024-08-07Merge "Binder API for freeze state change notification." into main Yu-Ting Tseng
2024-08-07Merge "libbinder: don't hold global locks for callbacks.." into main Treehugger Robot
2024-08-07Binder API for freeze state change notification. Yu-Ting Tseng
Bug: 338097747 Change-Id: Iac340abc7a1a0700148cded9adb0451b8a4eae73 Test: atest BinderLibTest
2024-08-06Fix driver open fail ProcessState.cpp Steven Moreland
The error message was incorrect. Bugs: me Change-Id: Ib79d3fd0931016b1686df8be5ad295762a9f1243 Test: N/A
2024-08-05binder: replace android_atomic_add with std::atomic Frederick Mayle
android_atomic_add uses the STL atomics internally with `memory_order_release`, so this should be a no-op. Test: m Change-Id: Ie63464d9cb607957c0b318e9cb8f778ce1aa6d83
2024-08-05fix race in ProcessState::getThreadPoolMaxTotalThreadCount Frederick Mayle
The race was introduced in https://r.android.com/3107366. Triggering the race requires calling `getThreadPoolMaxTotalThreadCount` concurrently with `startThreadPool`, which is a bad practice, but, we shouldn't crash. Bug: 355739944 Test: ran https://r.android.com/3207755 test for hours Change-Id: Iee9a99a213474f5b1a398e703b2af585ece6828f
2024-07-20libbinder: don't hold global locks for callbacks.. Steven Moreland
... that can be set by other libraries :) Bug: 354286280 Bug: 199683153 Bug: 352692435 Test: boot Change-Id: I8b8b9a243336a45af50fffbddcab13808a4a1bdc
2024-07-01Binder IPC: clean up includes Tomasz Wasilczyk
- remove unused ones - IWYU - apply preupload lint checks Bug: 341997808 Test: mma Change-Id: Ib8eaff3c2587503fd1b529e0b32d73f7a9b2f479
2024-06-27Migrate from libutils SystemClock.h to std::chrono Tomasz Wasilczyk
Bug: 341997808 Test: mma Change-Id: Ib4d60eeaaac73566cc79d473f6551e9abd20e69a
2024-06-18Merge "binder: remove mutex from transaction processing loop" into main Frederick Mayle
2024-05-31binder: remove mutex from transaction processing loop Frederick Mayle
atomic ops are enough for the various count fields, we don't need a completely consistent view of them. Bug: 333946800 Test: atest --test-mapping frameworks/native/libs/binder/TEST_MAPPING Change-Id: I01f55a36f7421e4955e2b0d3a6500b183573d765
2024-05-25libbinder: report binder error in abort message Steven Moreland
This bug has been eluding me for years. It's so rare, you never see the logcat. I only see the crash stacks. I'm going to guess it's FD exhaustion causing this? But we'll see... Bug: 197637414 Test: boot Change-Id: I78533a8de7cfb5edb7226cd6cfeac5b8aa6ffdf0
2024-02-06binder: fix coverity warnings wangmingming1
Bug: None Test: build Change-Id: I7d56bb75c8fe6bb3206855c06959f81335971c4b Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
2023-11-17Binder unique_fd Tomasz Wasilczyk
Test: mma Bug: 302723053 Change-Id: I52f14cadb027b3f854946d5315dce3d23aa21b19
2023-11-04Revert^2 "Use std::unique_ptr instead of ScopeGuard" Tomasz Wasilczyk
25c1a3b8543dd1756308424dd65030f90bb7a99f Test: m Bug: 302723053 Change-Id: Id9355c10d78d0c55afb49f512b78bb0923fbc4f7
2023-11-03Don't depend on libbase result.h Tomasz Wasilczyk
Test: mma Bug: 302723053 Change-Id: Iea797d6af825d58543ba899f6e712b27e48d859a
2023-10-31Binder: migrate off libutils Mutex Tomasz Wasilczyk
Bug: 302723053 Test: mma Change-Id: I5b81d5c0b6c7fef7f2216d4010adfa9cf72f9876
2023-10-30Revert "Use std::unique_ptr instead of ScopeGuard" Sebastian Pickl
Revert submission 2780893 Reason for revert: breaking boot tests Bug: 308214260 Reverted changes: /q/submissionid:2780893 Change-Id: I7a4ee9a45583a8a1d4a33447de55c63e6ce9d42a
2023-10-27Use std::unique_ptr instead of ScopeGuard Tomasz Wasilczyk
Bug: 302723053 Test: mma Change-Id: I27226885b8b5e771d675ba2d83d0a2e14551d13e
2023-08-25Use String8/16 c_str [binder] Tomasz Wasilczyk
Current String8::string() has two problems: it may suggest it's returning a std::string and also prevents a drop-in replacement with std::string. Bug: 295394788 Test: make checkbuild Change-Id: I1eb6ddebe3faede57f3e6f046da572a79056125a
2023-06-15libbinder: thread count startThreadPool spawn Steven Moreland
When startThreadPool is called, it spawns a thread which is not counted as part of the lazy kernel-started threads. This was discovered in fuzzers, and the test is updated. Bug: 286237215 Test: binderLibTest Change-Id: Ib0fa4484576f9d296b8f57f32ae536b17e5c6497
2023-04-24libbinder: remove 32-bit ABI support Steven Moreland
This was an old userspace ABI, but we've encouraged all platforms to move to a consistent ABI, regardless of bitness of the device. This corresponds to a kernel config option that we started requiring not be set in Android P. After this, the build system still needs to have this support removed. Bug: 232423610 Test: boot cf Change-Id: Iff5997f910d86c73bbd6502ec393434d248cdcd5
2023-02-14libbinder: warn when vndbinder use is wasted Steven Moreland
We can't return null, because there may be other calls in the process to ProcessState, but if vndservicemanager is not installed, we can save a few threads. Note: due to logs being broken (b/210919187) early in boot, you may not be able to see logs for this. Bug: 264617136 Test: check logs, e.g. 02-14 01:31:57.034 3273 3273 E ProcessState: vndservicemanager is not started on this device, you can save resources/threads by not initializing ProcessState with /dev/vndbinder. Change-Id: Ie91dc4ee302e7a36184e533fb755ce0870e2f546
2022-12-09binder: Add an API to check if the threadpool has been started Devin Moore
Libraries that require the threadpool can check this to make sure the threadpool has been started before it is needed. Test: atest binderLibTest Bug: 261652496 Change-Id: I7505319f162e2789dcc3c41bf1f7535c5c1bb9d9
2022-07-13libbinder: get threadpool count locked Steven Moreland
These variables might be changed by another thread. Bug: 233226955 Test: atest binderLibTest Change-Id: I384f309ed1cc7c062ccc5eaab9f6f6a57142cf7f
2022-05-31Fix for flaky test in binderLibTest Elie Kheirallah
Added thread locks around the update of mKernelStartedThreads Added hwasan-presubmit to TEST MAPPING Bug: 233787404 Test: binderLibTest Change-Id: If8dcd7061c478a3ebbb0414c4fcce2a9bf512563
2022-05-20Merge "Prevent cm from incrementing 0." Treehugger Robot
2022-05-20Merge "libbinder: O_CLOFORK" Steven Moreland
2022-05-20libbinder: O_CLOFORK Steven Moreland
You can't use binder after forking, so we can drop the FD. The binder driver doesn't support this (once the FD is open, we would need to open a new context in the child process). So, the userspace API would need to handle resetting all state. However, in general, handling this for multi-threaded processes (because of needing to take all locks by all libraries used by all threads and restoring state, etc...) is too complicated to make work in Android. Bug: 232904068 Test: binderLibTest Change-Id: I38c354af2c69804a40dc2774086a9ab77d158ede
2022-05-19Prevent cm from incrementing 0. Steven Moreland
The kernel will return an error now when the context manager tries to increment the 0 handle. Bug: 166779391 Test: binderLibTest Change-Id: Iab7af80b491c49c37425e840432d9071f9f36ff4
2022-05-19Merge "Tracking number of threads in threadpools. Added tests for max total ↵ Elie Kheirallah
thread count."
2022-05-19Tracking number of threads in threadpools. Elie Kheirallah
Added tests for max total thread count. Renamed getThreadPoolMaxThreadCount to getThreadPoolMaxTotalThreadCount which takes into account user joined threads and polling threads. Test added to check that the current available threads update properly and do not lock. Added second test that simulates a deadlock and confirms the deadlock. Bug: 188834514 Test: binderLibTest Change-Id: Ia99d95544a38596ec9fc316e623e523b64337bc7
2022-05-16Merge "Warn about deletion of 32-bit binder IPC ABI." Steven Moreland
2022-05-13Warn about deletion of 32-bit binder IPC ABI. Steven Moreland
No one should be using this, but if they are, we want to know so we can help them move off of this ABI and then eventually delete this code. Bug: 232423610 Test: N/A Change-Id: If8a8f77393cb2df90d1f04b1aea13e2be79f7b38
2022-05-10libbinder: add BINDER_GET_EXTENDED_ERROR support Carlos Llamas
This adds basic support to pull extended error information provided by the driver via BINDER_GET_EXTENDED_ERROR ioctl. For now, we'll only log the information upon a failed transaction. However, this data can later be used to handle error scenarios such as retry strategies. Bug: 28321379 Test: atest binderLibTest Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: I8aed63cb0d1aa15aa96db4ab8999e300fef1f505
2022-03-14Revert "Revert "libbinder: Replace deprecated utils/threads.h header"" Andrei Homescu
This reverts commit a643e2dabde445e257dc97e9ce81436497f6b2ee. Reason for revert: Fixed libvrflinger Change-Id: I2df02b571b49fe040958ee2c8236605426315d68
2022-03-09libbinder: detect features supported by the driver Carlos Llamas
The binder driver exposes the features it supports as individual files under /dev/binderfs/features/*. This patch adds a method to determine whether a feature is enabled or not and avoid unnecessary calls to the driver. In this case, we can skip logging any "oneway spam detection" failures seen during open_driver() if the ioctl is not supported. Bug: 191910201 Tested: toggling driver features manually Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: Ie8e7315cc1ba8baa9cb03bab1fb3bd7507765c99
2022-03-09Merge "Revert "libbinder: Replace deprecated utils/threads.h header"" Treehugger Robot
2022-03-09Revert "libbinder: Replace deprecated utils/threads.h header" Andrei Homescu
This reverts commit bc8d5b4830d7fb5afe52f9d8809212babedd72b1. Reason for revert: breaks libvrflinger build Change-Id: I767dbf3ed56893ead497184d2204a04156faaa9d
2022-03-09Merge changes Id85ddcb6,I3b096848 Treehugger Robot
* changes: libbinder: Replace deprecated utils/threads.h header libbinder: Fix PAD_SIZE_UNSAFE
2022-03-08libbinder: Replace deprecated utils/threads.h header Andrei Homescu
Replaces the old utils/threads.h with the newer replacement headers or removes it altogether from some files. Bug: None Test: m Change-Id: Id85ddcb6b647e95a649ca2cd77e9db34c5e77b30
2022-02-24libbinder: binder thread names ++ Steven Moreland
As requested by perf team, show domain information first. So, the thread name might look like: binder:3_4 vndbinder:7_8 Fixes: 220391109 Test: boot, ps -AT Change-Id: I70d5d15db01887c01e50cf0b6f656d71ff75d045
2022-02-09ProcessState: thread name includes driver Steven Moreland
Disambiguate /dev/binder and /dev/vndbinder thread names. Bug: email thread Test: ps -AT (and see important parts in comm) Change-Id: I898eeb091dba08bb37ffbf8cd9c03f3a21a53c90
2022-01-12libbinder: remove handle 0 TODO Steven Moreland
A different way to do this and needing to support both ways doesn't seem to make this better. Fixes: 168900528 Test: N/A Change-Id: I0f067b6f18a2c47dbc13e00dd692d60bdaf3f639
2021-12-16libbinder: log when wrong number of threads start Steven Moreland
Add a log when a service requests to have 0 threads but a threadpool (with a thread) is still requested to be started). This currently doesn't get hit on cuttlefish, but by triggering it manually I can see the log. Bug: 210145621 Test: trigger API misuse case and check for log Change-Id: I9113828e10812895802a83017ed8f55e851fa220
2021-10-15libbinder: use after fork aborts Steven Moreland
This is a separate CL, since the warning is independently useful, even if this needs to be reverted. Fixes: 202289725 Test: binderLibTest Change-Id: Ifb046f01cee047d1908a69c075a66ecb0bc68a78
2021-10-14libbinder: ProcessState warn on forked Steven Moreland
Reasonably common error, when people's programs are crashing, because libbinder does not support forking (and supporting forking is really complicated and error prone in multithreaded processes: pthread_atfork documentation states this The intent of pthread_atfork() was to provide a mechanism whereby the application (or a library) could ensure that mutexes and other process and thread state would be restored to a consistent state. In practice, this task is generally too difficult to be practicable. specifically, in libbinder, we would have to: - get all of the libbinder-related locks - make sure the kernel driver can handle forking (or open a new binder fd by reinstantiating ProcessState) - (actual difficulty here) make sure we can capture and release application-specific locks - in a multithreaded process, anything could be going on So, we don't want to take on the complexity of supporting it). Instead now, we install a pthread_atfork handler which marks the ProcessState as invalid in the child process. If code tries to access ProcessState after forking, then it will throw an error (future: abort). Note: forking and then using non-binder things, such as what installd and vold does, is okay. Bug: 202289725 Test: boot and check logs (none) Change-Id: I18638a3190ed2ea23945413c2e5ab15d7094d0b0
2021-09-14Merge changes I89e4de2e,I673d7a4c,Icfb454c2,I5924a82c am: a54c861843 Steven Moreland
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1825953 Change-Id: Ibf6c5ced4bc9d9822308c4ab4e370e7290753c39