Commit | Line | Data |
---|---|---|
c8f45ad2 MK |
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 | ||
13 | package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers; | |
14 | ||
0f7a12d3 | 15 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues; |
c8f45ad2 | 16 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; |
f69045e2 | 17 | import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes; |
c8f45ad2 MK |
18 | import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; |
19 | import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; | |
20 | import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; | |
c8f45ad2 MK |
21 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
22 | ||
23 | /** | |
24 | * Soft Irq Entry handler | |
25 | */ | |
26 | public class SoftIrqEntryHandler extends KernelEventHandler { | |
27 | ||
28 | /** | |
29 | * Constructor | |
30 | * | |
31 | * @param layout | |
32 | * event layout | |
33 | */ | |
34 | public SoftIrqEntryHandler(IKernelAnalysisEventLayout 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); | |
8140841e | 48 | int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss); |
c8f45ad2 MK |
49 | |
50 | /* | |
8140841e | 51 | * Mark this SoftIRQ as active in the resource tree. |
c8f45ad2 | 52 | */ |
19ed6598 | 53 | int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString()); |
8140841e | 54 | ITmfStateValue value = StateValues.CPU_STATUS_SOFTIRQ_VALUE; |
c8f45ad2 MK |
55 | ss.modifyAttribute(timestamp, value, quark); |
56 | ||
57 | /* Change the status of the running process to interrupted */ | |
58 | quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS); | |
59 | value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE; | |
60 | ss.modifyAttribute(timestamp, value, quark); | |
61 | ||
62 | /* Change the status of the CPU to interrupted */ | |
63 | quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS); | |
64 | value = StateValues.CPU_STATUS_SOFTIRQ_VALUE; | |
65 | ss.modifyAttribute(timestamp, value, quark); | |
66 | } | |
67 | } |