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 | ||
8140841e | 15 | import org.eclipse.jdt.annotation.Nullable; |
0f7a12d3 | 16 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues; |
c8f45ad2 MK |
17 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; |
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; | |
21 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
22 | ||
23 | /** | |
24 | * Raise a soft irq event | |
25 | */ | |
26 | public class SoftIrqRaiseHandler extends KernelEventHandler { | |
27 | ||
28 | /** | |
29 | * Constructor | |
19ed6598 MK |
30 | * |
31 | * @param layout | |
32 | * event layout | |
c8f45ad2 MK |
33 | */ |
34 | public SoftIrqRaiseHandler(IKernelAnalysisEventLayout layout) { | |
35 | super(layout); | |
36 | } | |
37 | ||
38 | @Override | |
39 | public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException { | |
40 | Integer softIrqId = ((Long) event.getContent().getField(getLayout().fieldVec()).getValue()).intValue(); | |
19ed6598 MK |
41 | Integer cpu = KernelEventHandlerUtils.getCpu(event); |
42 | if (cpu == null) { | |
43 | return; | |
44 | } | |
c8f45ad2 | 45 | /* |
8140841e | 46 | * Mark this SoftIRQ as *raised* in the resource tree. |
c8f45ad2 | 47 | */ |
19ed6598 | 48 | int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeSoftIRQs(cpu, ss), softIrqId.toString()); |
8140841e MK |
49 | |
50 | ITmfStateValue value = (isInSoftirq(ss.queryOngoingState(quark)) ? | |
51 | StateValues.SOFT_IRQ_RAISED_RUNNING_VALUE : | |
52 | StateValues.SOFT_IRQ_RAISED_VALUE); | |
c8f45ad2 | 53 | ss.modifyAttribute(KernelEventHandlerUtils.getTimestamp(event), value, quark); |
8140841e MK |
54 | |
55 | } | |
56 | ||
57 | private static boolean isInSoftirq(@Nullable ITmfStateValue state) { | |
58 | return (state != null && | |
59 | !state.isNull() && | |
60 | (state.unboxInt() & StateValues.CPU_STATUS_SOFTIRQ) == StateValues.CPU_STATUS_SOFTIRQ); | |
c8f45ad2 MK |
61 | } |
62 | } |