summaryrefslogtreecommitdiff
path: root/libc/system_properties/system_properties.cpp
AgeCommit message (Collapse)Author
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-04-01Match 'Access denied finding property' log severity to SELinuxTom Cherry
This log message exists to provide more context (the property name) to SELinux denials for the same access check. The SELinux log severity is 'W' since SELinux denials do not necessarily point to user-visible errors, therefore this message should be 'W' as well. Bug: 181269159 Test: build Change-Id: Ie25091d96214a175b7ca39d5615f9a09b789d1e3
2020-08-19Adding system property tracingBowgo Tsai
Introducing a new systrace tag, TRACE_TAG_SYSPROP, for use with system property. For property set, the tracing is added in __system_property_set() instead of __system_property_update() / __system_property_add() so we can record control properties like ctl.*, sys.powerctl.*, etc.., which won't be updated via the latter two functions. Bug: 147275573 Test: atest CtsBionicTestCases Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s bionic Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s sysprop Test: adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks \ --benchmark_filter=BM_property --bionic_cpu=4, then compares the results of property benchmarks before and after the change, didn't see significant difference. Change-Id: Id2b93acb2ce02b308c0e4889f836159151af3b46 Merged-In: Id2b93acb2ce02b308c0e4889f836159151af3b46 (cherry picked from commit 26970c34937e2339876d6ba335a56769d6f0d75e)
2019-11-12Revert "Revert "Make system property reads wait-free""Raman Tenneti
This reverts commit de39d9242ae38733c33173957386db0b8060e52a. Reason for revert: This revert is not needed Change-Id: I34af8e5d75c724f6c4066fafbfc6bc7d58377601
2019-11-12Revert "Make system property reads wait-free"Raman Tenneti
This reverts commit 0cf90556de2bde53a1957c5946036b2fe2e4e429. Reason for revert: Device boot failures - 144355953 Change-Id: Icd4fc8c7a1d06d688a6d37e6f1c1aa45563f711b
2019-11-11Make system property reads wait-freeDaniel Colascione
Right now, when we read a system property, we first (assuming we've already looked up the property's prop_info) read the property's serial number; if we find that the low bit (the dirty bit) in the serial number is set, we futex-wait for that serial number to become non-dirty. By doing so, we spare readers from seeing partially-updated property values if they race with the property service's non-atomic memcpy to the property value slot. (The futex-wait here isn't essential to the algorithm: spinning while dirty would suffice, although it'd be somewhat less efficient.) The problem with this approach is that readers can wait on the property service process, potentially causing delays due to scheduling variance. Property reads are not guaranteed to complete in finite time right now. This change makes property reads wait-free and ensures that they complete in finite time in all cases. In the new approach, we prevent value tearing by backing up each property we're about to modify and directing readers to the backup copy if they try to read a property with the dirty bit set. (The wait freedom is limited to the case of readers racing against *one* property update. A writer can still delay readers by rapidly updating a property --- but after this change, readers can't hang due to PID 1 scheduling delays.) I considered adding explicit atomic access to short property values, but between binary compatibility with the existing property database and the need to carefully handle transitions of property values between "short" (compatible with atomics) and "long" (incompatible with atomics) length domains, I figured the complexity wasn't worth it and that making property reads wait-free would be adequate. Test: boots Bug: 143561649 Change-Id: Ifd3108aedba5a4b157b66af6ca0a4ed084bd5982
2018-08-02Modernize codebase by replacing NULL with nullptrYi Kong
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-05-01Fix PROP_FILENAME_MAX overflow handlingRyan Prichard
Bug: b/79117743 Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests Change-Id: Idd5aa4d195abc13c06d3e5b57aef69a68c2a9a9d
2018-02-21Remove non-trivial constructors/destructors from SystemPropertiesTom Cherry
With the goal of disallowing exit time destructors, SystemProperties's non-trivial destructor needs to be removed. This means replacing the union hack with yet another hack as we don't want to allocate anything despite relying on some polymorphism. Bug: 73485611 Test: boot bullhead Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2017-12-18Split properties into their own class to make testing betterTom Cherry
Reinitializing system properties can result in crashes later in the program, and is generally not recommended or even supported. This change moves the actual logic for system properties into a class that can be tested in isolation, without reinitializing the actual system property area used in libc. Bug: 62197783 Test: boot devices, ensure properties work Test: system property unit tests and benchmarks Change-Id: I9ae6e1b56c62f51a4d3fdb5b62b8926cef545649
2017-12-14Revert "Don't use serialized propertyinfo"Tom Cherry
This reverts commit e149f3c1d7b6848af6a27e4089d5f0c915e1437d. Reason for revert: This is ready to be enabled now. Bug: 36001741 Change-Id: I418d3a498ff0712ce9a1857924c6d0039026a664
2017-12-13Don't use serialized propertyinfoTom Cherry
This needs more work before it can be enabled. Bug: 36001741 Test: boot, check that we're using old style properties Change-Id: I7032f4b4224758b187cf4e8a53fd8845466a5d4a
2017-12-12Add support for serialized property contextsTom Cherry
This adds support for reading a serialized /dev/__properties__/property_info file, which contains a serialized trie that maps property names to the SELinux context to which they belong. Performance wise on walleye, this change reduces the start up cost in libc from ~3000us to ~430us. On a benchmark that calls __system_property_find() for each property set on the system, it reduces the time per iteration from ~650us to ~292us. Bug: 36001741 Test: Boot bullhead, walleye, run unit tests Test: Benchmark initialization and lookup performance Change-Id: I0887a3a7da88eb51b6d1bd494fa5bce593423599
2017-11-30Fix static classes in system propertiesTom Cherry
Previously, the functionality for mapping properties to contexts were broken into a set of classes, each statically defined in system_properties.cpp to prevent using new/malloc. This is a mistake however, since system property initialization happens before static initialization, so it is possible for the Constructors of these classes to clobber the initialized data. This change fixes that by placing them in a Union and having that Union have a no-op constructor. The individual classes will be initialized via placement new before they are used as is typically done with classes in a union. Test: boot bullhead Change-Id: Ideb9d6ad8b6fc768811d8615d005cd4b8d134bce
2017-11-14Remove some globals from system_propertiesTom Cherry
pa_size should be static to prop_area, so make it so. __system_property_area__ was reused for various purposes, but realistically is a deprecated symbol and this finally separates us from it. Bug: 36001741 Test: boot bullhead, system property unit tests Change-Id: I39663cc3b613093fa4c728b21d8ba58754f8e105
2017-11-14Split system_properties.cpp into its component piecesTom Cherry
system_properties.cpp is a little bit unmanageable in its current form, and is overdue for a refactoring into more clearly defined components. Of particular interest, is creating of a Contexts interface that handles mapping of system property name -> SEContext and its associated prop_area, and creating two classes that implement the current and legacy functionality. This is needed as there will likely be a third even newer way to do this mapping. Bug: 36001741 Test: boot bullhead, system property unit tests Change-Id: Ie75ec6fea1a95f90813918f54669d533e51327c6