1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.kernel
.handlers
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
.StateValues
;
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
;
24 * Raise a soft irq event
26 public class SoftIrqRaiseHandler
extends KernelEventHandler
{
34 public SoftIrqRaiseHandler(IKernelAnalysisEventLayout layout
) {
39 public void handleEvent(ITmfStateSystemBuilder ss
, ITmfEvent event
) throws AttributeNotFoundException
{
40 Integer softIrqId
= ((Long
) event
.getContent().getField(getLayout().fieldVec()).getValue()).intValue();
41 Integer cpu
= KernelEventHandlerUtils
.getCpu(event
);
46 * Mark this SoftIRQ as *raised* in the resource tree.
48 int quark
= ss
.getQuarkRelativeAndAdd(KernelEventHandlerUtils
.getNodeSoftIRQs(cpu
, ss
), softIrqId
.toString());
50 ITmfStateValue value
= (isInSoftirq(ss
.queryOngoingState(quark
)) ?
51 StateValues
.SOFT_IRQ_RAISED_RUNNING_VALUE
:
52 StateValues
.SOFT_IRQ_RAISED_VALUE
);
53 ss
.modifyAttribute(KernelEventHandlerUtils
.getTimestamp(event
), value
, quark
);
57 private static boolean isInSoftirq(@Nullable ITmfStateValue state
) {
58 return (state
!= null &&
60 (state
.unboxInt() & StateValues
.CPU_STATUS_SOFTIRQ
) == StateValues
.CPU_STATUS_SOFTIRQ
);