use of org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus in project tracecompass by tracecompass.
the class TraceEventHandlerExecutionGraph method stateChange.
private TmfVertex stateChange(OsWorker task, long ts) {
TmfGraph graph = NonNullUtils.checkNotNull(getProvider().getAssignedGraph());
TmfVertex node = new TmfVertex(ts);
ProcessStatus status = task.getOldStatus();
graph.append(task, node, resolveProcessStatus(status));
return node;
}
use of org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus in project tracecompass by tracecompass.
the class TraceEventHandlerSched method handleSchedWakeup.
private void handleSchedWakeup(ITmfEvent event) {
String host = event.getTrace().getHostId();
Integer cpu = NonNullUtils.checkNotNull(TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event));
IKernelAnalysisEventLayout eventLayout = getProvider().getEventLayout(event.getTrace());
OsSystemModel system = getProvider().getSystem();
Integer tid = event.getContent().getFieldValue(Integer.class, eventLayout.fieldTid());
if (tid == null) {
return;
}
HostThread targetHt = new HostThread(host, tid);
OsWorker target = system.findWorker(targetHt);
OsWorker current = system.getWorkerOnCpu(host, cpu);
if (target == null) {
String name = EventField.getOrDefault(event, eventLayout.fieldComm(), NonNullUtils.checkNotNull(Messages.TraceEventHandlerSched_UnknownThreadName));
target = new OsWorker(targetHt, name, event.getTimestamp().getValue());
system.addWorker(target);
target.setStatus(ProcessStatus.WAIT_BLOCKED);
}
// spurious wakeup
ProcessStatus status = target.getStatus();
if ((current != null && target.getHostThread().equals(current.getHostThread())) || status == ProcessStatus.WAIT_CPU) {
return;
}
if (status == ProcessStatus.WAIT_BLOCKED || status == ProcessStatus.WAIT_FORK || status == ProcessStatus.UNKNOWN) {
target.setStatus(ProcessStatus.WAIT_CPU);
return;
}
}
use of org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus in project tracecompass by tracecompass.
the class KernelThreadInformationProviderTest method testGetStatusIntervalsForThread.
/**
* Test the
* {@link KernelThreadInformationProvider#getStatusIntervalsForThread(KernelAnalysisModule, Integer, long, long, long, IProgressMonitor)}
* method
*/
@Test
public void testGetStatusIntervalsForThread() {
KernelAnalysisModule module = checkNotNull(fModule);
IProgressMonitor monitor = new NullProgressMonitor();
Integer process21 = 21;
Integer process20 = 20;
/* Check invalid time ranges */
List<ITmfStateInterval> intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, -15, -5, 3, monitor);
assertTrue(intervals.isEmpty());
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 90, 1500000000L, 50, monitor);
assertTrue(intervals.isEmpty());
/* Check invalid quarks */
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, -1, 0, 70L, 3, monitor);
assertTrue(intervals.isEmpty());
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, 0, 0, 70L, 3, monitor);
assertTrue(intervals.isEmpty());
/* Check different time ranges and resolutions */
ProcessStatus[] values = { ProcessStatus.NOT_ALIVE, ProcessStatus.WAIT_CPU, ProcessStatus.RUN, ProcessStatus.WAIT_CPU, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 0, 70L, 3, monitor);
testIntervals("tid 21 [0,70,3]", intervals, values);
ProcessStatus[] values2 = { ProcessStatus.NOT_ALIVE, ProcessStatus.RUN, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 1, 70L, 30, monitor);
testIntervals("tid 21 [0,70,30]", intervals, values2);
ProcessStatus[] values3 = { ProcessStatus.WAIT_CPU, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 25, 50L, 3, monitor);
testIntervals("tid 21 [25,50,3]", intervals, values3);
ImmutableList<ITmfStateInterval> expectedIntervals = ImmutableList.of(new TmfStateInterval(1, 9, 0, ProcessStatus.NOT_ALIVE.getStateValue().unboxValue()), new TmfStateInterval(10, 19, 0, ProcessStatus.WAIT_UNKNOWN.getStateValue().unboxValue()), new TmfStateInterval(20, 29, 0, ProcessStatus.RUN.getStateValue().unboxValue()), new TmfStateInterval(30, 69, 0, ProcessStatus.WAIT_BLOCKED.getStateValue().unboxValue()));
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 0, 70L, 3, monitor);
compareIntervals(expectedIntervals, intervals);
expectedIntervals = ImmutableList.of(new TmfStateInterval(1, 9, 0, ProcessStatus.NOT_ALIVE.getStateValue().unboxValue()), new TmfStateInterval(30, 69, 0, ProcessStatus.WAIT_BLOCKED.getStateValue().unboxValue()));
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 1, 70L, 30, monitor);
compareIntervals(expectedIntervals, intervals);
ProcessStatus[] values6 = { ProcessStatus.RUN, ProcessStatus.WAIT_BLOCKED };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 25, 50L, 3, monitor);
testIntervals("tid 20 [25,50,3]", intervals, values6);
ProcessStatus[] values7 = { ProcessStatus.WAIT_CPU };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 80L, 85L, 3, monitor);
testIntervals("tid 20 [80,85,3]", intervals, values7);
}
use of org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus in project tracecompass by tracecompass.
the class KernelThreadInformationProviderTest method testGetStatusIntervalsForThreadIt.
/**
* Test the
* {@link KernelThreadInformationProvider#getStatusIntervalsForThread(KernelAnalysisModule, Integer, long, long, long)}
* method
*/
@Test
public void testGetStatusIntervalsForThreadIt() {
KernelAnalysisModule module = checkNotNull(fModule);
Integer process21 = 21;
Integer process20 = 20;
/* Check invalid time ranges */
Iterator<ITmfStateInterval> intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, -15, -5, -1);
assertFalse(intervals.hasNext());
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 90, 1500000000L, -1);
assertFalse(intervals.hasNext());
/* Check invalid quarks */
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, -1, 0, 70L, -1);
assertFalse(intervals.hasNext());
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, 0, 0, 70L, 0);
assertFalse(intervals.hasNext());
/* Check different time ranges */
ProcessStatus[] values = { ProcessStatus.NOT_ALIVE, ProcessStatus.WAIT_CPU, ProcessStatus.RUN, ProcessStatus.WAIT_CPU, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 0, 70L, -1);
testIterator("tid 21 [0,70]", intervals, values);
ProcessStatus[] values2 = { ProcessStatus.WAIT_CPU, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 25, 50L, -1);
testIterator("tid 21 [25,50]", intervals, values2);
ProcessStatus[] values3 = { ProcessStatus.NOT_ALIVE, ProcessStatus.WAIT_UNKNOWN, ProcessStatus.RUN, ProcessStatus.WAIT_BLOCKED };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 0, 70L, -1);
testIterator("tid 20 [0,70]", intervals, values3);
ProcessStatus[] values4 = { ProcessStatus.RUN, ProcessStatus.WAIT_BLOCKED };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 25, 50L, -1);
testIterator("tid 20 [25,50]", intervals, values4);
ProcessStatus[] values5 = { ProcessStatus.WAIT_CPU };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process20, 80L, 85L, -1);
testIterator("tid 20 [80,85]", intervals, values5);
/* Check valid time ranges with higher resolution */
ProcessStatus[] values6 = { ProcessStatus.NOT_ALIVE, ProcessStatus.RUN, ProcessStatus.RUN };
intervals = KernelThreadInformationProvider.getStatusIntervalsForThread(module, process21, 1, 70L, 30);
testIterator("tid 21 [0,70,30]", intervals, values6);
}
use of org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus in project tracecompass by tracecompass.
the class SchedWakeupHandler method handleEvent.
@Override
public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
Integer cpu = KernelEventHandlerUtils.getCpu(event);
ITmfEventField content = event.getContent();
final Integer tid = content.getFieldValue(Integer.class, getLayout().fieldTid());
if (tid == null) {
return;
}
final Integer prio = content.getFieldValue(Integer.class, getLayout().fieldPrio());
Long targetCpu = event.getContent().getFieldValue(Long.class, getLayout().fieldTargetCpu());
String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
if (cpu == null || targetCpu == null || threadAttributeName == null) {
return;
}
final int threadNode = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeThreads(ss), threadAttributeName);
/*
* The process indicated in the event's payload is now ready to run.
* Assign it to the "wait for cpu" state, but only if it was not already
* running.
*/
ProcessStatus status = ProcessStatus.getStatusFromStateValue(ss.queryOngoingState(threadNode));
long timestamp = KernelEventHandlerUtils.getTimestamp(event);
if (status != ProcessStatus.RUN && status != ProcessStatus.RUN_SYTEMCALL) {
ss.modifyAttribute(timestamp, ProcessStatus.WAIT_CPU.getStateValue().unboxValue(), threadNode);
}
/* Set the thread's target run queue */
int quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.CURRENT_CPU_RQ);
ss.modifyAttribute(timestamp, targetCpu.intValue(), quark);
/*
* When a user changes a threads prio (e.g. with pthread_setschedparam),
* it shows in ftrace with a sched_wakeup.
*/
if (prio != null) {
quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.PRIO);
ss.modifyAttribute(timestamp, prio, quark);
}
}
Aggregations