diff options
| author | 2024-07-10 09:28:23 +0000 | |
|---|---|---|
| committer | 2024-07-10 09:28:23 +0000 | |
| commit | 2caf6f9fc74ba4274ad6325cea2fec1403668255 (patch) | |
| tree | f817874d85c52d1b41364ecc240c2098d45693bc | |
| parent | 20af3c7e3b3c6ea024cd64c3241c4964626cce9f (diff) | |
Revert "trace-ipc: Don't hold procLock while calling out."
This reverts commit 20af3c7e3b3c6ea024cd64c3241c4964626cce9f.
Reason for revert: <Droidmonitor created revert due to b/352251767. Will be verifying through ABTD before submission.>
Change-Id: I8459761e181981ba9ec14c38c83d29e654638a72
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index dffbaad2a209..1b59c1829d4c 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18333,55 +18333,43 @@ public class ActivityManagerService extends IActivityManager.Stub boolean closeFd = true; try { - Objects.requireNonNull(fd); - - record ProcessToDump(String processName, IApplicationThread thread) { } - - PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor())); - pw.println("Binder transaction traces for all processes.\n"); - final ArrayList<ProcessToDump> processes = new ArrayList<>(); synchronized (mProcLock) { - // Since dumping binder transactions is a long-running operation, we can't do it - // with mProcLock held. Do the initial verification here, and save the processes - // to dump later outside the lock. - final ArrayList<ProcessRecord> unverifiedProcesses = - new ArrayList<>(mProcessList.getLruProcessesLOSP()); - for (int i = 0, size = unverifiedProcesses.size(); i < size; i++) { - ProcessRecord process = unverifiedProcesses.get(i); + if (fd == null) { + throw new IllegalArgumentException("null fd"); + } + mBinderTransactionTrackingEnabled = false; + + PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor())); + pw.println("Binder transaction traces for all processes.\n"); + mProcessList.forEachLruProcessesLOSP(true, process -> { final IApplicationThread thread = process.getThread(); if (!processSanityChecksLPr(process, thread)) { - continue; + return; } - processes.add(new ProcessToDump(process.processName, process.getThread())); - } - mBinderTransactionTrackingEnabled = false; - } - for (int i = 0, size = processes.size(); i < size; i++) { - final String processName = processes.get(i).processName(); - final IApplicationThread thread = processes.get(i).thread(); - pw.println("Traces for process: " + processName); - pw.flush(); - try { - TransferPipe tp = new TransferPipe(); + pw.println("Traces for process: " + process.processName); + pw.flush(); try { - thread.stopBinderTrackingAndDump(tp.getWriteFd()); - tp.go(fd.getFileDescriptor()); - } finally { - tp.kill(); + TransferPipe tp = new TransferPipe(); + try { + thread.stopBinderTrackingAndDump(tp.getWriteFd()); + tp.go(fd.getFileDescriptor()); + } finally { + tp.kill(); + } + } catch (IOException e) { + pw.println("Failure while dumping IPC traces from " + process + + ". Exception: " + e); + pw.flush(); + } catch (RemoteException e) { + pw.println("Got a RemoteException while dumping IPC traces from " + + process + ". Exception: " + e); + pw.flush(); } - } catch (IOException e) { - pw.println("Failure while dumping IPC traces from " + processName + - ". Exception: " + e); - pw.flush(); - } catch (RemoteException e) { - pw.println("Got a RemoteException while dumping IPC traces from " + - processName + ". Exception: " + e); - pw.flush(); - } + }); + closeFd = false; + return true; } - closeFd = false; - return true; } finally { if (fd != null && closeFd) { try { |