Loading services/core/java/com/android/server/SystemServerInitThreadPool.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; import com.android.server.am.ActivityManagerService; import com.android.server.am.ActivityManagerService; import com.android.server.utils.TimingsTraceAndSlog; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -93,6 +94,8 @@ public class SystemServerInitThreadPool { mPendingTasks.add(description); mPendingTasks.add(description); } } return mService.submit(() -> { return mService.submit(() -> { TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); traceLog.traceBegin("InitThreadPoolExec:" + description); if (IS_DEBUGGABLE) { if (IS_DEBUGGABLE) { Slog.d(TAG, "Started executing " + description); Slog.d(TAG, "Started executing " + description); } } Loading @@ -100,6 +103,7 @@ public class SystemServerInitThreadPool { runnable.run(); runnable.run(); } catch (RuntimeException e) { } catch (RuntimeException e) { Slog.e(TAG, "Failure in " + description + ": " + e, e); Slog.e(TAG, "Failure in " + description + ": " + e, e); traceLog.traceEnd(); throw e; throw e; } } synchronized (mPendingTasks) { synchronized (mPendingTasks) { Loading @@ -108,6 +112,7 @@ public class SystemServerInitThreadPool { if (IS_DEBUGGABLE) { if (IS_DEBUGGABLE) { Slog.d(TAG, "Finished executing " + description); Slog.d(TAG, "Finished executing " + description); } } traceLog.traceEnd(); }); }); } } Loading @@ -132,7 +137,10 @@ public class SystemServerInitThreadPool { */ */ static void shutdown() { static void shutdown() { synchronized (LOCK) { synchronized (LOCK) { TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("WaitInitThreadPoolShutdown"); if (sInstance == null) { if (sInstance == null) { t.traceEnd(); Slog.wtf(TAG, "Already shutdown", new Exception()); Slog.wtf(TAG, "Already shutdown", new Exception()); return; return; } } Loading @@ -147,6 +155,7 @@ public class SystemServerInitThreadPool { } catch (InterruptedException e) { } catch (InterruptedException e) { Thread.currentThread().interrupt(); Thread.currentThread().interrupt(); dumpStackTraces(); dumpStackTraces(); t.traceEnd(); throw new IllegalStateException(TAG + " init interrupted"); throw new IllegalStateException(TAG + " init interrupted"); } } if (!terminated) { if (!terminated) { Loading @@ -160,11 +169,13 @@ public class SystemServerInitThreadPool { synchronized (sInstance.mPendingTasks) { synchronized (sInstance.mPendingTasks) { copy.addAll(sInstance.mPendingTasks); copy.addAll(sInstance.mPendingTasks); } } t.traceEnd(); throw new IllegalStateException("Cannot shutdown. Unstarted tasks " throw new IllegalStateException("Cannot shutdown. Unstarted tasks " + unstartedRunnables + " Unfinished tasks " + copy); + unstartedRunnables + " Unfinished tasks " + copy); } } sInstance = null; // Make eligible for GC sInstance = null; // Make eligible for GC Slog.d(TAG, "Shutdown successful"); Slog.d(TAG, "Shutdown successful"); t.traceEnd(); } } } } Loading Loading
services/core/java/com/android/server/SystemServerInitThreadPool.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; import com.android.server.am.ActivityManagerService; import com.android.server.am.ActivityManagerService; import com.android.server.utils.TimingsTraceAndSlog; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -93,6 +94,8 @@ public class SystemServerInitThreadPool { mPendingTasks.add(description); mPendingTasks.add(description); } } return mService.submit(() -> { return mService.submit(() -> { TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); traceLog.traceBegin("InitThreadPoolExec:" + description); if (IS_DEBUGGABLE) { if (IS_DEBUGGABLE) { Slog.d(TAG, "Started executing " + description); Slog.d(TAG, "Started executing " + description); } } Loading @@ -100,6 +103,7 @@ public class SystemServerInitThreadPool { runnable.run(); runnable.run(); } catch (RuntimeException e) { } catch (RuntimeException e) { Slog.e(TAG, "Failure in " + description + ": " + e, e); Slog.e(TAG, "Failure in " + description + ": " + e, e); traceLog.traceEnd(); throw e; throw e; } } synchronized (mPendingTasks) { synchronized (mPendingTasks) { Loading @@ -108,6 +112,7 @@ public class SystemServerInitThreadPool { if (IS_DEBUGGABLE) { if (IS_DEBUGGABLE) { Slog.d(TAG, "Finished executing " + description); Slog.d(TAG, "Finished executing " + description); } } traceLog.traceEnd(); }); }); } } Loading @@ -132,7 +137,10 @@ public class SystemServerInitThreadPool { */ */ static void shutdown() { static void shutdown() { synchronized (LOCK) { synchronized (LOCK) { TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("WaitInitThreadPoolShutdown"); if (sInstance == null) { if (sInstance == null) { t.traceEnd(); Slog.wtf(TAG, "Already shutdown", new Exception()); Slog.wtf(TAG, "Already shutdown", new Exception()); return; return; } } Loading @@ -147,6 +155,7 @@ public class SystemServerInitThreadPool { } catch (InterruptedException e) { } catch (InterruptedException e) { Thread.currentThread().interrupt(); Thread.currentThread().interrupt(); dumpStackTraces(); dumpStackTraces(); t.traceEnd(); throw new IllegalStateException(TAG + " init interrupted"); throw new IllegalStateException(TAG + " init interrupted"); } } if (!terminated) { if (!terminated) { Loading @@ -160,11 +169,13 @@ public class SystemServerInitThreadPool { synchronized (sInstance.mPendingTasks) { synchronized (sInstance.mPendingTasks) { copy.addAll(sInstance.mPendingTasks); copy.addAll(sInstance.mPendingTasks); } } t.traceEnd(); throw new IllegalStateException("Cannot shutdown. Unstarted tasks " throw new IllegalStateException("Cannot shutdown. Unstarted tasks " + unstartedRunnables + " Unfinished tasks " + copy); + unstartedRunnables + " Unfinished tasks " + copy); } } sInstance = null; // Make eligible for GC sInstance = null; // Make eligible for GC Slog.d(TAG, "Shutdown successful"); Slog.d(TAG, "Shutdown successful"); t.traceEnd(); } } } } Loading