Import lttng.kernel.core plugins from Scope
[deliverable/tracecompass.git] / lttng / org.lttng.scope.lttng.kernel.core / src / org / lttng / scope / lttng / kernel / core / analysis / os / handlers / internal / SoftIrqEntryHandler.java
CommitLineData
451ba2f7
AM
1/*******************************************************************************
2 * Copyright (c) 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13package org.lttng.scope.lttng.kernel.core.analysis.os.handlers.internal;
14
15import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
16import org.lttng.scope.lttng.kernel.core.analysis.os.StateValues;
17import org.lttng.scope.lttng.kernel.core.trace.layout.ILttngKernelEventLayout;
18
19import ca.polymtl.dorsal.libdelorean.ITmfStateSystemBuilder;
20import ca.polymtl.dorsal.libdelorean.exceptions.AttributeNotFoundException;
21import ca.polymtl.dorsal.libdelorean.statevalue.ITmfStateValue;
22
23/**
24 * Soft Irq Entry handler
25 */
26public class SoftIrqEntryHandler extends KernelEventHandler {
27
28 /**
29 * Constructor
30 *
31 * @param layout
32 * event layout
33 */
34 public SoftIrqEntryHandler(ILttngKernelEventLayout layout) {
35 super(layout);
36 }
37
38 @Override
39 public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
40 Integer cpu = KernelEventHandlerUtils.getCpu(event);
41 if (cpu == null) {
42 return;
43 }
44
45 long timestamp = KernelEventHandlerUtils.getTimestamp(event);
46 Integer softIrqId = ((Long) event.getContent().getField(getLayout().fieldVec()).getValue()).intValue();
47 int currentCPUNode = KernelEventHandlerUtils.getCurrentCPUNode(cpu, ss);
48 int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
49
50 /*
51 * Mark this SoftIRQ as active in the resource tree.
52 */
53 int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString());
54 ITmfStateValue value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
55 ss.modifyAttribute(timestamp, value, quark);
56
57 /* Change the status of the running process to interrupted */
58 value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
59 ss.modifyAttribute(timestamp, value, currentThreadNode);
60
61 /* Change the status of the CPU to interrupted */
62 value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
63 ss.modifyAttribute(timestamp, value, currentCPUNode);
64 }
65}
This page took 0.025565 seconds and 5 git commands to generate.