Skip to contentSkip to conversation

cobalt_switch_context plugin

RFC PATCH In review Hongzhan Chen 2 participants 14 messages Dec 14, 2021 – Dec 15, 2021

lore
Share & tools
lore
#0 lore raw

cover cobalt_switch_context plugin

1. add plugin to take correct action to show correct color for cobalt_switch_context in cpu plot
2. show hollow blue box underneath baseline of task plot to mark oob state task is runing on.

steps to show hollow blue box
1. loading trace-cmd data, please note that it would check if there is cobalt_switch_context event in data. If does not exist ,the cobalt_switch_context plugin would fail to init.
2. click menu plots-> tasks and then choose RT tasks that you want to show and then apply.
3. In RT tasks plot shape you may find the hollow blue box that indicating that it is running on OOB underneath the baseline of plot.

Please help check if it meet our requirement and comments.

Hongzhan Chen (2):
kernel-shark: add plugin for handling xenomai cobalt context switch
event
kernelshark: shape blue hollow box to show OOB state of task

 src/libkshark-tepdata.c                    |   1 +
 src/plugins/CMakeLists.txt                 |   4 +
 src/plugins/CobaltSwitchEvents.cpp         | 204 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.c | 196 ++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.h |  64 +++++++
 5 files changed, 469 insertions(+)
 create mode 100644 src/plugins/CobaltSwitchEvents.cpp
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.c
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.h
Signature · 1 line
2.17.1
#1 lore raw

RFC PATCH 1/2 kernel-shark: add plugin for handling xenomai cobalt context switch event

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

---
 src/libkshark-tepdata.c                    |   1 +
 src/plugins/CMakeLists.txt                 |   4 +
 src/plugins/xenomai_cobalt_switch_events.c | 116 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.h |  45 ++++++++
 4 files changed, 166 insertions(+)
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.c
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.h
src/libkshark-tepdata.c +1 -0
index 9740ed9..e933b39 100644
@@ -1208,6 +1208,7 @@ static void kshark_tep_init_methods(struct kshark_generic_stream_interface *inte
 /** A list of built in default plugins for FTRACE (trace-cmd) data. */
 const char *tep_plugin_names[] = {
 	"sched_events",
+	"xenomai_cobalt_switch_events",
 	"missed_events",
 	"kvm_combo",
 };
src/plugins/CMakeLists.txt +4 -0
index 3e170fa..276eaaa 100644
@@ -44,6 +44,10 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE)
                      SOURCE sched_events.c SchedEvents.cpp)
     list(APPEND PLUGIN_LIST "sched_events")
 
+    BUILD_GUI_PLUGIN(NAME xenomai_cobalt_switch_events
+                     SOURCE xenomai_cobalt_switch_events.c)
+    list(APPEND PLUGIN_LIST "xenomai_cobalt_switch_events")
+
     BUILD_GUI_PLUGIN(NAME event_field_plot
                      MOC EventFieldDialog.hpp
                      SOURCE event_field_plot.c EventFieldDialog.cpp EventFieldPlot.cpp)
src/plugins/xenomai_cobalt_switch_events.c new file +116 -0

116 lines not on this page · raw message

src/plugins/xenomai_cobalt_switch_events.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#3 lore raw

RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 17 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

Quoted 8 lines
            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

Quoted 6 lines

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#4 lore raw

Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 21 lines · Hongzhan
Quoted 21 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
Quoted 7 lines
Quoted 4 lines

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back and forth. And it has no RT mode visualization.

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#5 lore raw

Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 27 lines · Jan Kiszka via Xenomai
Quoted 26 lines · Hongzhan
Quoted 25 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

Quoted 7 lines
Quoted 2 lines

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back and forth. And it has no RT mode visualization.

Correction: The CPU graph is fine now as well. Still confusing that you have to enable task plots first, but that might be a generic KernelShark issue.

Quoted 4 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#6 lore raw

RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 39 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 3:02 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 30 lines · Jan Kiszka via Xenomai
Quoted 28 lines · Hongzhan
Quoted 17 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

Quoted 8 lines
            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

Quoted 8 lines
Quoted 4 lines

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back and forth. And it has no RT mode visualization.

Correction: The CPU graph is fine now as well. Still confusing that you have to enable task plots first, but that might be a generic KernelShark issue.

Yes, this is kernelshark issue. Kernel shark have to depend on redraw of plugin after activation to correct them.

Quoted 8 lines
Quoted 5 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

Quoted 8 lines
       pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
       pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
      hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
      hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
      hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Regards

Hongzhan Chen

Quoted 6 lines

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#7 lore raw

Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 65 lines · Hongzhan
Quoted 39 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 3:02 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 30 lines · Jan Kiszka via Xenomai
Quoted 28 lines · Hongzhan
Quoted 17 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

Quoted 8 lines
            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

Quoted 8 lines
Quoted 4 lines

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back and forth. And it has no RT mode visualization.

Correction: The CPU graph is fine now as well. Still confusing that you have to enable task plots first, but that might be a generic KernelShark issue.

Yes, this is kernelshark issue. Kernel shark have to depend on redraw of plugin after activation to correct them.

Quoted 14 lines
Quoted 5 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

       pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
       pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
      hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
      hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
      hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
Quoted 6 lines
Quoted 2 lines

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Yeah, the problem is indeed that the bar is only drawn if beg AND end points are visible - that is sure not useful. Does the drawing concept of kernelshark imposes this limitation?

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#8 lore raw

RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 5 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

       pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
       pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
      hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
      hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
      hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Quoted 7 lines
Quoted 3 lines

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Yeah, the problem is indeed that the bar is only drawn if beg AND end points are visible - that is sure not useful. Does the drawing concept of kernelshark imposes this limitation?

This should be common issue in kernelshark. I also observed same issue on hollow red box for preempt latency implementation.

Regards

Hongzhan Chen

Quoted 6 lines

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#9 lore raw

Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 21 lines · Hongzhan
Quoted 21 lines
Quoted 20 lines
Quoted 8 lines
Quoted 5 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

Quoted 8 lines
       pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
       pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
      hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
      hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
      hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Quoted 7 lines
Quoted 3 lines

Yeah, the problem is indeed that the bar is only drawn if beg AND end points are visible - that is sure not useful. Does the drawing concept of kernelshark imposes this limitation?

This should be common issue in kernelshark. I also observed same issue on hollow red box for preempt latency implementation.

Ok, another topic to discuss with their community :)

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#10 lore raw

RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 34 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 3:51 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 25 lines · Hongzhan
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Some visualization issue:

       pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
       pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
      hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
      hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
      hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
Quoted 6 lines
Quoted 2 lines

In this case, the task plot of hi-thread-919 does no show the blue box between hardened and fault.

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Yeah, the problem is indeed that the bar is only drawn if beg AND end points are visible - that is sure not useful. Does the drawing concept of kernelshark imposes this limitation?

Quoted 5 lines
Quoted 3 lines

This should be common issue in kernelshark. I also observed same issue on hollow red box for preempt latency implementation.

Ok, another topic to discuss with their community :)

It is OK to submit this patch set to kernel-shark community to review if it meet our requirement? 😊

Regards

Hongzhan Chen

Quoted 6 lines

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#11 lore raw

RFC PATCH 2/2 kernelshark: shape blue hollow box to show OOB state of task

In reply to Hongzhan Chen

1. store cobalt_switch_contexts event to data container.
2. show blue hollow box to mark out-of-band state under the basedline of task plot according to cobalt_switch_context events.
3. clickable cobalt_switch_context plugin shapes.

---
 src/plugins/CMakeLists.txt                 |   2 +-
 src/plugins/CobaltSwitchEvents.cpp         | 204 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.c |  86 ++++++++-
 src/plugins/xenomai_cobalt_switch_events.h |  19 ++
 4 files changed, 307 insertions(+), 4 deletions(-)
 create mode 100644 src/plugins/CobaltSwitchEvents.cpp
src/plugins/CMakeLists.txt +1 -1
index 276eaaa..16f080b 100644
@@ -45,7 +45,7 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE)
     list(APPEND PLUGIN_LIST "sched_events")
 
     BUILD_GUI_PLUGIN(NAME xenomai_cobalt_switch_events
-                     SOURCE xenomai_cobalt_switch_events.c)
+                     SOURCE xenomai_cobalt_switch_events.c CobaltSwitchEvents.cpp)
     list(APPEND PLUGIN_LIST "xenomai_cobalt_switch_events")
 
     BUILD_GUI_PLUGIN(NAME event_field_plot
src/plugins/CobaltSwitchEvents.cpp new file +204 -0

204 lines not on this page · raw message

src/plugins/xenomai_cobalt_switch_events.c +83 -3

122 lines not on this page · raw message

src/plugins/xenomai_cobalt_switch_events.h +19 -0
index 4a3bc66..9e1e030 100644
@@ -20,6 +20,7 @@
 extern "C" {
 #endif
 
+#define SWITCH_INBAND_STATE	1
 /** Structure representing a plugin-specific context. */
 struct plugin_cobalt_context {
 	/** Page event used to parse the page. */
@@ -34,10 +35,28 @@ struct plugin_cobalt_context {
 	/** Pointer to the cobalt_switch_prev_state_field format descriptor. */
 	struct tep_format_field *cobalt_switch_prev_state_field;
 
+	/** True if the second pass is already done. */
+	bool	second_pass_done;
+
+	/** Data container for cobalt_switch_context data. */
+	struct kshark_data_container	*cs_data;
+
 };
 
 KS_DECLARE_PLUGIN_CONTEXT_METHODS(struct plugin_cobalt_context)
 
+/** The type of the data field stored in the kshark_data_container object. */
+typedef int64_t ks_num_field_t;
+
+int plugin_cobalt_get_pid(ks_num_field_t field);
+
+int plugin_cobalt_check_switch_inband(ks_num_field_t field);
+
+void plugin_cobalt_draw(struct kshark_cpp_argv *argv, int sd, int pid,
+		 int draw_action);
+
+void *plugin_cobalt_set_gui_ptr(void *gui_ptr);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.17.1
#12 lore raw

Re: [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task

Quoted 6 lines · Hongzhan Chen

1. store cobalt_switch_contexts event to data container.
2. show blue hollow box to mark out-of-band state under the basedline of task plot according to cobalt_switch_context events.
3. clickable cobalt_switch_context plugin shapes.

How do I activate this? I have the plugin built and apparently loaded, but I'm not seeing that new boxes in the CPU or task plots.

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#13 lore raw

RE: [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task

Quoted 34 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:49 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 26 lines · Hongzhan
Quoted 25 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, December 14, 2021 2:38 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event

Quoted 5 lines · Hongzhan Chen

For Xenomai-cobalt enabled system, cobalt_switch_context means that there is context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch. We need to update cpu bar regarding cobalt_switch_context event to correct color as switching-in task.

It's tricker... I have trace with the following sequence here:

            gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
            gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
       pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that cobalt_timer_start is still running under the previous pid, causing a color switch-back and than forth on cobalt_shadow_hardened. We need to understand why and possibly fix that or rethink the visualization.

Quoted 7 lines
Quoted 2 lines

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw and then the issue you observed would be fixed by plugin.

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back and forth. And it has no RT mode visualization.

Yes, it does not affect CPU. What does means jump back and forth now?

Quoted 2 lines

BTW, is that blue hollow box exclusive for our plugin? Or can this be

Currently there is other two hollow box as described in page 15 of [1]. Blue hollow box should be exclusive if we want to upstream if it upstream.

[1]: https://elinux.org/images/6/64/Elc2011_rostedt.pdf

Quoted 1 line

customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Yes, we can customize it. But once we finalize it and upstream , it should be exclusive and try not to confuse user per my understanding. I just refer to available design about hollow box usage in kernelshark as described in page 15 of [1]..

Quoted 6 lines

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux