Skip to content

Commit f03ccc7

Browse files
MatthewKhouzamarfio
authored andcommitted
linux.core: : Add IRQ handlers instead of generic IRQs
Currently, the Resources view only shows IRQs as a single entity. This makes it harder to distinguish which handler is actually running, especially in cases where multiple IRQ handlers are mapped to the same lane. This change updates the view to display IRQ handlers instead of just the IRQ, providing finer granularity and improving readability when a single lane contains multiple handlers. Benefits: * Clearer visualization of interrupt activity. * Easier to identify which handler is active at a given time. * Better distinction when multiple handlers share one IRQ lane. [Added] Add handlers to IRQs in resources views Change-Id: I131790ec6dad3b28328abea0c5d84b280a7b196e Signed-off-by: Matthew Khouzam <[email protected]>
1 parent 7f18609 commit f03ccc7

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
8787
* Version number of this state provider. Please bump this if you modify the
8888
* contents of the generated state history in some way.
8989
*/
90-
private static final int VERSION = 30;
90+
private static final int VERSION = 31;
9191

9292
// ------------------------------------------------------------------------
9393
// Fields

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/IrqEntryHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws Attri
4545
return;
4646
}
4747
Integer irqId = ((Long) event.getContent().getField(getLayout().fieldIrq()).getValue()).intValue();
48-
48+
String name = event.getContent().getField(getLayout().fieldName()).getValue().toString();
4949
/*
5050
* Mark this IRQ as active in the resource tree. The state value = the
5151
* CPU on which this IRQ is sitting
5252
*/
53-
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString());
53+
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString() + "/" + name); //$NON-NLS-1$
5454

5555
long timestamp = KernelEventHandlerUtils.getTimestamp(event);
5656
ss.modifyAttribute(timestamp, cpu.intValue(), quark);
@@ -64,7 +64,7 @@ public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws Attri
6464
ss.modifyAttribute(timestamp, StateValues.CPU_STATUS_IRQ_VALUE.unboxValue(), quark);
6565

6666
/* Update the aggregate IRQ entry to set it to this CPU */
67-
int aggregateQuark = ss.getQuarkAbsoluteAndAdd(Attributes.IRQS, irqId.toString());
67+
int aggregateQuark = ss.getQuarkAbsoluteAndAdd(Attributes.IRQS, irqId.toString() + "/" + name); //$NON-NLS-1$
6868
ss.modifyAttribute(timestamp, cpu, aggregateQuark);
6969
}
7070

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/IrqExitHandler.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
1616

17+
import java.util.List;
18+
1719
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
1820
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
21+
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
1922
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
2023
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
2124
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
@@ -43,8 +46,18 @@ public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws Attri
4346
}
4447
int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss);
4548
Integer irqId = ((Long) event.getContent().getField(getLayout().fieldIrq()).getValue()).intValue();
49+
List<Integer> subAttrs = ss.getSubAttributes(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), false);
50+
String irqPrefix = irqId.toString() + "/"; //$NON-NLS-1$
51+
List<Integer> quarks = subAttrs.stream().filter(iquark -> ss.getAttributeName(iquark).startsWith(irqPrefix)).toList();
52+
int quark = ITmfStateSystem.INVALID_ATTRIBUTE;
53+
for (int quarkCandidate : quarks) {
54+
if (ss.queryOngoing(quarkCandidate) != null) {
55+
quark = quarkCandidate;
56+
break;
57+
}
58+
}
59+
String name = ss.getAttributeName(quark);
4660
/* Put this IRQ back to inactive in the resource tree */
47-
int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString());
4861
long timestamp = KernelEventHandlerUtils.getTimestamp(event);
4962
ss.modifyAttribute(timestamp, (Object) null, quark);
5063

@@ -55,7 +68,7 @@ public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws Attri
5568
KernelEventHandlerUtils.updateCpuStatus(timestamp, cpu, ss);
5669

5770
/* Update the aggregate IRQ entry to set it to this CPU */
58-
int aggregateQuark = ss.getQuarkAbsoluteAndAdd(Attributes.IRQS, irqId.toString());
71+
int aggregateQuark = ss.getQuarkAbsoluteAndAdd(Attributes.IRQS, name);
5972
/* Update the aggregate IRQ entry to set it to a running CPU */
6073
Integer prevCpu = KernelEventHandlerUtils.getCpuForIrq(ss, irqId);
6174
ss.modifyAttribute(timestamp, prevCpu, aggregateQuark);

analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/resourcesstatus/ResourcesStatusDataProvider.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,12 @@ private void createInterrupt(final ITmfStateSystem ssq, long startTime, long end
317317
ResourcesEntryModel cpuEntry, List<Integer> irqQuarks, Type type, List<ResourcesEntryModel> builder) {
318318
for (Integer irqQuark : irqQuarks) {
319319
String resourceName = ssq.getAttributeName(irqQuark);
320-
int resourceId = Integer.parseInt(resourceName);
320+
String[] resourceNames = resourceName.split("/"); //$NON-NLS-1$
321+
int resourceId = Integer.parseInt(resourceNames[0]);
321322
long irqId = getId(irqQuark);
322323

323324
builder.add(new ResourcesEntryModel(irqId, cpuEntry.getId(),
324-
computeEntryName(type, resourceId), startTime, endTime, resourceId, type));
325+
computeEntryName(type, resourceName), startTime, endTime, resourceId, type));
325326

326327
fEntryModelTypes.put(irqQuark, type);
327328

@@ -337,7 +338,7 @@ private void createInterrupt(final ITmfStateSystem ssq, long startTime, long end
337338
long aggregateId = getId(aggregateQuark);
338339
if (!Iterables.any(builder, entry -> entry.getId() == aggregateId)) {
339340
builder.add(new ResourcesEntryModel(aggregateId, cpuEntry.getParentId(),
340-
computeEntryName(type, resourceId),
341+
computeEntryName(type, resourceName),
341342
startTime, endTime, resourceId, type));
342343
}
343344
fEntryModelTypes.put(aggregateQuark, type);
@@ -354,9 +355,9 @@ private void createInterrupt(final ITmfStateSystem ssq, long startTime, long end
354355
}
355356
}
356357

357-
private static @NonNull List<@NonNull String> computeEntryName(Type type, int id) {
358+
private static @NonNull List<@NonNull String> computeEntryName(Type type, Object id) {
358359
if (type == Type.SOFT_IRQ) {
359-
return Collections.singletonList(type.toString() + ' ' + id + ' ' + SoftIrqLabelProvider.getSoftIrq(id));
360+
return Collections.singletonList(type.toString() + ' ' + id + ' ' + SoftIrqLabelProvider.getSoftIrq(Integer.parseInt((String) id)));
360361
} else if (type == Type.CURRENT_THREAD) {
361362
String threadEntryName = NLS.bind(Messages.ThreadEntry, id);
362363
if (threadEntryName != null) {

lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/StateSystemTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void testRangeQuery2() {
166166
assertNotNull(ss);
167167

168168
try {
169-
int quark = ss.getQuarkAbsolute(Attributes.CPUS, Integer.toString(0), Attributes.IRQS, "1");
169+
int quark = ss.getQuarkAbsolute(Attributes.CPUS, Integer.toString(0), Attributes.IRQS, "1/i8042");
170170
long ts1 = ss.getStartTime(); /* start of the trace */
171171
long ts2 = startTime + 20L * NANOSECS_PER_SEC; /* invalid, but ignored */
172172

@@ -176,7 +176,7 @@ public void testRangeQuery2() {
176176
assertEquals(65, intervals.size());
177177

178178
} catch (AttributeNotFoundException | StateSystemDisposedException e) {
179-
fail();
179+
fail(e.toString());
180180
}
181181
}
182182

0 commit comments

Comments
 (0)