From 0655253223160e4d1622b20ed8a4cf3c9556ffb9 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Tue, 1 May 2012 18:05:50 -0400 Subject: [PATCH] lttng: Rework the IRQ event handler 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 --- .../StateSystemFullHistoryTest.java | 6 +- .../core/stateprovider/CtfKernelHandler.java | 90 ++++++++++++------- .../lttng2/kernel/core/trace/Attributes.java | 10 ++- .../kernel/core/trace/LttngStrings.java | 2 +- 4 files changed, 70 insertions(+), 38 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java index 47ab2e746e..2a69e57183 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java @@ -216,14 +216,14 @@ public class StateSystemFullHistoryTest { List 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()); } /** diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java index fb74982003..90b792b563 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/CtfKernelHandler.java @@ -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 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 fillEventNames() { diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Attributes.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Attributes.java index 4b62fac841..5f01a74463 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Attributes.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/Attributes.java @@ -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"; diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngStrings.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngStrings.java index 68afb8e234..1dd37d2229 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngStrings.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngStrings.java @@ -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"; -- 2.34.1