Search in sources :

Example 1 with ProcessStatus

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;
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)

Example 2 with ProcessStatus

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;
    }
}
Also used : HostThread(org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread) OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) OsSystemModel(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsSystemModel) TmfCpuAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect) ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus) IKernelAnalysisEventLayout(org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout)

Example 3 with ProcessStatus

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) TmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval) ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 4 with ProcessStatus

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);
}
Also used : ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 5 with ProcessStatus

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);
    }
}
Also used : ITmfEventField(org.eclipse.tracecompass.tmf.core.event.ITmfEventField) ProcessStatus(org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus)

Aggregations

ProcessStatus (org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus)7 TmfGraph (org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)3 TmfVertex (org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex)2 OsSystemModel (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsSystemModel)2 OsWorker (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker)2 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)2 HostThread (org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread)2 IKernelAnalysisEventLayout (org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout)2 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)2 TmfCpuAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect)2 Test (org.junit.Test)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 TmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval)1 ITmfEventField (org.eclipse.tracecompass.tmf.core.event.ITmfEventField)1