lttng: Rework the IRQ event handler
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 1 May 2012 22:05:50 +0000 (18:05 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 2 May 2012 03:33:28 +0000 (23:33 -0400)
Implement the softIrq handlers. Drop the IRQ_stack sub-tree,
put the IRQ stuff under Resources/IRQs and Resources/Soft_IRQs.

This matches more closely what is needed by the Resource view.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Attributes.java
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngStrings.java

index 47ab2e746e0ceff4e5e69c4d21b5907512f95659..2a69e57183c64210d2738c94c86fe9e92bf4be7d 100644 (file)
@@ -216,14 +216,14 @@ public class StateSystemFullHistoryTest {
 
         List<ITmfStateInterval> intervals;
         
-        int quark = ssb.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.IRQ_STACK);
+        int quark = ssb.getQuarkAbsolute(Attributes.RESOURCES, Attributes.IRQS, "1");
         long ts1 = ssb.getStartTime(); /* start of the trace */
         long ts2 = CtfTestFiles.startTime + 20L * CtfTestFiles.NANOSECS_PER_SEC; /* invalid, but ignored */
 
         intervals = ssb.queryHistoryRange(quark, ts1, ts2);
 
-        /* Nb of IRQs on CPU 0 during the whole trace */
-        assertEquals(1653, intervals.size());
+        /* Activity of IRQ 1 over the whole trace */
+        assertEquals(65, intervals.size());
     }
 
     /**
index fb749820037b93c3ffb371bb9d417e31dbcaf152..90b792b563b0c9d4c2668e85d79b075cb54b9322 100644 (file)
@@ -53,6 +53,8 @@ class CtfKernelHandler implements Runnable {
     /* Common locations in the attribute tree */
     private int cpusNode = -1;
     private int threadsNode = -1;
+    private int irqsNode = -1;
+    private int softIrqsNode = -1;
 
     CtfKernelHandler(BlockingQueue<CtfTmfEvent> eventsQueue) {
         assert (eventsQueue != null);
@@ -136,8 +138,7 @@ class CtfKernelHandler implements Runnable {
         try {
             /*
              * Feed event to the history system if it's known to cause a state
-             * transition See:
-             * https://projectwiki.dorsal.polymtl.ca/index.php/State_transitions
+             * transition.
              */
             switch (getEventIndex(eventName)) {
 
@@ -164,14 +165,15 @@ class CtfKernelHandler implements Runnable {
             {
                 Integer irqId = ((Long) content.getField(LttngStrings.IRQ).getValue()).intValue();
 
-                /* Push the IRQ to the CPU's IRQ_stack */
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.IRQ_STACK);
-                value = TmfStateValue.newValueInt(irqId);
-                ss.pushAttribute(ts, value, quark);
+                /* Mark this IRQ as active in the resource tree.
+                 * The state value = the CPU on which this IRQ is sitting */
+                quark = ss.getQuarkRelativeAndAdd(irqsNode, irqId.toString());
+                value = TmfStateValue.newValueInt(event.getCPU());
+                ss.modifyAttribute(ts, value, quark);
 
                 /* Change the status of the running process to interrupted */
                 quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                value = TmfStateValue.newValueInt(Attributes.STATUS_WAIT_CPU);
+                value = TmfStateValue.newValueInt(Attributes.STATUS_INTERRUPTED);
                 ss.modifyAttribute(ts, value, quark);
             }
                 break;
@@ -179,46 +181,66 @@ class CtfKernelHandler implements Runnable {
             case 3: // "irq_handler_exit":
             /* Fields: int32 irq, int32 ret */
             {
-                int stackDepth = 0;
+                Integer irqId = ((Long) content.getField(LttngStrings.IRQ).getValue()).intValue();
 
-                /* Pop the IRQ from the CPU's IRQ_stack */
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.IRQ_STACK);
-                try {
-                    ss.popAttribute(ts, quark);
-                } catch (AttributeNotFoundException e1) {
-                    System.err.print(event.getTimestamp()
-                            + " Popping empty attribute: " + e1.getMessage()); //$NON-NLS-1$
-                }
+                /* Put this IRQ back to inactive in the resource tree */
+                quark = ss.getQuarkRelativeAndAdd(irqsNode, irqId.toString());
+                value = TmfStateValue.nullValue();
+                ss.modifyAttribute(ts, value, quark);
 
-                /*
-                 * If this was the last IRQ on the stack, set the process back
-                 * to running
-                 */
-                /* 'quark' should still be valid */
-                try {
-                    stackDepth = ss.queryOngoingState(quark).unboxInt();
-                } catch (StateValueTypeException e) {
-                    /* IRQ_stack SHOULD be of int type, this shouldn't happen */
-                    e.printStackTrace();
-                }
-                if (stackDepth == 0) {
-                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                    value = TmfStateValue.newValueInt(Attributes.STATUS_RUN);
-                    ss.modifyAttribute(ts, value, quark);
-                }
+                /* Set the previous process back to running */
+                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                value = TmfStateValue.newValueInt(Attributes.STATUS_RUN);
+                ss.modifyAttribute(ts, value, quark);
             }
                 break;
 
             case 4: // "softirq_entry":
             /* Fields: int32 vec */
+            {
+                Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
+
+                /* Mark this SoftIRQ as active in the resource tree.
+                 * The state value = the CPU on which this SoftIRQ is processed */
+                quark = ss.getQuarkRelativeAndAdd(softIrqsNode, softIrqId.toString());
+                value = TmfStateValue.newValueInt(event.getCPU());
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Change the status of the running process to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                value = TmfStateValue.newValueInt(Attributes.STATUS_INTERRUPTED);
+                ss.modifyAttribute(ts, value, quark);
+            }
                 break;
 
             case 5: // "softirq_exit":
             /* Fields: int32 vec */
+            {
+                Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
+
+                /* Put this SoftIRQ back to inactive (= -1) in the resource tree */
+                quark = ss.getQuarkRelativeAndAdd(softIrqsNode, softIrqId.toString());
+                value = TmfStateValue.nullValue();
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the previous process back to running */
+                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                value = TmfStateValue.newValueInt(Attributes.STATUS_RUN);
+                ss.modifyAttribute(ts, value, quark);
+            }
                 break;
 
             case 6: // "softirq_raise":
-                /* Fields: int32 vec */
+            /* Fields: int32 vec */
+            {
+                Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
+
+                /* Mark this SoftIRQ as *raised* in the resource tree.
+                 * State value = -2 */
+                quark = ss.getQuarkRelativeAndAdd(softIrqsNode, softIrqId.toString());
+                value = TmfStateValue.newValueInt(-2);
+                ss.modifyAttribute(ts, value, quark);
+            }
                 break;
 
             case 7: // "sched_switch":
@@ -405,6 +427,8 @@ class CtfKernelHandler implements Runnable {
     private void setupCommonLocations() {
         cpusNode = ss.getQuarkAbsoluteAndAdd(Attributes.CPUS);
         threadsNode = ss.getQuarkAbsoluteAndAdd(Attributes.THREADS);
+        irqsNode = ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.IRQS);
+        softIrqsNode = ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.SOFT_IRQS);
     }
 
     private static HashMap<String, Integer> fillEventNames() {
index 4b62fac8411ec20329bc45957b015e4f233018da..5f01a744638637d2a89e51efcbb53b85c526259c 100644 (file)
@@ -30,9 +30,9 @@ public abstract class Attributes {
     /* First-level attributes */
     public static final String CPUS = "CPUs";
     public static final String THREADS = "Threads";
+    public static final String RESOURCES = "Resources";
 
     /* Sub-attributes of the CPU nodes */
-    public static final String IRQ_STACK = "IRQ_stack";
     public static final String CURRENT_THREAD = "Current_thread";
 
     /* Sub-attributes of the Thread nodes */
@@ -41,6 +41,10 @@ public abstract class Attributes {
     public static final String EXEC_NAME = "Exec_name";
     public static final String EXEC_MODE_STACK = "Exec_mode_stack";
 
+    /* Attributes under "Resources" */
+    public static final String IRQS = "IRQs";
+    public static final String SOFT_IRQS = "Soft_IRQs";
+
     /* 
      * Statistics sub-nodes
      * (Written all out, because "Stats" is easy to confuse with "Status")
@@ -51,6 +55,10 @@ public abstract class Attributes {
     /* Process status (note these are *values*, not attribute names */
     public static final int STATUS_WAIT_CPU = 1;
     public static final int STATUS_RUN = 2;
+    public static final int STATUS_INTERRUPTED = 3;
+
+    /* SoftIRQ-specific stuff. -1: null/disabled, >= 0: running on that CPU */
+    public static final int SOFT_IRQ_RAISED = -2;
 
     /* Misc stuff */
     public static final String UNKNOWN = "Unknown";
index 68afb8e234a72c68115c95b723c6039f60567c42..1dd37d2229aadee6df263831792a1888ef1c6d69 100644 (file)
@@ -41,11 +41,11 @@ public abstract class LttngStrings {
     public static final String SYSCALL_PREFIX = "sys_";
     public static final String COMPAT_SYSCALL_PREFIX = "compat_sys_";
 
-
     /* Field names */
     public static final String IRQ = "irq";
     public static final String COMM = "comm";
     public static final String TID = "tid";
+    public static final String VEC = "vec";
     public static final String PREV_COMM = "prev_comm";
     public static final String PREV_TID = "prev_tid";
     public static final String PREV_STATE = "prev_state";
This page took 0.030398 seconds and 5 git commands to generate.