Commit Graph

727 Commits

Author SHA1 Message Date
Jagadeesh Pakaravoor
28a5a1d51b Add madvising of .odex, .vdex and .art files
1. When mmaping {.art, .odex, .vdex} files madvise them to
MADV_WILLNEED
2. Add system properties to limit the madvise size/range

Test: presubmit
Bug: 178853586
Change-Id: I7bd882e3e1021d48f00f297c4dd1d5a8098c087d
2021-03-10 15:39:57 -08:00
Hans Boehm
69d44b0bfd Add zygote native fork loop
Do not return to Java mode between consecutive fork operations.
This greatly reduces the Zygote overhead, since we no longer need to
stop and restart Java daemons.

By not switching back to Java mode, and being careful about what memory
we touch between forks, we also keep the Zygote heaps much more stable,
facilitating page sharing between the zygote and all its children.
Under normal operation we should no longer allocate any memory in the
zygote between forks. That applies to both the Java and C++ heap.
This makes the zygote behave much more like the mental model many
of us had assumed: It has nearly constant memory contents, which are
copy-on-right cloned at each fork. This does not apply to the initial
system server and webzygote forks, that are currently still handled
differently.

This includes

1. Add ZygoteCommandBuffer, and switch the argument parsing code to use it.
This slightly reduces allocation and enables (3).

2. Support process specialization in the child, even when the arguments
are already know, Leverages existing Usap code.

3. Add support for forking multiple child processes directly to the
ZygoteCommandBuffer data structure. This directly uses the buffer
internals, and avoids returning to Java so long as it can handle the
zygote commands it sees.

FUNCTIONALITY CHANGE:

We now limit the total size of the zygote command, rather than the
number of arguments.

Initial performance observations:

[ These are not perfect, since I'm comparing to numbers before I
started. There may have been other moving parts, but they should be
minor. ]

System-server-observed launch latency:

[Not the best metric, but easy to measure. In particular, this
does not represent a significant reduction in application launch
time.]

Based on measuring the last 10 launches in a lightly used cf AOSP
instance, the system server latency from requesting an app launch to
response with the pid (which does not require the child to execute
anything) went from an average of about 10.7(25) msecs to 6.8(9) and
7.9(16) in two tries with the CL. (The parenthetical numbers are
maxima from among the 10; the variance appears to have decreased
appreciably.)

Dirty pages:

The number of private dirty pages in the zygote itself appears to have
decreased from about 4000 to about 2200. The number of dalvik-main
private dirty pages went from about 1500 to nearly zero.

Initially ART benchmarking service claim -1.88% in PSS. But this is not
consistently repeatable.

Drive-by fix:

Call setAllowNetworkingForProcess on usap / native loop path.

Bug: 159631815
Bug: 174211442
Test: Boots AOSP
Change-Id: I90d2e381bada1b6c9857666d5e87372b6a4c1a70
2021-02-23 15:03:40 -08:00
Remi NGUYEN VAN
684a7409e6 Split NetworkUtils and NetworkUtilsInternal
NetworkUtils is planned to move to a dedicated JAR for connectivity
classes, while NetworkUtilsInternal would stay in the
frameworks-minus-apex JAR, in the com.android.internal.net package.

Bug: 171540887
Test: m, boots, wifi working
      atest FrameworksNetTests
Change-Id: I3d38d72ad23a4bf84af823c7baeb6fed25c0665f
2020-12-07 19:41:49 +09:00
Florian Mayer
044e2806e5 Merge "Pass -XX:PerfettoHprof=true to ART." am: ec5055f307 am: a37238fde7
Change-Id: I00d60a78092a07f9284590f267f76f01124032a4
2020-05-18 21:15:52 +00:00
Florian Mayer
7dc66b31c1 Pass -XX:PerfettoHprof=true to ART.
Bug: 147667830
Change-Id: Ibc26afc5e9e8744839dce7e863d0635788ad9507
2020-05-18 19:52:48 +02:00
Alec Mouri
cf3ad873dd Dispatch refresh rate callbacks from DMS
AChoreographer will consume these callbacks in lieu of going through SF
for the callbacks. This is so that DMS can update its view of display
configs before apps receive the refresh rate callback so that apps can
get consistent information.

Bug: 154874011
Test: ChoreographerNativeTest
Test: Manually verify that HWUI is receiving callbacks
Change-Id: I992c247fd16ef414f94a259bbd300bea3e4c9467
2020-05-07 19:19:23 -07:00
Robin Lee
9e1181302a Use waitForDeclaredService to get Lights HAL
We cache the reference to the HAL and use a DeathRecipient to keep track
of whether it's still good.

Adds waitForService and waitForDeclaredService to the ServiceManager
Java implementation because they were missing.

Test: atest LightsManagerTest
Test: atest LightsServiceTest
Bug: 152509747
Bug: 154631113
Bug: 154627432
Bug: 154629168
Change-Id: Ife8471f3a7e47b48bb31015ddf40f1d7fef6240f
2020-04-24 16:12:27 +02:00
Elliott Hughes
94cc1b3972 Tell bionic when we overwrite argv[0].
Otherwise bionic might still have a pointer into the old content.

(Cherrypick of 07ce3ccc80c26105f2ccfc8c255353274d8b5861.)

Bug: https://issuetracker.google.com/152893281
Test: treehugger
Merged-In: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
Change-Id: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
2020-04-21 16:22:44 -07:00
Elliott Hughes
07ce3ccc80 Tell bionic when we overwrite argv[0].
Otherwise bionic might still have a pointer into the old content.

Bug: https://issuetracker.google.com/152893281
Test: treehugger
Change-Id: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
2020-04-17 16:15:39 -07:00
Hans Boehm
8242eab297 Don't call exit() with threads running
Otherwise running threads race with destructors.

Bug: 150176543
Test: Build and boot AOSP
Change-Id: I159164a36d9808ae86c2928271b14736178e127b
(cherry picked from commit 0fcf4a605d)
2020-04-14 16:58:42 -07:00
Hans Boehm
0fcf4a605d Don't call exit() with threads running
Otherwise running threads race with destructors.

Bug: 150176543
Test: Build and boot AOSP
Change-Id: I159164a36d9808ae86c2928271b14736178e127b
2020-04-10 18:02:42 -07:00
Muhammad Qureshi
4ef3c3bd26 Delete unused code in stats-log-api-gen
Bug: 145100015
Test: m
Change-Id: Idbbe35fbce0d751a5973128406596678e1ead5d3
2020-03-05 10:21:36 -08:00
Connor O'Brien
140049bce8 Merge changes Ie5fa2605,Ia092e896
* changes:
  Use bpf data when available for single-UID cpu stats
  Use bpf data when available for per-UID cpu stats
2020-02-20 22:45:53 +00:00
Derek Sollenberger
83ccff716f Move android.graphics JNI & APEX files into HWUI
The graphics JNI code is now separate from libandroid_runtime
and it along with HWUI headers are no longer visible to targets
outside the boundary of what is to become the UI mainline module

The exposed headers to targets outside the module are now restriced
to C APIs contained in the apex header directory.

Bug: 137655431
Test: CtsUiRenderingTestCases
Change-Id: I30d34055b6870dc1039f190a88f4a747cee17300
2020-02-19 21:13:34 -05:00
Jean-Michel Trivi
1c4cb8be3b Merge "Rename AudioDevice to AudioDeviceAttributes" 2020-02-19 05:51:11 +00:00
Ryan Mitchell
f2392c6f56 Merge changes from topic "rro_config"
* changes:
  Make overlay config work with immutable non-android overlays
  Add xml configuration of RROs
  Extract system partitions into standalone class
2020-02-19 04:37:26 +00:00
Connor O'Brien
cd834de67c Use bpf data when available for single-UID cpu stats
Update KernelSingleUidTimeReader to read BPF data rather than per-UID
proc files when the BPF data is available. This is implemented by
calling libtimeinstate functions via JNI.
Extend KernelSingleUidTimeReaderTest to exercise both the BPF and proc
file code paths.

Bug: 138317993
Test: KernelSingleUidTimerTest passes
Test: no regression in BatteryStatsTests
Change-Id: Ie5fa2605007e8c5f70a0383bf8adbd81d479abfe
Merged-In: Ie962ddd9e30d96aa0fab6104a4164af9ad02f55e
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-19 00:22:14 +00:00
Connor O'Brien
57635c976b Use bpf data when available for per-UID cpu stats
Update KernelCpuUidTimeReader and its subclasses to support reading
frequency, active & cluster times from BPF maps rather than proc files
on devices that support this approach. BPF-based accounting offers
improved accuracy as it can detect every context switch, whereas the
proc files attribute a full tick period to whatever happens to be
running when the tick occurs.
Add a KernelCpuUidBpfMapReader class modeled on
KernelCpuProcStringReader, with singletons for reading each distinct
set of data. These follow the locking approach used by
KernelCpuProcStringReader to ensure thread safety, but they collect
data by calling libtimeinstate functions via JNI rather than reading
text from proc files. They also provide a getDataDimensions() function
to retrieve information currently provided by the header rows of the
proc files, such as the list of available freqs or the number of cores
on each cluster.
Extend the KernelCpu*TimeReaderTest classes to exercise the BPF path
for each reader class, and add a KernelCpuUidBpfMapReaderTest modeled
on KernelProcStringReaderTest.

Bug: 138317993
Test: KernelCpu*TimeReaderTests and KernelCpuUidBpfMapReaderTest pass
Test: no regressions in BatteryStatsTests
Change-Id: Ia092e896028e5f647f6c182de05fa76c7e2e3180
Merged-In: Ie7c0b11a47289e16f72fd6868de4185e858c7e4f
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-19 00:20:52 +00:00
Ryan Mitchell
9b93942a80 Add xml configuration of RROs
This change adds the ability to configure the priority, default enable
state, and mutability (previously know as staticness) of an overlay.
Rather than overlays configuring themselves, the system can configure
overlays relative to each other.

An example configuration file looks like:
<config>
    <merge path="auto-generated.xml" />
    <overlay package="com.example.one" mutable="false"
             enabled="true"/>
    <overlay package="com.example.two" mutable="false"
             enabled="true"/>
    <overlay package="com.example.three" enabled="true"/>
</config>

The <overlay> tag configures the overlay while the <merge> tag allows
additional configuration files to be included at a position within
the configuration file.

If the configuration file is not present for a partition, the legacy
android:isStatic and android:priority will continue to configure the
overlays in the partition. Once at least one configuration file has
been defined in any partition, strict partition precedence will be
enforced and overlays on separate partitions will no longer be able
to use android:priority to reorder themselves conversely from the
overlay partition precedence.

The order of the system partitions from least to greatest precedence
is system, vendor, odm, oem, product, system_ext.

Bug: 135048762
Test: atest OverlayConfigTest
Change-Id: If57e8caa9b881f9d424ef48bba80b18cc8b7b943
2020-02-18 16:13:22 -08:00
Connor O'Brien
1746a6df24 Merge changes Ie962ddd9,Ie7c0b11a
* changes:
  Use bpf data when available for single-UID cpu stats
  Use bpf data when available for per-UID cpu stats
2020-02-19 00:06:33 +00:00
Jean-Michel Trivi
0e87bcaf5c Rename AudioDevice to AudioDeviceAttributes
Once AudioDeviceAddress, then AudioDevice, now AudioDeviceAttributes.

Bug: 148565943
Test: atest AudioServiceHostTest#testAudioDeviceAttributes AudioServiceHostTest#testPreferredDeviceRouting
Change-Id: I17b2b8fc6a5eda6ee1176d6aa27ada3cdd820acc
2020-02-18 23:10:46 +00:00
Connor O'Brien
103a7bb6e1 Use bpf data when available for single-UID cpu stats
Update KernelSingleUidTimeReader to read BPF data rather than per-UID
proc files when the BPF data is available. This is implemented by
calling libtimeinstate functions via JNI.
Extend KernelSingleUidTimeReaderTest to exercise both the BPF and proc
file code paths.

Bug: 138317993
Test: KernelSingleUidTimerTest passes
Test: no regression in BatteryStatsTests
Change-Id: Ie962ddd9e30d96aa0fab6104a4164af9ad02f55e
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-18 12:25:21 -08:00
Connor O'Brien
5065db0572 Use bpf data when available for per-UID cpu stats
Update KernelCpuUidTimeReader and its subclasses to support reading
frequency, active & cluster times from BPF maps rather than proc files
on devices that support this approach. BPF-based accounting offers
improved accuracy as it can detect every context switch, whereas the
proc files attribute a full tick period to whatever happens to be
running when the tick occurs.
Add a KernelCpuUidBpfMapReader class modeled on
KernelCpuProcStringReader, with singletons for reading each distinct
set of data. These follow the locking approach used by
KernelCpuProcStringReader to ensure thread safety, but they collect
data by calling libtimeinstate functions via JNI rather than reading
text from proc files. They also provide a getDataDimensions() function
to retrieve information currently provided by the header rows of the
proc files, such as the list of available freqs or the number of cores
on each cluster.
Extend the KernelCpu*TimeReaderTest classes to exercise the BPF path
for each reader class, and add a KernelCpuUidBpfMapReaderTest modeled
on KernelProcStringReaderTest.

Bug: 138317993
Test: KernelCpu*TimeReaderTests and KernelCpuUidBpfMapReaderTest pass
Test: no regressions in BatteryStatsTests
Change-Id: Ie7c0b11a47289e16f72fd6868de4185e858c7e4f
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-14 21:01:45 -08:00
TreeHugger Robot
650c6a454d Remove libstats_jni from the platform
As part of statsd becoming a mainline module in R,
libstats_jni needs to live in the apex.

Bug: 148620413
Test: m
Test: fastboot flashall

Change-Id: I22c2816c863e7a4462a79ac99238b06aca40a2d6
2020-02-14 14:49:33 -08:00
Evgenii Stepanov
fc27d03bef Refactor NativeHeapTagging compat feature.
Move the logic to startProcessLocked so that it can use app info/flags.

Bug: 135754954
Test: NFC
Change-Id: I50cfb8d0ec4ce1f79dec56b8bef09752a1b37490
Merged-In: Ief86185c6866640700e2548259df9ba1fb617e4d
(cherry picked from commit 5750d3b153)
2020-02-14 10:43:18 -08:00
Derek Sollenberger
db8164c0ac Merge "Move RenderNodeAnimator to android.graphics.animation package" 2020-02-14 16:32:50 +00:00
Evgenii Stepanov
45c350c0a8 Merge changes from topic "allowNativeHeapPointerTagging"
* changes:
  Add android:allowNativeHeapPointerTagging.
  Refactor NativeHeapTagging compat feature.
2020-02-14 01:41:37 +00:00
Derek Sollenberger
8c2f6b6e15 Move RenderNodeAnimator to android.graphics.animation package
A wrapper still exists at android.view.RenderNode animator
as it needs access to internals of the view that would violate
the package layering if moved into android.graphics.animation.

This CL also moves the Java and cpp files associated with creating
a native interpolator that can be run directly on the RenderThread.

Bug: 149293249
Test: CtsViewTestCases
Change-Id: I5260331fedbd634cf2f6d6d392941e7284527420
2020-02-13 16:14:06 -05:00
Siarhei Vishniakou
b01c6135ea Cache VerifiedInputEvent class references
Currently, the variables 'clazz' and 'constructor' are not stored properly.
Cache them to make it consistent with all of the other jni code.

This would also prevent a crash in checkjni for using deleted local
reference (it's never made global in the current code).

Bug: 134977432
Test: atest VerifyInputEventTest (run several times)
Change-Id: Icef5271d915fce49b24d987923942fbdc4b6898b
2020-02-12 17:36:44 -08:00
Evgenii Stepanov
5750d3b153 Refactor NativeHeapTagging compat feature.
Move the logic to startProcessLocked so that it can use app info/flags.

Bug: 135754954
Test: NFC
Change-Id: Ief86185c6866640700e2548259df9ba1fb617e4d
2020-02-12 17:07:34 -08:00
Nicolas Geoffray
ada87ea525 Merge "Use new image location for JIT Zygote." 2020-02-10 14:09:57 +00:00
Nicolas Geoffray
6097439672 Use new image location for JIT Zygote.
Bug:119800099
Test: boots, correct image is being picked up, correct files are being
pinned

(cherry picked from commit 9ac03a0504)

Change-Id: I0fd94e27ec2e8ecd814576efed8363b0e6b6d438
Merged-In: I7add3006b0d72b005daabb6609d954b466985304
2020-02-09 23:02:05 +00:00
Nicolas Geoffray
97f02a4f26 Merge "Use new image location for JIT Zygote." 2020-02-09 22:47:09 +00:00
Nicolas Geoffray
9ac03a0504 Use new image location for JIT Zygote.
Bug:119800099
Test: boots, correct image is being picked up, correct files are being
pinned

Change-Id: I7add3006b0d72b005daabb6609d954b466985304
2020-02-07 22:40:22 +00:00
Automerger Merge Worker
2305ccf398 Merge "Make FinalizerTimeoutMs and ThreadSuspendTimeout system prop" am: e021e1f78e am: deeb2974c0 am: 32db483074
Change-Id: I5364e58a9a386c927137d0438e27f9de6bafda66
2020-02-07 17:38:10 +00:00
Jean-Michel Trivi
036c5acae1 Rename AudioDeviceAddress to AudioDevice
Bug: 148565943
Test: atest AudioServiceHostTest AudioServiceHostTest#testAudioDevice
Change-Id: Idb3ed485e86f6d3ce443df910a087ce246c7d3f5
2020-02-06 14:17:55 -08:00
Lokesh Gidra
b4607fc27e Make FinalizerTimeoutMs and ThreadSuspendTimeout system prop
Currently these are command line options for dalvikvm. Exposing them to
system property.

Bug:143848108
Test: flash device; adb shell setprop dalvik.vm.finalizer-timeout-ms
<val>; adb shell stop; adb shell start; adb shell getprop dalvik.vm.finalizer-timeout-ms

Change-Id: I3bd16ea0c4a01b7e400b3e6e67eb47cf7a26afce
2020-02-06 13:33:50 -08:00
Automerger Merge Worker
df801ee4c0 Merge "Clean up options for ART runtime." am: 5c517f5ae9 am: 94754ea0e7 am: 069a85e865
Change-Id: Id7de5e66472e77a94128d9eb28a3e26d1d3a1298
2020-02-05 16:23:22 +00:00
Vladimir Marko
a2fc49d54d Clean up options for ART runtime.
The ART runtime no longer runs dex2oat directly, so all
-Xcompiler-options flags are used only by JIT. As such, -Xms
and -Xmx flags are useless, so we do not need to pass them.

When we want to skip compilation, pass -Xnoimage-dex2oat and
do not pass any other -Ximage-compiler-option. Also, since
we no longer relocate to /data (patchoat has been removed),
do not request -Xnorelocate as relocation in memory is OK.

Pass --generate-mini-debug-info if dalvik.vm.minidebuginfo
is set also as -Ximage-compiler-option.

And move the check for /system/etc/boot-image.prof from
AndroidRuntime.cpp to the deprecated GenerateImage() in
art/runtime/gc/space/image_space.cc . If it's not found,
just report the error and compile with the "speed" filter.
Previously we used to set --compiler-filter=speed-profile,
making the dalvik.vm.image-dex2oat-filter useless. Instead
rely on dex2oat using speed-profile or speed as the default.

Test: aosp_taimen-userdebug boots; check zygote args in logcat.
Bug: 119800099
Change-Id: Ie019f00e3b37030920a72b1ad8944a33b8665817
2020-02-04 16:35:55 +00:00
Muhammad Qureshi
006d3ee677 Merge "Fix StatsLog JNI registration" 2020-02-03 17:12:49 +00:00
TreeHugger Robot
3f5ed8b0ae Merge "Add API for updating quota type of files on external storage." 2020-02-03 11:18:32 +00:00
Martijn Coenen
6caa2d15be Add API for updating quota type of files on external storage.
In recent releases, Android has used the GID of files on external
storage to compute quota for various media types. This was implemented
by the kernel sdcard filesystem, which kept a mapping of file
extension->GID, and automatically set the correct GID on the lower
filesystem. We then simply asked the kernel "how much space is used by
the GID corresponding to image files" to determine how much space image
files took up on external storage.

sdcardfs will be removed starting with devices launching with R; this
means that the quota tracking implementation can no longer live in the
kernel on these devices. MediaProvider is a logical place to initiate
the quote handling in userspace, since it is responsible for all files
on external storage.

But since MediaProvider is now a mainline module, we don't want the
quota tracking implementation to live in MediaProvider itself. Instead,
provide a new @SystemAPI on StorageManager that can be called whenever
we need to set the quota type for a file on external storage. This
allows MediaProvider to call this API whenever a file is created on
external storage, or whenever its type is changed such that it requires
using a different quota type (eg going from an image file to an audio
file, which is presumably a rare case).

The API doesn't require a special permission, because the current
implementation is not a binder call, but an in-process call to modify
filesystem attributes. That means that the caller must already be in an
SELinux domain that allows these attribute modifications. Currently,
only MediaProvider and vold are allowed to modify these attributes.
Therefore, this API is effectively protected by SELinux.

Bug: 146419093
Test: builds. Functionality will be tested with existing
      StorageHostTest CTS test, but running that tests depends on other
      changes (eg a device without sdcardfs). This is tracked in the
      test plan for removing sdcardfs.
Change-Id: I9ffb11a89b17e5596fce70e96c06a8af2142e41f
2020-02-03 09:36:00 +01:00
Muhammad Qureshi
93b4e99d9b Fix StatsLog JNI registration
Re-add StatsLog JNI regsitration in AndroidRuntime.cpp.
This will have to be revisited once StatsLog is moved into statsd apex.

Test: m
Test: fastboot flashall
Test: adb logcat "*:E"
Change-Id: I233a527d00d524cbc2edaed7c2be76ea1c212b29
2020-02-02 08:25:44 -08:00
Automerger Merge Worker
623d6030c3 Merge "Pass down more profile saver options to the runtime" am: b1b1204a7a am: 83ee6f1b35 am: e7d0e57d5a
Change-Id: Ia17cafcadb78754e4f317023ef28bfe87ec67d74
2020-02-01 01:12:39 +00:00
Calin Juravle
1038dcdf2c Pass down more profile saver options to the runtime
Add the delay to save the resolved classes as a system property and pass
it down to the runtime

Test: build and check profile saver activity
Bug: 141487932
Change-Id: I17278505e29295d3ecfe1e1e782da11f5356ebfd
2020-01-30 18:52:19 -08:00
Tej Singh
a2b78e4d6b Create libstats_jni
This cl creates libstats_jni, puts the android_util_StatsLog class in it
to implement the jni StatsLog.writeImpl() call, and puts the library in
the statsd apex.

Right now, it does NOT load the library properly and therefore the
library is still in the platform. It needs to be removed from the
platform.

Test: boots
Test: adb shell cmd stats print-logs shows logs still flow
Bug: 147315667
Change-Id: I0a06b66d4640d00ee75bc273423b33dafc944b05
2020-01-30 13:52:42 -08:00
Automerger Merge Worker
3d072827fd Merge "Disable heap pointer tagging on Q or earlier." am: 372a9b99e2 am: d465863e3d am: 0552cba90a
Change-Id: I46616ca8979628e22d4974e915995bdc035b8305
2020-01-24 08:08:28 +00:00
Evgenii Stepanov
cba0c36535 Disable heap pointer tagging on Q or earlier.
For testing, this feature can be enabled per-application with
  adb shell am compat 135754954 <app.name>

Bug: 135754954
Bug: 147147490
Test: malloc() returns tagged pointer with the feature enabled

Change-Id: I067b4ba6f5fbfcb8287f0cc07d17978dbe708806
2020-01-22 15:20:54 -08:00
Songchun Fan
3c82a306cd [incremental] native implementation of Incremental Service
The implementation of IIncrementalManager.aidl. TODO to refactor this.

Test: atest service.incremental_test
Change-Id: Ib8c8a9c0e7f0289b4bcd8961fa39746ed12b4310
2019-12-19 11:27:42 -08:00
Andy Hung
f2310c7065 MediaMetrics: Add MediaMetrics Java interface
Test: Verify media.metrics dumpsys, atest MediaMetricsTest
Bug: 138583596
Change-Id: Ic0e86fcbb4768f9d21a32dae7e69e071a67d965d
2019-12-17 16:38:51 -08:00