KernelAnalysis: Use CPUs CoreAttributes to store "Status"
authorLoïc Prieur-Drevon <loic.prieurdrevon@gmail.com>
Fri, 15 Apr 2016 15:04:23 +0000 (11:04 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 15 Sep 2016 13:17:57 +0000 (09:17 -0400)
CPUs core attributes were not used to store interval data, this
leads to useless NullStateValue intervals ranging from tree start
to end. This patch uses the CPUs CoreNodes to store the "Status"
fields thus reducing the number of attributes and intervals.

Change-Id: I4b7953efff14879ea2eabe72200138f9be682c09
Signed-off-by: Loïc Prieur-Drevon <loic.prieurdrevon@gmail.com>
Reviewed-on: https://git.eclipse.org/r/70770
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/Attributes.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/IPIEntryHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/IrqEntryHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/KernelEventHandlerUtils.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SoftIrqEntryHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SysEntryHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SysExitHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/resources/ResourcesView.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/TestValues.java

index 89e370d738777756ef0410afc1c6914bcef3455c..e8889f3ce65d25b3d3bc8db0fa1fe055bbed42a8 100644 (file)
@@ -32,13 +32,11 @@ public interface Attributes {
 
     /* Sub-attributes of the CPU nodes */
     String CURRENT_THREAD = "Current_thread";
-    String STATUS = "Status";
     String SOFT_IRQS = "Soft_IRQs";
     String IRQS = "IRQs";
 
     /* Sub-attributes of the Thread nodes */
     String PPID = "PPID";
-    // static final String STATUS = "Status"
     String EXEC_NAME = "Exec_name";
 
     String PRIO = "Prio";
index f6bceb73eb07d711c24ac42c786c782a872651cc..6d040ce288ff66382c50f76d9f3651cecbf990f6 100644 (file)
@@ -61,7 +61,7 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
      * Version number of this state provider. Please bump this if you modify the
      * contents of the generated state history in some way.
      */
-    private static final int VERSION = 19;
+    private static final int VERSION = 20;
 
     // ------------------------------------------------------------------------
     // Fields
index 20a2ca2c8e34833475035aabb957922440db60bf..a5fd42131a9b3a6f8e3ee9d3a1aacfce998670cf 100644 (file)
@@ -11,7 +11,6 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
@@ -55,12 +54,12 @@ public class IPIEntryHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, quark);
 
         /* Change the status of the running process to interrupted */
-        quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss), Attributes.STATUS);
+        quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss));
         value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
         ss.modifyAttribute(timestamp, value, quark);
 
         /* Change the status of the CPU to interrupted */
-        quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss), Attributes.STATUS);
+        quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss));
         value = StateValues.CPU_STATUS_IRQ_VALUE;
         ss.modifyAttribute(timestamp, value, quark);
     }
index a9697714046cf314d59f959324334c060cea2b89..dcf4554491b891e45d878b744546532930930e1e 100644 (file)
@@ -14,7 +14,6 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
@@ -61,7 +60,7 @@ public class IrqEntryHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, quark);
 
         /* Change the status of the CPU to interrupted */
-        quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss), Attributes.STATUS);
+        quark = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
         value = StateValues.CPU_STATUS_IRQ_VALUE;
         ss.modifyAttribute(timestamp, value, quark);
     }
index 85780c32a645785de3a5768345d781d3878b5368..2776163c05b46617e5e8f60126bef6b02b3ec0d2 100644 (file)
@@ -198,12 +198,10 @@ public final class KernelEventHandlerUtils {
      */
     public static void cpuExitInterrupt(long timestamp, Integer cpuNumber, ITmfStateSystemBuilder ssb)
             throws StateValueTypeException, TimeRangeException {
-        int quark;
         int currentCPUNode = getCurrentCPUNode(cpuNumber, ssb);
 
-        quark = ssb.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
         ITmfStateValue value = getCpuStatus(ssb, currentCPUNode);
-        ssb.modifyAttribute(timestamp, value, quark);
+        ssb.modifyAttribute(timestamp, value, currentCPUNode);
     }
 
     /**
index 5355f390aecc04c3fddda1e169fbaa3381ca2ec3..ef4fc47b8627fd261edb1a36d1d66aa6cd5be643 100644 (file)
@@ -151,8 +151,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         } else {
             value = StateValues.CPU_STATUS_IDLE_VALUE;
         }
-        quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-        ss.modifyAttribute(timestamp, value, quark);
+        ss.modifyAttribute(timestamp, value, currentCPUNode);
     }
 
     private static void setCpuProcess(ITmfStateSystemBuilder ss, Integer nextTid, long timestamp, int currentCPUNode) {
index 664ea331f38d6667a97ec1ec913e6454c65bd3ec..fd2c22c9c7c2c6c9661f9bcc017d0f106d83aa76 100644 (file)
@@ -14,7 +14,6 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
@@ -59,8 +58,7 @@ public class SoftIrqEntryHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, currentThreadNode);
 
         /* Change the status of the CPU to interrupted */
-        quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
         value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
-        ss.modifyAttribute(timestamp, value, quark);
+        ss.modifyAttribute(timestamp, value, currentCPUNode);
     }
 }
index f2b4ed27b81fef09688f4c27f4c77250b79dcfe5..6df8e145c7f98997af88927a0ac42d8c143f93f4 100644 (file)
@@ -55,9 +55,8 @@ public class SysEntryHandler extends KernelEventHandler {
 
         /* Put the CPU in system call (kernel) mode */
         int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
-        quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
         value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
-        ss.modifyAttribute(timestamp, value, quark);
+        ss.modifyAttribute(timestamp, value, currentCPUNode);
     }
 
 }
index 2841d3612cf377cb76fe55c440bb7a81119c9698..a898f936f3f8622bce63264bef454549d635242c 100644 (file)
@@ -55,9 +55,8 @@ public class SysExitHandler extends KernelEventHandler {
 
         /* Put the CPU in system call (kernel) mode */
         int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
-        quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
         value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
-        ss.modifyAttribute(timestamp, value, quark);
+        ss.modifyAttribute(timestamp, value, currentCPUNode);
     }
 
 }
index 23ca9beb04e496a817335456bdadc5111da271c5..a51d637b8e380e045bea454a56dd8d2af23e1223 100644 (file)
@@ -36,7 +36,6 @@ import org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowCpuA
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.UnfollowCpuAction;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesEntry.Type;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
@@ -337,7 +336,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         int quark = resourcesEntry.getQuark();
 
         if (resourcesEntry.getType().equals(Type.CPU)) {
-            return createCpuEventsList(entry, ssq, fullStates, prevFullState, monitor, quark);
+            return createCpuEventsList(entry, fullStates, prevFullState, monitor, quark);
         } else if ((resourcesEntry.getType().equals(Type.IRQ) || resourcesEntry.getType().equals(Type.SOFT_IRQ)) && (quark >= 0)) {
             return createIrqEventsList(entry, fullStates, prevFullState, monitor, quark);
         }
@@ -345,32 +344,22 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         return null;
     }
 
-    private static List<ITimeEvent> createCpuEventsList(ITimeGraphEntry entry, ITmfStateSystem ssq, List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState, IProgressMonitor monitor, int quark) {
+    private static List<ITimeEvent> createCpuEventsList(ITimeGraphEntry entry, List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState, IProgressMonitor monitor, int quark) {
         List<ITimeEvent> eventList;
-        int statusQuark;
-        try {
-            statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);
-        } catch (AttributeNotFoundException e) {
-            /*
-             * The sub-attribute "status" is not available. May happen if the
-             * trace does not have sched_switch events enabled.
-             */
-            return null;
-        }
         boolean isZoomThread = Thread.currentThread() instanceof ZoomThread;
         eventList = new ArrayList<>(fullStates.size());
-        ITmfStateInterval lastInterval = prevFullState == null || statusQuark >= prevFullState.size() ? null : prevFullState.get(statusQuark);
+        ITmfStateInterval lastInterval = prevFullState == null || quark >= prevFullState.size() ? null : prevFullState.get(quark);
         long lastStartTime = lastInterval == null ? -1 : lastInterval.getStartTime();
         long lastEndTime = lastInterval == null ? -1 : lastInterval.getEndTime() + 1;
         for (List<ITmfStateInterval> fullState : fullStates) {
             if (monitor.isCanceled()) {
                 return null;
             }
-            if (statusQuark >= fullState.size()) {
+            if (quark >= fullState.size()) {
                 /* No information on this CPU (yet?), skip it for now */
                 continue;
             }
-            ITmfStateInterval statusInterval = fullState.get(statusQuark);
+            ITmfStateInterval statusInterval = fullState.get(quark);
             int status = statusInterval.getStateValue().unboxInt();
             long time = statusInterval.getStartTime();
             long duration = statusInterval.getEndTime() - time + 1;
index 4dae05ece4446f1592dca25553985a30c442fd67..2de3b167b681d9aa3315629ffc315334a17ed3a8 100644 (file)
@@ -25,7 +25,7 @@ import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
  */
 interface TestValues {
 
-    int size = 871;
+    int size = 869;
 
     long[] startTimes = {
         1331668247314038062L,
@@ -38,9 +38,8 @@ interface TestValues {
         1331668247316120937L,
         1331668247314038062L,
         1331668247314038062L,
-        1331668247314038062L,
-        1331668248014145796L,
         1331668248014183954L,
+        1331668248014145796L,
         1331668247314851888L,
         1331668247327098502L,
         1331668247327098502L,
@@ -59,9 +58,8 @@ interface TestValues {
         1331668248013353414L,
         1331668247314607227L,
         1331668247314607227L,
-        1331668247314038062L,
-        1331668248014184526L,
         1331668248014130616L,
+        1331668248014184526L,
         1331668247314038062L,
         1331668248011090056L,
         1331668247931793142L,
@@ -912,9 +910,8 @@ interface TestValues {
         1331668259054285979L,
         1331668259054285979L,
         1331668259054285979L,
-        1331668259054285979L,
-        1331668248014620024L,
         1331668248014185078L,
+        1331668248014620024L,
         1331668259054285979L,
         1331668259054285979L,
         1331668259054285979L,
@@ -933,9 +930,8 @@ interface TestValues {
         1331668248015333196L,
         1331668259054285979L,
         1331668259054285979L,
-        1331668259054285979L,
-        1331668248014548923L,
         1331668248014188534L,
+        1331668248014548923L,
         1331668259054285979L,
         1331668248015040151L,
         1331668248482983146L,
@@ -1786,9 +1782,8 @@ interface TestValues {
         TmfStateValue.newValueInt(20),
         TmfStateValue.nullValue(),
         TmfStateValue.nullValue(),
-        TmfStateValue.nullValue(),
-        TmfStateValue.newValueInt(1397),
         TmfStateValue.newValueInt(2),
+        TmfStateValue.newValueInt(1397),
         TmfStateValue.nullValue(),
         TmfStateValue.nullValue(),
         TmfStateValue.nullValue(),
@@ -1807,9 +1802,8 @@ interface TestValues {
         TmfStateValue.newValueInt(5),
         TmfStateValue.newValueString("swapper/1"),
         TmfStateValue.newValueInt(20),
-        TmfStateValue.nullValue(),
-        TmfStateValue.newValueInt(1432),
         TmfStateValue.newValueInt(4),
+        TmfStateValue.newValueInt(1432),
         TmfStateValue.nullValue(),
         TmfStateValue.nullValue(),
         TmfStateValue.newValueInt(1),
This page took 0.032654 seconds and 5 git commands to generate.