Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2013-06-04 20:06:37 +0000
committerAlexandre Montplaisir2013-06-05 14:41:30 +0000
commit7e6bde75f5cb6c0a8a766e8464184678316e80c8 (patch)
tree86319818cfb3b7cd4bb8dffe91e49190f7886d35
parent73902cfd92a0c51cb7971297492e8cd962dc1bb9 (diff)
downloadorg.eclipse.linuxtools-7e6bde75f5cb6c0a8a766e8464184678316e80c8.tar.gz
org.eclipse.linuxtools-7e6bde75f5cb6c0a8a766e8464184678316e80c8.tar.xz
org.eclipse.linuxtools-7e6bde75f5cb6c0a8a766e8464184678316e80c8.zip
lttng: Also initialize static state values
Instead of just defining the integers statically, we can also define the matching state value objects themselves. This can potentially save a lot of object allocations during state system construction. Some allocations will still be needed for state values that are only known at run-time. Change-Id: I3839c7685f64adf5bec1a41bd6dc342d24fdb529 Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-on: https://git.eclipse.org/r/13564 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/StateValues.java18
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java48
2 files changed, 42 insertions, 24 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/StateValues.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/StateValues.java
index 928d67a0c5..8584912d19 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/StateValues.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/StateValues.java
@@ -12,6 +12,9 @@
package org.eclipse.linuxtools.internal.lttng2.kernel.core;
+import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
+
/**
* State values that are used in the kernel event handler. It's much better to
* use integer values whenever possible, since those take much less space in the
@@ -30,6 +33,12 @@ public interface StateValues {
static final int CPU_STATUS_IRQ = 3;
static final int CPU_STATUS_SOFTIRQ = 4;
+ static final ITmfStateValue CPU_STATUS_IDLE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IDLE);
+ static final ITmfStateValue CPU_STATUS_RUN_USERMODE_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_USERMODE);
+ static final ITmfStateValue CPU_STATUS_RUN_SYSCALL_VALUE = TmfStateValue.newValueInt(CPU_STATUS_RUN_SYSCALL);
+ static final ITmfStateValue CPU_STATUS_IRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_IRQ);
+ static final ITmfStateValue CPU_STATUS_SOFTIRQ_VALUE = TmfStateValue.newValueInt(CPU_STATUS_SOFTIRQ);
+
/* Process status */
static final int PROCESS_STATUS_UNKNOWN = 0;
static final int PROCESS_STATUS_WAIT_BLOCKED = 1;
@@ -38,6 +47,15 @@ public interface StateValues {
static final int PROCESS_STATUS_INTERRUPTED = 4;
static final int PROCESS_STATUS_WAIT_FOR_CPU = 5;
+ static final ITmfStateValue PROCESS_STATUS_UNKNOWN_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_UNKNOWN);
+ static final ITmfStateValue PROCESS_STATUS_WAIT_BLOCKED_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_WAIT_BLOCKED);
+ static final ITmfStateValue PROCESS_STATUS_RUN_USERMODE_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_RUN_USERMODE);
+ static final ITmfStateValue PROCESS_STATUS_RUN_SYSCALL_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_RUN_SYSCALL);
+ static final ITmfStateValue PROCESS_STATUS_INTERRUPTED_VALUE = TmfStateValue.newValueInt(PROCESS_STATUS_INTERRUPTED);
+ static final 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 */
static final int SOFT_IRQ_RAISED = -2;
+
+ static final ITmfStateValue SOFT_IRQ_RAISED_VALUE = TmfStateValue.newValueInt(SOFT_IRQ_RAISED);
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java
index f818005eba..5f62847254 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/internal/lttng2/kernel/core/stateprovider/LttngKernelStateProvider.java
@@ -128,12 +128,12 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Put the process' status back to user mode */
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
+ value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
ss.modifyAttribute(ts, value, quark);
/* Put the CPU's status back to user mode */
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
ss.modifyAttribute(ts, value, quark);
}
break;
@@ -151,12 +151,12 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Change the status of the running process to interrupted */
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
+ value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
ss.modifyAttribute(ts, value, quark);
/* Change the status of the CPU to interrupted */
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IRQ);
+ value = StateValues.CPU_STATUS_IRQ_VALUE;
ss.modifyAttribute(ts, value, quark);
}
break;
@@ -192,12 +192,12 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Change the status of the running process to interrupted */
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
+ value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
ss.modifyAttribute(ts, value, quark);
/* Change the status of the CPU to interrupted */
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_SOFTIRQ);
+ value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
ss.modifyAttribute(ts, value, quark);
}
break;
@@ -228,7 +228,7 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Mark this SoftIRQ as *raised* in the resource tree.
* State value = -2 */
quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(), softIrqId.toString());
- value = TmfStateValue.newValueInt(StateValues.SOFT_IRQ_RAISED);
+ value = StateValues.SOFT_IRQ_RAISED_VALUE;
ss.modifyAttribute(ts, value, quark);
}
break;
@@ -250,9 +250,9 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Set the status of the process that got scheduled out. */
quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
if (prevState != 0) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
+ value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
} else {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
}
ss.modifyAttribute(ts, value, quark);
@@ -278,12 +278,12 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Check if the entering process is in kernel or user mode */
quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
if (ss.queryOngoingState(quark).isNull()) {
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
} else {
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
}
} else {
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
+ value = StateValues.CPU_STATUS_IDLE_VALUE;
}
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
ss.modifyAttribute(ts, value, quark);
@@ -316,7 +316,7 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Set the new process' status */
quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
ss.modifyAttribute(ts, value, quark);
/* Set the process' syscall name, to be the same as the parent's */
@@ -392,11 +392,11 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
if (ss.queryOngoingState(quark).isNull()) {
/* "2" here means "WAIT_FOR_CPU", and "5" "WAIT_BLOCKED" in the LTTng kernel. */
if (status == 2) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
} else if (status == 5) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
+ value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
} else {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_UNKNOWN);
+ value = StateValues.PROCESS_STATUS_UNKNOWN_VALUE;
}
ss.modifyAttribute(ts, value, quark);
}
@@ -417,7 +417,7 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
* run. Assign it to the "wait for cpu" state.
*/
quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
ss.modifyAttribute(ts, value, quark);
}
break;
@@ -439,12 +439,12 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
/* Put the process in system call mode */
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
+ value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
ss.modifyAttribute(ts, value, quark);
/* Put the CPU in system call (kernel) mode */
quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
ss.modifyAttribute(ts, value, quark);
}
}
@@ -548,10 +548,10 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
if (ss.queryOngoingState(quark).isNull()) {
/* We were in user mode before the interruption */
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
+ value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
} else {
/* We were previously in kernel mode */
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
+ value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
}
quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
ss.modifyAttribute(ts, value, quark);
@@ -573,14 +573,14 @@ public class LttngKernelStateProvider extends AbstractTmfStateProvider {
quark = ss.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
if (ss.queryOngoingState(quark).isNull()) {
/* That process was in user mode */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
} else {
/* That process was in a system call */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
}
} else {
/* There was no real process scheduled, CPU was idle */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
+ value = StateValues.CPU_STATUS_IDLE_VALUE;
}
quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
ss.modifyAttribute(ts, value, quark);

Back to the top