Skip to content

Commit 3c40d1c

Browse files
arfioMatthewKhouzam
authored andcommitted
kernel: make status for threads work again
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
1 parent fc2eea7 commit 3c40d1c

15 files changed

Lines changed: 27 additions & 31 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public static Map<Integer, List<ITmfStateInterval>> getStatusIntervalsForThreads
548548
if (ss == null) {
549549
return Objects.requireNonNull(Collections.emptyMap());
550550
}
551-
List<Long> currentTimes = times.stream().filter(time -> (time > ss.getCurrentEndTime() || time < ss.getStartTime())).sorted().collect(Collectors.toList());
551+
List<Long> currentTimes = times.stream().filter(time -> (time < ss.getCurrentEndTime() && time > ss.getStartTime())).sorted().collect(Collectors.toList());
552552
if (currentTimes.isEmpty()) {
553553
return Objects.requireNonNull(Collections.emptyMap());
554554
}

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Objects;
27-
2827
import java.util.Set;
29-
//import java.util.stream.Collectors;
3028
import java.util.stream.Collectors;
3129

3230
import org.eclipse.core.runtime.IProgressMonitor;
@@ -46,6 +44,9 @@
4644
import org.eclipse.tracecompass.tmf.core.model.OutputElementStyle;
4745
import org.eclipse.tracecompass.tmf.core.model.StyleProperties;
4846
import org.eclipse.tracecompass.tmf.core.model.StyleProperties.SymbolType;
47+
import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;
48+
import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationCategoriesModel;
49+
import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationModel;
4950
import org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter;
5051
import org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter;
5152
import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow;
@@ -55,10 +56,6 @@
5556
import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel;
5657
import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphState;
5758
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel;
58-
import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;
59-
//import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;
60-
import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationCategoriesModel;
61-
import org.eclipse.tracecompass.tmf.core.model.annotations.AnnotationModel;
6259
import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
6360
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
6461
import org.junit.Test;
@@ -262,7 +259,7 @@ public void testFetchModel() {
262259
new TimeGraphState(6, 2, null, new OutputElementStyle(LinuxStyle.WAIT_FOR_CPU.getLabel())),
263260
new TimeGraphState(8, 2, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel())),
264261
new TimeGraphState(10, 2, null, new OutputElementStyle(LinuxStyle.WAIT_FOR_CPU.getLabel())),
265-
new TimeGraphState(12, 8, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel()))), true);
262+
new TimeGraphState(12, 8, "openat", new OutputElementStyle(LinuxStyle.SYSCALL.getLabel()))), true);
266263

267264
// Get the row model for those entries with low resolution
268265
rowResponse = dataProvider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(3, 15, 2, selectedIds)), new NullProgressMonitor());
@@ -300,7 +297,7 @@ public void testFetchModel() {
300297
// Verify kernel statuses of tid 6
301298
verifyStates(rows, FlameDataProviderTestUtils.findEntryByDepthAndType(tid6Children, -1, EntryType.KERNEL), ImmutableList.of(
302299
new TimeGraphState(1, 5, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel())),
303-
new TimeGraphState(12, 8, null, new OutputElementStyle(LinuxStyle.USERMODE.getLabel()))), true);
300+
new TimeGraphState(12, 8, "openat", new OutputElementStyle(LinuxStyle.SYSCALL.getLabel()))), true);
304301

305302
// Check arrows
306303
FlameChartEntryModel tid2 = FlameDataProviderTestUtils.findEntryByNameAndType(modelEntries, "2", EntryType.LEVEL);
@@ -436,11 +433,9 @@ private static void verifyStates(List<ITimeGraphRowModel> rowModels, FlameChartE
436433
assertNotNull(rowModel);
437434
@SuppressWarnings("null")
438435
List<ITimeGraphState> states = rowModel.getStates();
436+
assertEquals(expectedStates.size(), states.size());
439437
for (int i = 0; i < states.size(); i++) {
440438
String entryName = entry.getName();
441-
if (i > expectedStates.size() - 1) {
442-
fail("Unexpected state at position " + i + FOR_ENTRY + entryName + ": " + states.get(i));
443-
}
444439
ITimeGraphState actual = states.get(i);
445440
ITimeGraphState expected = expectedStates.get(i);
446441
assertEquals("State start time at " + i + FOR_ENTRY + entryName, expected.getStartTime(), actual.getStartTime());

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/callgraph2/FlameGraphDataProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private static void assertTooltip(FlameGraphDataProvider<?, ?, ?> provider, Long
300300
assertNotNull(tooltipModel);
301301
if (expectedObject.equals("null")) {
302302
assertTrue(tooltipModel.isEmpty());
303-
} else if (List.of(ProcessStatus.RUN.toString(), ProcessStatus.WAIT_CPU.toString()).contains(expectedObject)) {
303+
} else if (List.of(ProcessStatus.RUN.toString(), ProcessStatus.WAIT_CPU.toString(), ProcessStatus.RUN_SYTEMCALL.toString()).contains(expectedObject)) {
304304
if (isAction) {
305305
assertNotNull(tooltipModel);
306306
} else {

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/KernelStateProviderStub.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ public ITmfStateProvider getNewInstance() {
5959
@Override
6060
protected void eventHandle(ITmfEvent event) {
6161
ITmfStateSystemBuilder ssb = getStateSystemBuilder();
62-
if (ssb == null) {
62+
if (ssb == null || event.getName().equals("instant_event")) {
6363
return;
6464
}
6565
int threadQuark = ssb.getQuarkAbsoluteAndAdd(Attributes.THREADS, event.getContent().getFieldValue(String.class, "tid"));
6666
boolean isEntry = event.getName().equals(ENTRY);
6767
long timestamp = event.getTimestamp().getValue();
6868
if (isEntry) {
69-
if (event.getName().equals("op4")) {
69+
String operationName = event.getContent().getFieldValue(String.class, "op");
70+
if (operationName != null && operationName.equals("op4")) {
7071
int systemCallQuark = ssb.getQuarkRelativeAndAdd(threadQuark, Attributes.SYSTEM_CALL);
7172
ssb.modifyAttribute(timestamp, "openat", systemCallQuark);
7273
/* Put the process in system call mode */

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFull2Times

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
function,0,level,2:0,8,op4,op4
22
function,1,level,2:0,8,-,null
33
function,2,level,2:0,8,-,null
4-
kernel,Kernel statuses,level,2:0,8,RUN,RUN
4+
kernel,Kernel statuses,level,2:0,8,RUN_SYTEMCALL,RUN_SYTEMCALL
55
function,0,level,3:0,17,op2,op2
66
function,1,level,3:0,1,op3,op3
77
kernel,Kernel statuses,level,3:0,8,WAIT_CPU,WAIT_CPU
88
function,0,level,6:0,19,op1,op1
99
function,1,level,6:0,3,op2,op2,16,3,-,null
1010
function,2,level,6:0,1,op3,op3,5,14,-,null
11-
kernel,Kernel statuses,level,6:0,4,WAIT_CPU,WAIT_CPU,4,15,RUN,RUN
11+
kernel,Kernel statuses,level,6:0,4,WAIT_CPU,WAIT_CPU,11,8,RUN_SYTEMCALL,RUN_SYTEMCALL
1212
function,0,level,7:0,19,op5,op5
1313
function,1,level,7:0,12,op2,op2,12,7,-,null
1414
function,2,level,7:0,1,op3,op3,1,18,-,null

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullAll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
function,0,level,2:0,8,op4,op4,8,9,op1,op1
22
function,1,level,2:0,8,-,null,8,4,op2,op2,12,5,-,null
33
function,2,level,2:0,8,-,null,8,1,op3,op3,9,8,-,null
4-
kernel,Kernel statuses,level,2:0,8,RUN,RUN,8,4,RUN,RUN,12,5,WAIT_CPU,WAIT_CPU
4+
kernel,Kernel statuses,level,2:0,8,RUN_SYTEMCALL,RUN_SYTEMCALL,8,4,RUN,RUN,12,5,WAIT_CPU,WAIT_CPU
55
function,0,level,3:0,17,op2,op2
66
function,1,level,3:0,1,op3,op3,1,6,op2,op2,7,10,-,null
77
kernel,Kernel statuses,level,3:0,8,WAIT_CPU,WAIT_CPU,8,9,RUN,RUN
88
function,0,level,6:0,19,op1,op1
99
function,1,level,6:0,3,op2,op2,3,5,op3,op3,8,8,op4,op4,16,3,-,null
1010
function,2,level,6:0,1,op3,op3,1,2,-,null,3,2,op1,op1,5,14,-,null
11-
kernel,Kernel statuses,level,6:0,4,WAIT_CPU,WAIT_CPU,4,15,RUN,RUN
11+
kernel,Kernel statuses,level,6:0,4,WAIT_CPU,WAIT_CPU,4,7,RUN,RUN,11,8,RUN_SYTEMCALL,RUN_SYTEMCALL
1212
function,0,level,7:0,19,op5,op5
1313
function,1,level,7:0,12,op2,op2,12,7,-,null
1414
function,2,level,7:0,1,op3,op3,1,18,-,null

analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullZoom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ kernel,Kernel statuses,level,3:8,9,RUN,RUN
88
function,0,level,6:0,19,op1,op1
99
function,1,level,6:8,8,op4,op4,16,3,-,null
1010
function,2,level,6:5,14,-,null
11-
kernel,Kernel statuses,level,6:4,15,RUN,RUN
11+
kernel,Kernel statuses,level,6:4,7,RUN,RUN,11,8,RUN_SYTEMCALL,RUN_SYTEMCALL
1212
function,0,level,7:0,19,op5,op5
1313
function,1,level,7:0,12,op2,op2,12,7,-,null
1414
function,2,level,7:1,18,-,null
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
function,0,level,All:0,8,op4,op4,44,28,op1,op1
22
function,1,level,All:0,8,-,null,64,8,-,null
33
function,2,level,All:0,25,-,null,51,21,-,null
4-
kernel,Kernel statuses,level,All:0,8,RUN,RUN,53,19,RUN,RUN
4+
kernel,Kernel statuses,level,All:0,8,RUN_SYTEMCALL,RUN_SYTEMCALL,61,11,RUN,RUN
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
function,0,level,All:0,8,op4,op4,8,17,op2,op2,25,19,op5,op5,44,28,op1,op1
22
function,1,level,All:0,8,-,null,8,1,op3,op3,9,6,op2,op2,15,10,-,null,25,12,op2,op2,37,7,-,null,44,5,op3,op3,49,7,op2,op2,56,8,op4,op4,64,8,-,null
33
function,2,level,All:0,25,-,null,25,1,op3,op3,26,18,-,null,44,2,op1,op1,46,3,-,null,49,2,op3,op3,51,21,-,null
4-
kernel,Kernel statuses,level,All:0,8,RUN,RUN,8,8,WAIT_CPU,WAIT_CPU,16,9,RUN,RUN,25,8,WAIT_CPU,WAIT_CPU,33,11,RUN,RUN,44,9,WAIT_CPU,WAIT_CPU,53,19,RUN,RUN
4+
kernel,Kernel statuses,level,All:0,8,RUN_SYTEMCALL,RUN_SYTEMCALL,8,8,WAIT_CPU,WAIT_CPU,16,9,RUN,RUN,25,8,WAIT_CPU,WAIT_CPU,33,11,RUN,RUN,44,8,RUN_SYTEMCALL,RUN_SYTEMCALL,52,9,WAIT_CPU,WAIT_CPU,61,11,RUN,RUN
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
function,0,level,All:25,19,op5,op5,44,28,op1,op1
22
function,1,level,All:25,12,op2,op2,37,7,-,null,44,5,op3,op3,49,7,op2,op2,56,8,op4,op4,64,8,-,null
33
function,2,level,All:26,18,-,null,44,2,op1,op1,46,3,-,null,49,2,op3,op3,51,21,-,null
4-
kernel,Kernel statuses,level,All:33,11,RUN,RUN,44,9,WAIT_CPU,WAIT_CPU,53,19,RUN,RUN
4+
kernel,Kernel statuses,level,All:33,11,RUN,RUN,44,8,RUN_SYTEMCALL,RUN_SYTEMCALL,52,9,WAIT_CPU,WAIT_CPU,61,11,RUN,RUN

0 commit comments

Comments
 (0)