summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Todd Kennedy <toddke@google.com> 2016-08-18 11:22:52 -0700
committer Andreas Gampe <agampe@google.com> 2016-09-06 10:46:18 -0700
commit94f9be2ee2a40b390cc4de1f24a33d0b662a2d79 (patch)
tree96cd1fb62f5d20034c3d8f54e7a25518ad080954
parent3f95d0bb6af6a155291cff3f6b61b2b25348127f (diff)
Release mPackages lock earlier
We cannot hold mPackages when calling into generatePackageDexopts(). This method takes Package Manager's mInstallLock. By holding mPackages, we have lock inversion and hilarity ensues. Change-Id: Ia11a158677051e3511702f38cde6780e75b256fb Fixes: 30927731 (cherry picked from commit a8d4f489974f3ea8f73990cbabbce205343fb926)
-rw-r--r--services/core/java/com/android/server/pm/OtaDexoptService.java45
1 files changed, 23 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/pm/OtaDexoptService.java b/services/core/java/com/android/server/pm/OtaDexoptService.java
index 836b588c7621..bff6d2d4786e 100644
--- a/services/core/java/com/android/server/pm/OtaDexoptService.java
+++ b/services/core/java/com/android/server/pm/OtaDexoptService.java
@@ -93,38 +93,39 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
if (mDexoptCommands != null) {
throw new IllegalStateException("already called prepare()");
}
+ final List<PackageParser.Package> important;
+ final List<PackageParser.Package> others;
synchronized (mPackageManagerService.mPackages) {
// Important: the packages we need to run with ab-ota compiler-reason.
- List<PackageParser.Package> important = PackageManagerServiceUtils.getPackagesForDexopt(
+ important = PackageManagerServiceUtils.getPackagesForDexopt(
mPackageManagerService.mPackages.values(), mPackageManagerService);
// Others: we should optimize this with the (first-)boot compiler-reason.
- List<PackageParser.Package> others =
- new ArrayList<>(mPackageManagerService.mPackages.values());
+ others = new ArrayList<>(mPackageManagerService.mPackages.values());
others.removeAll(important);
// Pre-size the array list by over-allocating by a factor of 1.5.
mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2);
+ }
- for (PackageParser.Package p : important) {
- // Make sure that core apps are optimized according to their own "reason".
- // If the core apps are not preopted in the B OTA, and REASON_AB_OTA is not speed
- // (by default is speed-profile) they will be interepreted/JITed. This in itself is
- // not a problem as we will end up doing profile guided compilation. However, some
- // core apps may be loaded by system server which doesn't JIT and we need to make
- // sure we don't interpret-only
- int compilationReason = p.coreApp
- ? PackageManagerService.REASON_CORE_APP
- : PackageManagerService.REASON_AB_OTA;
- mDexoptCommands.addAll(generatePackageDexopts(p, compilationReason));
- }
- for (PackageParser.Package p : others) {
- // We assume here that there are no core apps left.
- if (p.coreApp) {
- throw new IllegalStateException("Found a core app that's not important");
- }
- mDexoptCommands.addAll(
- generatePackageDexopts(p, PackageManagerService.REASON_FIRST_BOOT));
+ for (PackageParser.Package p : important) {
+ // Make sure that core apps are optimized according to their own "reason".
+ // If the core apps are not preopted in the B OTA, and REASON_AB_OTA is not speed
+ // (by default is speed-profile) they will be interepreted/JITed. This in itself is
+ // not a problem as we will end up doing profile guided compilation. However, some
+ // core apps may be loaded by system server which doesn't JIT and we need to make
+ // sure we don't interpret-only
+ int compilationReason = p.coreApp
+ ? PackageManagerService.REASON_CORE_APP
+ : PackageManagerService.REASON_AB_OTA;
+ mDexoptCommands.addAll(generatePackageDexopts(p, compilationReason));
+ }
+ for (PackageParser.Package p : others) {
+ // We assume here that there are no core apps left.
+ if (p.coreApp) {
+ throw new IllegalStateException("Found a core app that's not important");
}
+ mDexoptCommands.addAll(
+ generatePackageDexopts(p, PackageManagerService.REASON_FIRST_BOOT));
}
completeSize = mDexoptCommands.size();
}