Bug 218357 - trace-cmd split doesn't handle multiple instances
Summary: trace-cmd split doesn't handle multiple instances
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Trace-cmd/Kernelshark (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: Default virtual assignee for Trace-cmd and kernelshark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-09 10:29 UTC by pierre.gondois
Modified: 2024-01-10 18:51 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
trace.dat recorded with the record command given as example (4.35 MB, application/octet-stream)
2024-01-09 10:29 UTC, pierre.gondois
Details
Handle leaf node case in rbtree deletion (735 bytes, patch)
2024-01-10 13:44 UTC, Steven Rostedt
Details | Diff

Description pierre.gondois 2024-01-09 10:29:07 UTC
Created attachment 305690 [details]
trace.dat recorded with the record command given as example

trace-cmd can record events in multiple instances:
  $ trace-cmd record -e sched_wakeup -B test_instance -e sched_switch

When trying to split a trace.dat file recorded with the above command, only the events located in the main buffer seems to be split. The events recorded in the test_instance buffer seem to be discarded:
  $ trace-cmd split -i trace.dat -o trace_2.dat 284443 284444
  $ trace-cmd report trace_2.dat
    cpus=8
           <...>-525991 [004] 284443.173879: sched_wakeup:         wdavdaemon:525987 [120] CPU:007
           <...>-525991 [004] 284443.173879: sched_wakeup:         wdavdaemon:525987 [120] CPU:007
           <...>-525990 [007] 284443.173885: sched_wakeup:         wdavdaemon:525986 [120] CPU:007
           <...>-525990 [007] 284443.173885: sched_wakeup:         wdavdaemon:525986 [120] CPU:007
(no sign of sched_switch events)

As a side issue, it also seems that some timestamps make the trace-cmd split command fail:
  $ trace-cmd split -i trace.dat -o trace_2.dat 284443.2003 284444
  Segmentation fault
Comment 1 pierre.gondois 2024-01-09 10:35:22 UTC
I forgot to mention, trace-cmd is built from the latest:
08435acd37326c7030747dc5c3a10daca185e6fe (HEAD, origin/master, origin/HEAD) trace-cmd stat: Use tracefs_instance_file_read()
Comment 2 Steven Rostedt 2024-01-10 04:03:35 UTC
Moving to Tools: trace-cmd/KernelShark

As "Tracing/Profiling" is for the kernel component not the tooling.
Comment 3 pierre.gondois 2024-01-10 08:44:01 UTC
I have started to work on it, just to avoid a duplicated effort.
Comment 4 Steven Rostedt 2024-01-10 13:44:21 UTC
Created attachment 305691 [details]
Handle leaf node case in rbtree deletion

Can you see if this patch fixes it for you. The rbtree did't handle a deletion of a leaf node. I have no idea how this didn't trigger in my tests.
Comment 5 pierre.gondois 2024-01-10 14:00:07 UTC
Yes it solves the Segmentation fault issue,

Thanks
Comment 6 Steven Rostedt 2024-01-10 15:44:47 UTC
Unfortunately that patch is incorrect. Although it fixes the segfault, it corrupts the rbtree. I have the real fix here:

  https://lore.kernel.org/all/20240110103941.2e26da60@gandalf.local.home/

Note You need to log in before you can comment on or make changes to this bug.