Skip to content

hm2 TRACER - interested adding it to the official repository #4236

Description

@zz912

Hello,

I am testing Mesa card with Xenomai 4 #4199

It has amazing results, but on my PC configuration I sometimes get 800 000 ns spikes.

I created hm2_tracer for this.
https://github.com/zz912/linuxcnc/tree/feature/hm2-trace

You can read more about it here:
https://github.com/zz912/linuxcnc/blob/feature/hm2-trace/src/hal/drivers/mesa-hostmot2/hm2_tracer-readme.md

If anyone would like to try it out, just add to the hal file:

loadrt hm2_eth ......
loadusr hm2-trace-log

The program works in such a way that if the (hm2_7i96s.0.read + hm2_7i96s.0.write > 50% Realtime Threads Period) it creates a log file in ~.

For testing, I reduce the ratio: https://github.com/zz912/linuxcnc/blob/9a56334cd81756fcd5a9ddf861a7df0ed0bdd39e/src/hal/drivers/mesa-hostmot2/hm2_trace_trigger.c#L31

The log file looks like this:

HM2 TRACE

version           : 1
generation        : 1
trigger_reason    : LATENCY
trigger_ratio     : 15 %

read_runtime_ns   : 105024
write_runtime_ns  : 4119
total_runtime_ns  : 109143

read_tmax_ns      : 144604
write_tmax_ns     : 17003
total_tmax_ns     : 158941

ring_size         : 4096
ring_head         : 2153
trigger_index     : 104
samples_written   : 2153

Ring buffer:
------------
 idx        timestamp    snapshot(ns)      cycle(ns)      event(ns)  event
---- ---------------- --------------- --------------- --------------- ------------

....

  91   81878499561176       +13003605              +0         +880125 CYCLE_START 
  92   81878499561274       +13003703             +98             +98 READ_ENTER  
  93   81878499561299       +13003728            +123             +25 RECV_ENTER  
  94   81878499667685       +13110114         +106509         +106386 RECV_EXIT   
  95   81878499673268       +13115697         +112092           +5583 READ_EXIT   
  96   81878499687697       +13130126         +126521          +14429 WRITE_ENTER 
  97   81878499698230       +13140659         +137054          +10533 WRITE_EXIT  

  98   81878500558931       +14001360              +0         +860701 CYCLE_START 
  99   81878500559025       +14001454             +94             +94 READ_ENTER  
 100   81878500559050       +14001479            +119             +25 RECV_ENTER  
 101   81878500694149       +14136578         +135218         +135099 RECV_EXIT   
 102   81878500703629       +14146058         +144698           +9480 READ_EXIT   
 103   81878500725404       +14167833         +166473          +21775 WRITE_ENTER 


========================================================================
========================== TRIGGER DETECTED ============================
========================================================================


 104   81878500739741       +14182170         +180810          +14337 WRITE_EXIT  

 105   81878501555862       +14998291              +0         +816121 CYCLE_START 
 106   81878501555919       +14998348             +57             +57 READ_ENTER  
 107   81878501555994       +14998423            +132             +75 RECV_ENTER  
 108   81878501671492       +15113921         +115630         +115498 RECV_EXIT   
 109   81878501673620       +15116049         +117758           +2128 READ_EXIT   
 110   81878501679328       +15121757         +123466           +5708 WRITE_ENTER 
 111   81878501684921       +15127350         +129059           +5593 WRITE_EXIT  

 112   81878502555892       +15998321              +0         +870971 CYCLE_START 
 113   81878502555934       +15998363             +42             +42 READ_ENTER  
 114   81878502555985       +15998414             +93             +51 RECV_ENTER  
 115   81878502652085       +16094514          +96193          +96100 RECV_EXIT   
 116   81878502653360       +16095789          +97468           +1275 READ_EXIT   
 117   81878502658396       +16100825         +102504           +5036 WRITE_ENTER 
 118   81878502662937       +16105366         +107045           +4541 WRITE_EXIT  

hm2_trace_2026_07_11-06_41_47.log

I made the program with the help of ChatGPT. The project is in the "It works" phase. This phase is sufficient for my needs. However, if I wanted to make a proper code suitable for PR, I would like to redo the tracer architecture and its activation in the hal file.

I would like to ask if there would be interest in this hm2_tracer if I redid it?

@pcw-mesa what is your opinion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions