@SuppressWarnings("javadoc")
public interface StateValues {
- /* CPU Status */
- int CPU_STATUS_IDLE = 0;
- int CPU_STATUS_RUN_USERMODE = 1;
- int CPU_STATUS_RUN_SYSCALL = 2;
- int CPU_STATUS_IRQ = 3;
- int CPU_STATUS_SOFTIRQ = 4;
-
- ITmfStateValue CPU_STATUS_IDLE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IDLE);
- ITmfStateValue CPU_STATUS_RUN_USERMODE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_USERMODE);
- ITmfStateValue CPU_STATUS_RUN_SYSCALL_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_SYSCALL);
- ITmfStateValue CPU_STATUS_IRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IRQ);
- ITmfStateValue CPU_STATUS_SOFTIRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_SOFTIRQ);
-
/* Process status */
int PROCESS_STATUS_UNKNOWN = 0;
int PROCESS_STATUS_WAIT_BLOCKED = 1;
ITmfStateValue PROCESS_STATUS_INTERRUPTED_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_INTERRUPTED);
ITmfStateValue PROCESS_STATUS_WAIT_FOR_CPU_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_WAIT_FOR_CPU);
- /* SoftIRQ-specific stuff. -1: null/disabled, >= 0: running on that CPU */
- int SOFT_IRQ_RAISED = -2;
+ /* CPU Status */
+ int CPU_STATUS_IDLE = 0;
+ /**
+ * Soft IRQ raised, could happen in the CPU attribute but should not since
+ * this means that the CPU went idle when a softirq was raised.
+ *
+ * @since 2.0
+ */
+ int CPU_STATUS_SOFT_IRQ_RAISED = (1 << 0);
+ int CPU_STATUS_RUN_USERMODE = (1 << 1);
+ int CPU_STATUS_RUN_SYSCALL = (1 << 2);
+ int CPU_STATUS_SOFTIRQ = (1 << 3);
+ int CPU_STATUS_IRQ = (1 << 4);
+
+ ITmfStateValue CPU_STATUS_IDLE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IDLE);
+ ITmfStateValue CPU_STATUS_RUN_USERMODE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_USERMODE);
+ ITmfStateValue CPU_STATUS_RUN_SYSCALL_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_SYSCALL);
+ ITmfStateValue CPU_STATUS_IRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IRQ);
+ ITmfStateValue CPU_STATUS_SOFTIRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_SOFTIRQ);
+
+ /** Soft IRQ is raised, CPU is in user mode */
+ ITmfStateValue SOFT_IRQ_RAISED_VALUE = TmfStateValue.newValueInt(CPU_STATUS_SOFT_IRQ_RAISED);
- ITmfStateValue SOFT_IRQ_RAISED_VALUE = TmfStateValue.newValueInt(SOFT_IRQ_RAISED);
+ /**
+ * If the softirq is running and another is raised at the same time.
+ *
+ * @since 2.0
+ */
+ ITmfStateValue SOFT_IRQ_RAISED_RUNNING_VALUE = TmfStateValue.newValueInt(CPU_STATUS_SOFT_IRQ_RAISED | CPU_STATUS_SOFTIRQ);
}
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
/**
long timestamp = KernelEventHandlerUtils.getTimestamp(event);
Integer softIrqId = ((Long) event.getContent().getField(getLayout().fieldVec()).getValue()).intValue();
int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
- int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu,ss);
+ int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
/*
- * Mark this SoftIRQ as active in the resource tree. The state value =
- * the CPU on which this SoftIRQ is processed
+ * Mark this SoftIRQ as active in the resource tree.
*/
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
- ITmfStateValue value = TmfStateValue.newValueInt(cpu.intValue());
+ ITmfStateValue value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
ss.modifyAttribute(timestamp, value, quark);
/* Change the status of the running process to interrupted */
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
/* Put this SoftIRQ back to inactive (= -1) in the resource tree */
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
- ITmfStateValue value = TmfStateValue.nullValue();
long timestamp = KernelEventHandlerUtils.getTimestamp(event);
-
- ss.modifyAttribute(timestamp, value, quark);
-
+ if (isSoftIrqRaised(ss.queryOngoingState(quark))) {
+ ss.modifyAttribute(timestamp, StateValues.SOFT_IRQ_RAISED_VALUE, quark);
+ } else {
+ ss.modifyAttribute(timestamp, TmfStateValue.nullValue(), quark);
+ }
+ List<Integer> softIrqs = ss.getSubAttributes(ss.getParentAttributeQuark(quark), false);
+ /* Only set status to running and no exit if ALL softirqs are exited. */
+ for (Integer softIrq : softIrqs) {
+ if (!ss.queryOngoingState(softIrq).isNull()) {
+ return;
+ }
+ }
/* Set the previous process back to running */
KernelEventHandlerUtils.setProcessToRunning(timestamp, currentThreadNode, ss);
KernelEventHandlerUtils.cpuExitInterrupt(timestamp, cpu, ss);
}
+ /**
+ * This checks if the running <stong>bit</strong> is set
+ *
+ * @param state
+ * the state to check
+ * @return true if in a softirq. The softirq may be pre-empted by an irq
+ */
+ private static boolean isSoftIrqRaised(@Nullable ITmfStateValue state) {
+ return (state != null &&
+ !state.isNull() &&
+ (state.unboxInt() & StateValues.CPU_STATUS_SOFT_IRQ_RAISED) == StateValues.CPU_STATUS_SOFT_IRQ_RAISED);
+ }
+
}
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
return;
}
/*
- * Mark this SoftIRQ as *raised* in the resource tree. State value = -2
+ * Mark this SoftIRQ as *raised* in the resource tree.
*/
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
- ITmfStateValue value = StateValues.SOFT_IRQ_RAISED_VALUE;
+
+ ITmfStateValue value = (isInSoftirq(ss.queryOngoingState(quark)) ?
+ StateValues.SOFT_IRQ_RAISED_RUNNING_VALUE :
+ StateValues.SOFT_IRQ_RAISED_VALUE);
ss.modifyAttribute(KernelEventHandlerUtils.getTimestamp(event), value, quark);
+
+ }
+
+ private static boolean isInSoftirq(@Nullable ITmfStateValue state) {
+ return (state != null &&
+ !state.isNull() &&
+ (state.unboxInt() & StateValues.CPU_STATUS_SOFTIRQ) == StateValues.CPU_STATUS_SOFTIRQ);
}
}
} else if (entry.getType() == Type.IRQ) {
return State.IRQ_ACTIVE;
} else if (entry.getType() == Type.SOFT_IRQ) {
- if (value == StateValues.SOFT_IRQ_RAISED) {
+ if (value == StateValues.CPU_STATUS_SOFT_IRQ_RAISED) {
return State.SOFT_IRQ_RAISED;
}
return State.SOFT_IRQ_ACTIVE;
/*******************************************************************************
- * Copyright (c) 2013, 2015 Ericsson
+ * Copyright (c) 2013, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.newValueInt(1397),
- TmfStateValue.newValueInt(1),
+ TmfStateValue.newValueInt(2),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.newValueInt(1432),
- TmfStateValue.newValueInt(2),
+ TmfStateValue.newValueInt(4),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),
TmfStateValue.nullValue(),