analysis.os: bug 488757: Let the KernelTidAspect block if not queryable
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 28 Apr 2016 13:38:30 +0000 (09:38 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 10 May 2016 00:42:55 +0000 (20:42 -0400)
This aspect implements the blocking resolve method and, if the caller
wishes, will block until the analysis is ready to be queried at the
time of the event. A progress monitor is used to allow for cancelling
the blocking call.

This patch updates the system call latency analysis to block.

Change-Id: Ie858bb4ed8984f6320af443030db4950ab5f7927
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/71604
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelTidAspect.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/SystemCallLatencyAnalysis.java

index e2a2a6d9cd9630724ff01e72e4bde525f277a68e..a6dcbbd78b9f0dd8963e034050356c292e907ed5 100644 (file)
@@ -12,6 +12,9 @@
 
 package org.eclipse.tracecompass.analysis.os.linux.core.kernel;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule;
@@ -31,11 +34,23 @@ public final class KernelTidAspect extends LinuxTidAspect {
     /** The singleton instance */
     public static final KernelTidAspect INSTANCE = new KernelTidAspect();
 
+    private static final IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
+
     private KernelTidAspect() {
     }
 
     @Override
     public @Nullable Integer resolve(ITmfEvent event) {
+        try {
+            return resolve(event, false, NULL_MONITOR);
+        } catch (InterruptedException e) {
+            /* Should not happen since there is nothing to interrupt */
+            return null;
+        }
+    }
+
+    @Override
+    public @Nullable Integer resolve(@NonNull ITmfEvent event, boolean block, final IProgressMonitor monitor) throws InterruptedException {
         /* Find the CPU this event is run on */
         Integer cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(),
                 TmfCpuAspect.class, event);
@@ -49,7 +64,11 @@ public final class KernelTidAspect extends LinuxTidAspect {
         if (analysis == null) {
             return null;
         }
-        return analysis.getThreadOnCpuAtTime(cpu, event.getTimestamp().toNanos());
+        long ts = event.getTimestamp().toNanos();
+        while (block && !analysis.isQueryable(ts) && !monitor.isCanceled()) {
+            Thread.sleep(100);
+        }
+        return analysis.getThreadOnCpuAtTime(cpu, ts);
     }
 
 }
index 912a6e4f65d1ee48bc7a28113320af68dbbc3878..e324337cf8b3f1b3c9f54be7edf5d4f896897721 100644 (file)
@@ -21,6 +21,8 @@ import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect;
@@ -96,6 +98,7 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent
 
         private final Map<Integer, SystemCall.InitialInfo> fOngoingSystemCalls = new HashMap<>();
         private @Nullable IKernelAnalysisEventLayout fLayout;
+        private final IProgressMonitor fMonitor = new NullProgressMonitor();
 
         public SyscallLatencyAnalysisRequest(ISegmentStore<ISegment> syscalls) {
             super(syscalls);
@@ -116,7 +119,12 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent
                     eventName.startsWith(layout.eventCompatSyscallEntryPrefix())) {
                 /* This is a system call entry event */
 
-                Integer tid = KernelTidAspect.INSTANCE.resolve(event);
+                Integer tid;
+                try {
+                    tid = KernelTidAspect.INSTANCE.resolve(event, true, fMonitor);
+                } catch (InterruptedException e) {
+                    return;
+                }
                 if (tid == null) {
                     // no information on this event/trace ?
                     return;
@@ -137,7 +145,12 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent
             } else if (eventName.startsWith(layout.eventSyscallExitPrefix())) {
                 /* This is a system call exit event */
 
-                Integer tid = KernelTidAspect.INSTANCE.resolve(event);
+                Integer tid;
+                try {
+                    tid = KernelTidAspect.INSTANCE.resolve(event, true, fMonitor);
+                } catch (InterruptedException e) {
+                    return;
+                }
                 if (tid == null) {
                     return;
                 }
@@ -161,6 +174,13 @@ public class SystemCallLatencyAnalysis extends AbstractSegmentStoreAnalysisEvent
         @Override
         public void handleCompleted() {
             fOngoingSystemCalls.clear();
+            super.handleCompleted();
+        }
+
+        @Override
+        public void handleCancel() {
+            fMonitor.setCanceled(true);
+            super.handleCancel();
         }
     }
 
This page took 0.02719 seconds and 5 git commands to generate.