Skip to content

Commit 7844f25

Browse files
committed
vm: fixed review comments
1 parent 1a084ee commit 7844f25

32 files changed

Lines changed: 367 additions & 1150 deletions

File tree

analyses/org.eclipse.tracecompass.incubator.executioncomparison.core/src/org/eclipse/tracecompass/incubator/internal/executioncomparison/core/DifferentialSeqCallGraphAnalysis.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ public DifferentialSeqCallGraphAnalysis() {
9797
// Adding VM/Native analysis
9898
fCallStackAnalysisMap.put("org.eclipse.linuxtools.lttng2.kernel.tracetype", //$NON-NLS-1$
9999
"org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis.vm.native.callstack"); //$NON-NLS-1$
100-
101-
/*fCallStackAnalysisMap.put("org.eclipse.tracecompass.tmf.core.experiment", //$NON-NLS-1$
102-
"org.eclipse.tracecompass.incubator.overhead.core.analysis.vm.native.callstack"); //$NON-NLS-1$*/
103100
}
104101

105102
/**

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/plugin.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,10 @@
6363
class="org.eclipse.tracecompass.tmf.core.trace.TmfTrace">
6464
</tracetype>
6565
</module>
66-
<module
67-
analysis_module="org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis.VMNativeComparisonAnalysis"
68-
id="org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis.vmcomparison"
69-
name="VM vs Native Comparison">
70-
<tracetype
71-
class="org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment">
72-
</tracetype>
73-
</module>
7466
<module
7567
analysis_module="org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis.VMNativeCallStackAnalysis"
7668
applies_experiment="true"
69+
automatic="false"
7770
id="org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis.vm.native.callstack"
7871
name="VM Native CallStack">
7972
<tracetype

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ExecutionSequence.java

Lines changed: 10 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

313
import java.util.ArrayList;
414
import java.util.List;
5-
import java.io.File;
6-
import java.io.FileOutputStream;
7-
import java.io.IOException;
8-
import java.io.PrintWriter;
915

1016
/**
1117
* Represents a complete execution sequence in a virtualized environment:
@@ -82,78 +88,6 @@ void setVmEntry(FlowEvent event) {
8288
this.vmEntry = event;
8389
}
8490

85-
/**
86-
* Prints the execution sequence for debugging purposes.
87-
* <p>
88-
* The sequence is printed both to the standard output and appended
89-
* to a file on disk.
90-
* </p>
91-
*
92-
* @throws IOException
93-
* if an I/O error occurs while writing to the file
94-
*/
95-
void printSequence() throws IOException {
96-
try (
97-
FileOutputStream fos = new FileOutputStream(
98-
new File("/home/philippe/Desktop/virtualized_flow.txt"), true); //$NON-NLS-1$
99-
PrintWriter writer = new PrintWriter(fos)) {
100-
101-
// Print guest events
102-
for (FlowEvent guestEvent : guestEvents) {
103-
KernelEventInfo evt = guestEvent.kernelEvent;
104-
System.out.printf(" [GUEST] %s (TID:%d, CPU:%d)\n", evt.name, evt.tid, evt.cpuid); //$NON-NLS-1$
105-
writer.printf(" [GUEST] %s (TID:%d, CPU:%d)\n", evt.name, evt.tid, evt.cpuid); //$NON-NLS-1$
106-
}
107-
108-
// Print VM exit
109-
if (vmExit != null) {
110-
System.out.printf(" ↓ [VM_EXIT] %s (CPU:%d, VCPU:%d, exit_reason:%s)\n", //$NON-NLS-1$
111-
vmExit.kernelEvent.name,
112-
vmExit.kernelEvent.cpuid,
113-
vmExit.kernelEvent.vcpuid,
114-
vmExit.kernelEvent.exitReason);
115-
116-
writer.printf(" ↓ [VM_EXIT] %s (CPU:%d, VCPU:%d, exit_reason:%s)\n", //$NON-NLS-1$
117-
vmExit.kernelEvent.name,
118-
vmExit.kernelEvent.cpuid,
119-
vmExit.kernelEvent.vcpuid,
120-
vmExit.kernelEvent.exitReason);
121-
}
122-
123-
// Print hypervisor events
124-
for (FlowEvent hypervisorEvent : hypervisorEvents) {
125-
KernelEventInfo evt = hypervisorEvent.kernelEvent;
126-
System.out.printf(" [HOST] %s (PID:%d, CPU:%d)\n", //$NON-NLS-1$
127-
evt.name, evt.pid, evt.cpuid);
128-
129-
writer.printf(" [HOST] %s (PID:%d, CPU:%d)\n", //$NON-NLS-1$
130-
evt.name, evt.pid, evt.cpuid);
131-
}
132-
133-
// Print VM entry
134-
if (vmEntry != null) {
135-
System.out.printf(" ↑ [VM_ENTRY] %s (CPU:%d, VCPU:%d)\n", //$NON-NLS-1$
136-
vmEntry.kernelEvent.name,
137-
vmEntry.kernelEvent.cpuid,
138-
vmEntry.kernelEvent.vcpuid);
139-
140-
writer.printf(" ↑ [VM_ENTRY] %s (CPU:%d, VCPU:%d)\n", //$NON-NLS-1$
141-
vmEntry.kernelEvent.name,
142-
vmEntry.kernelEvent.cpuid,
143-
vmEntry.kernelEvent.vcpuid);
144-
}
145-
146-
// Print timing summary
147-
if (!guestEvents.isEmpty() && vmEntry != null) {
148-
long totalDuration = vmEntry.kernelEvent.timestamp
149-
- guestEvents.get(0).kernelEvent.timestamp;
150-
151-
System.out.printf(" Total sequence duration: %d µs\n", totalDuration / 1000); //$NON-NLS-1$
152-
writer.printf(" Total sequence duration: %d µs\n", totalDuration / 1000); //$NON-NLS-1$
153-
}
154-
}
155-
}
156-
15791
/**
15892
* Indicates whether the execution sequence is complete.
15993
* <p>

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ExitReasonMap.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

313
import java.util.HashMap;

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/FlowEvent.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

313
/**

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/KernelEventInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

313

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/KvmExitAnalysisModule.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
/***********************************************************************
2-
* KVM Exit Analysis Module
3-
* This module analyzes and tracks KVM exit event per cpu
4-
***********************************************************************/
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
511

612
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
713

@@ -16,6 +22,8 @@
1622
/**
1723
* Analysis module that builds a state system from KVM exit events in a trace.
1824
* It tracks the number and types of VM exits for each CPU.
25+
*
26+
* @author Francois Belias
1927
*/
2028
public class KvmExitAnalysisModule extends TmfStateSystemAnalysisModule {
2129

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/KvmExitStateProvider.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
21
/*******************************************************************************
3-
* KVM Exit State Provider
4-
* This state provider processes trace events related to KVM exits
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
510
*******************************************************************************/
6-
7-
8-
911
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
1012

1113

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ProcessFlowInfo.java

Lines changed: 18 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

3-
import java.io.File;
4-
import java.io.FileOutputStream;
5-
import java.io.IOException;
6-
import java.io.PrintWriter;
713
import java.util.ArrayList;
814
import java.util.Comparator;
915
import java.util.HashMap;
@@ -35,9 +41,6 @@ public class ProcessFlowInfo {
3541
private final Set<String> seenTransitions = new HashSet<>();
3642
private boolean currentlyInHost = false;
3743

38-
// Store execution sequences for analysis
39-
private List<ExecutionSequence> executionSequences = new ArrayList<>();
40-
4144
// Constructor for non-virtualized environments
4245
ProcessFlowInfo(String phase, String processName) {
4346
this(phase, processName, false, null);
@@ -165,11 +168,19 @@ public void addEvent(KernelEventInfo evt) {
165168
return; // we don't want to track the hypervisor because we are on the native system
166169
}
167170

171+
if (!processName.equals(evt.processName)) {
172+
return;
173+
}
174+
168175
// For native systems, if we have a target thread, only track that thread
169176
if (targetThreadId != null && !targetThreadId.equals(evt.tid)) {
170177
return;
171178
}
172179

180+
ThreadFlowInfo threadInfo = threadsByTid.computeIfAbsent(evt.tid,
181+
k -> new ThreadFlowInfo(k, processName));
182+
threadInfo.addEvent(evt);
183+
173184
String key = "NATIVE" + "_" + evt.timestamp + "_" + evt.cpuid + "_" + evt.tid; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
174185

175186
if (seenTransitions.contains(key)) {
@@ -287,112 +298,12 @@ private void buildExecutionSequences() {
287298
default:
288299
break;
289300
}
290-
291-
// Close sequence after VM_ENTRY (which comes after hypervisor events)
292-
// Actually, let's close it when we see the next VM_ENTRY or at the end
293301
}
294302

295303
// Add any remaining sequence
296304
if (currentSequence != null) {
297305
sequences.add(currentSequence);
298306
}
299-
300-
this.executionSequences = sequences;
301-
}
302-
303-
/**
304-
* Print the unified execution flow
305-
*/
306-
void printUnifiedFlow() throws IOException {
307-
System.out.printf("\n=== Unified Flow for Process %s (Phase: %s) ===\n", //$NON-NLS-1$
308-
processName, phase);
309-
310-
if (targetThreadId != null) {
311-
System.out.printf("Tracking Thread: %d", targetThreadId); //$NON-NLS-1$
312-
if (targetVcpuId != null) {
313-
System.out.printf(" (vCPU: %d)", targetVcpuId); //$NON-NLS-1$
314-
}
315-
System.out.println();
316-
}
317-
318-
if (!trackHypervisor) {
319-
printSimpleFlow();
320-
return;
321-
}
322-
323-
printVirtualizedFlow();
324-
}
325-
326-
private void printSimpleFlow() throws IOException {
327-
System.out.printf("Events: %d, Threads: %d\n", unifiedFlow.size(), threadsByTid.size()); //$NON-NLS-1$
328-
329-
FileOutputStream fos = new FileOutputStream(new File("/home/philippe/Desktop/natif_flow.txt"), true); //$NON-NLS-1$
330-
try (PrintWriter writer = new PrintWriter(fos)) {
331-
for (FlowEvent flowEvent : unifiedFlow) {
332-
KernelEventInfo evt = flowEvent.kernelEvent;
333-
String output = String.format(" [%d] %s (TID:%d)\n", //$NON-NLS-1$
334-
evt.timestamp, evt.name, evt.tid);
335-
System.out.print(output);
336-
writer.print(output);
337-
}
338-
}
339-
}
340-
341-
private void printVirtualizedFlow() throws IOException {
342-
System.out.printf("Execution Sequences: %d\n", executionSequences.size()); //$NON-NLS-1$
343-
344-
int sequenceNum = 1;
345-
for (ExecutionSequence seq : executionSequences) {
346-
System.out.printf("\n--- Sequence %d ---\n", sequenceNum++); //$NON-NLS-1$
347-
seq.printSequence();
348-
}
349-
350-
// Also print raw chronological flow
351-
System.out.println("\n--- Raw Chronological Flow ---"); //$NON-NLS-1$
352-
FileOutputStream fos = new FileOutputStream(new File("/home/philippe/Desktop/virtualized_flow_raw.txt"), true); //$NON-NLS-1$
353-
try (PrintWriter writer = new PrintWriter(fos)) {
354-
for (FlowEvent flowEvent : unifiedFlow) {
355-
printFlowEvent(flowEvent, writer);
356-
}
357-
}
358-
}
359-
360-
private static void printFlowEvent(FlowEvent flowEvent, PrintWriter writer) {
361-
KernelEventInfo evt = flowEvent.kernelEvent;
362-
String prefix = getEventPrefix(flowEvent.type);
363-
364-
String output = String.format(" [%d] %s%s", evt.timestamp, prefix, evt.name); //$NON-NLS-1$
365-
366-
if (evt.tid >= 0) {
367-
output += String.format(" (TID:%d", evt.tid); //$NON-NLS-1$
368-
if (evt.cpuid >= 0) {
369-
output += String.format(", CPU:%d", evt.cpuid); //$NON-NLS-1$
370-
}
371-
if (evt.vcpuid >= 0) {
372-
output += String.format(", VCPU:%d", evt.vcpuid); //$NON-NLS-1$
373-
}
374-
if (!evt.exitReason.equals("UNKNOWN_EXIT_REASON")) { //$NON-NLS-1$
375-
output += String.format(", exit_reason:%s", evt.exitReason); //$NON-NLS-1$
376-
}
377-
output += ")"; //$NON-NLS-1$
378-
}
379-
output += "\n"; //$NON-NLS-1$
380-
381-
System.out.print(output);
382-
if (writer != null) {
383-
writer.print(output);
384-
}
385-
}
386-
387-
private static String getEventPrefix(FlowEventType type) {
388-
switch (type) {
389-
case GUEST_EVENT: return "[GUEST] "; //$NON-NLS-1$
390-
case VM_EXIT: return "[VM_EXIT] "; //$NON-NLS-1$
391-
case HYPERVISOR_EVENT: return "[HOST] "; //$NON-NLS-1$
392-
case VM_ENTRY: return "[VM_ENTRY] "; //$NON-NLS-1$
393-
case NATIVE: return "[NATIVE] "; //$NON-NLS-1$
394-
default: return ""; //$NON-NLS-1$
395-
}
396307
}
397308

398309
boolean isMultiThreaded() {

vm/org.eclipse.tracecompass.incubator.virtual.machine.analysis.core/src/org/eclipse/tracecompass/incubator/internal/virtual/machine/analysis/core/flow/analysis/ThreadFlowInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 École Polytechnique de Montréal
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
111
package org.eclipse.tracecompass.incubator.internal.virtual.machine.analysis.core.flow.analysis;
212

313
import java.util.ArrayList;

0 commit comments

Comments
 (0)