Converting CPU clock values to wall time
- johnbl
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 3
10 Oct 2021 13:36 #222748
by johnbl
Converting CPU clock values to wall time was created by johnbl
Hi,
As far as I understand, pretty much all time values reported by HAL and Mesa cards are CPU clock counts instead of actual time (e.g.: thread time, thread max-time, hm2 *.tmax params, ...).
To convert these values to milli-seconds, I use the TSC tick rate calculated by the kernel, which can be extracted with:
For example, if the param read.tmax from my Mesa 7i96 is 300'000, the value in ms would be 300 * 1000 / tsc_khz.
Is this the correct way to do it?
As far as I understand, pretty much all time values reported by HAL and Mesa cards are CPU clock counts instead of actual time (e.g.: thread time, thread max-time, hm2 *.tmax params, ...).
To convert these values to milli-seconds, I use the TSC tick rate calculated by the kernel, which can be extracted with:
bpftrace -e 'BEGIN { printf("%u\n", *kaddr("tsc_khz")); exit(); }'
For example, if the param read.tmax from my Mesa 7i96 is 300'000, the value in ms would be 300 * 1000 / tsc_khz.
Is this the correct way to do it?
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10804
- Thank you received: 3556
10 Oct 2021 18:45 #222790
by rodw
Replied by rodw on topic Converting CPU clock values to wall time
I'm not sure of your intent here. Where are you doing this? For what purpose?
If you are writing a component the global variable fperiod will contain the time in seconds for that particular servo cycle.
If you are writing a component the global variable fperiod will contain the time in seconds for that particular servo cycle.
Please Log in or Create an account to join the conversation.
- johnbl
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 3
10 Oct 2021 18:49 #222791
by johnbl
Replied by johnbl on topic Converting CPU clock values to wall time
My goal here is simply to make sense of the *.tmax values from my Mesa card, to check how much headroom I have for the servo thread rate.
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
Less
More
- Posts: 7000
- Thank you received: 1172
10 Oct 2021 22:35 #222802
by BigJohnT
Replied by BigJohnT on topic Converting CPU clock values to wall time
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
Less
More
- Posts: 7000
- Thank you received: 1172
10 Oct 2021 22:36 #222803
by BigJohnT
Replied by BigJohnT on topic Converting CPU clock values to wall time
Attachments:
The following user(s) said Thank You: tommylight, johnbl
Please Log in or Create an account to join the conversation.
- johnbl
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 3
11 Oct 2021 11:55 - 11 Oct 2021 11:55 #222849
by johnbl
Replied by johnbl on topic Converting CPU clock values to wall time
Nice! Didn't know about that feature.
Last edit: 11 Oct 2021 11:55 by johnbl.
Please Log in or Create an account to join the conversation.
Time to create page: 0.091 seconds