<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>

<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: hsla(0,0%,100%,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: hsla(0,0%,100%,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">

<p class="details" style="font-style: italic; color: #626168;">
Issue created by <a href="https://gitlab.rtems.org/zbarnett">Zebulun Barnett</a>: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5671">#5671</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">Disclaimer: I got Claude to write this out so I didn't have to type so much but I did read through and everything looks correct to me.</p>
<h2 id="user-content-summary" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">In SMP configurations built with <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR</code>, the record subsystem produces all <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">RTEMS_RECORD_UPTIME_LOW</code>/<code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">RTEMS_RECORD_UPTIME_HIGH</code> pairs into the boot processor's ring. The rings of secondary processors never receive uptime anchors. Tools that rely on per-ring anchors to associate the 22-bit event timestamps with absolute time (rtems-record-client and everything downstream) therefore cannot resolve timestamps for events of secondary processors: the client's hold-back state for those rings never clears, and captures come out with unusable timestamps for CPUs > 0. As far as I can tell from the history (below), this combination has never worked.</p>
<h2 id="user-content-mechanism" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Mechanism<a href="#mechanism" aria-label="Link to heading 'Mechanism'" data-heading-content="Mechanism" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial"><code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Record_Watchdog()</code> in <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">cpukit/libtrace/record/record-sysinit.c</code> re-arms its watchdog on the <em>owning</em> processor but produces the uptime events on the <em>executing</em> processor:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0px 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="c" style="margin-top: 0px;"><span class="n" style="margin-top: 0px;">_Watchdog_Per_CPU_insert_ticks</span><span class="p">(</span></span>
<span id="LC2" class="line" lang="c">  <span class="n" style="margin-top: 0px;">watchdog</span><span class="p">,</span></span>
<span id="LC3" class="line" lang="c">  <span class="n" style="margin-top: 0px;">_Watchdog_Get_CPU</span><span class="p">(</span> <span class="n">watchdog</span> <span class="p">),</span>                  <span class="cm">/* owner CPU */</span></span>
<span id="LC4" class="line" lang="c">  <span class="n" style="margin-top: 0px;">_Record_Tick_interval</span></span>
<span id="LC5" class="line" lang="c"><span class="p" style="margin-top: 0px;">);</span></span>
<span id="LC6" class="line" lang="c"><span class="n" style="margin-top: 0px;">now</span> <span class="o">=</span> <span class="n">_Timecounter_Sbinuptime</span><span class="p">();</span></span>
<span id="LC7" class="line" lang="c"><span class="n" style="margin-top: 0px;">rtems_record_prepare_critical</span><span class="p">(</span> <span class="o">&</span><span class="n">context</span><span class="p">,</span> <span class="n">_Per_CPU_Get</span><span class="p">()</span> <span class="p">);</span>  <span class="cm">/* executing CPU */</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">With <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR</code>, <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">Clock_driver_timecounter_tick()</code> in <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">bsps/shared/dev/clock/clockimpl.h</code> has the boot processor service the watchdog headers of all online processors:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0px 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0px; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="c" style="margin-top: 0px;"><span class="err" style="margin-top: 0px;">}</span> <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span> <span class="n">_Processor_mask_Is_set</span><span class="p">(</span> <span class="n">_SMP_Get_online_processors</span><span class="p">(),</span> <span class="n">cpu_index</span> <span class="p">)</span> <span class="p">)</span> <span class="p">{</span></span>
<span id="LC2" class="line" lang="c">  <span class="n" style="margin-top: 0px;">_Watchdog_Tick</span><span class="p">(</span> <span class="n">cpu</span> <span class="p">);</span></span>
<span id="LC3" class="line" lang="c"><span class="p" style="margin-top: 0px;">}</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">So for every secondary processor's record watchdog, executor != owner: the routine runs on the boot processor, <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Per_CPU_Get()</code> yields the boot processor, and the anchors land in ring 0. The owner-based re-arm keeps ownership intact, so this persists for the lifetime of the system. This is the only cross-processor <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Watchdog_Tick()</code> call site in the tree; in the default configuration each processor runs <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Timecounter_Tick()</code> itself, executor == owner always holds, and the record subsystem behaves as intended.</p>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">Setting <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR = False</code> restores per-ring anchors and correct client output.</p>
<h2 id="user-content-history" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">History<a href="#history" aria-label="Link to heading 'History'" data-heading-content="History" class="anchor" style="margin-top: 0px;"></a>
</h2>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0px 0px 1rem; padding: 0;">
<li style="margin-top: 0px; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/commit/b61d5cac7c5f1ba801a8d0f896313b2e5cd01111" title="bsps: Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR" class="gfm gfm-commit has-tooltip" data-original="b61d5cac7c" data-link="false" data-link-reference="false" data-commit="b61d5cac7c5f1ba801a8d0f896313b2e5cd01111" data-project="26" data-container="body" data-placement="top" data-reference-type="commit" style="font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; font-size: 95%; margin-top: 0px;">b61d5cac</a> (2016-06-14) "bsps: Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR" — clock tick processing on the boot processor on behalf of all other processors, introduced as a workaround for a QEMU shortcoming on ARM (<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/2737" title="Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR" class="gfm gfm-issue" data-original="#2737" data-link="false" data-link-reference="false" data-issue="25103" data-project="26" data-iid="2737" data-namespace-path="rtems/rtos/rtems" data-project-path="rtems/rtos/rtems" data-issue-type="issue" data-container="body" data-placement="top" data-reference-type="issue">#2737 (closed)</a>). It has since become a regular build option and is hardwired by some BSPs.</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/commit/dca618404ee61c1be8a883ddb679889dbfea284b" title="Add low level event recording support" class="gfm gfm-commit has-tooltip" data-original="dca618404e" data-link="false" data-link-reference="false" data-commit="dca618404ee61c1be8a883ddb679889dbfea284b" data-project="26" data-container="body" data-placement="top" data-reference-type="commit" style="font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; font-size: 95%; margin-top: 0px;">dca61840</a> (2018-04-28) "Add low level event recording support" — <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;">_Record_Watchdog()</code> already has its current owner/executor shape in this commit. The incompatibility has existed since then.</li>
</ul>
<h2 id="user-content-possible-fix" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Possible fix<a href="#possible-fix" aria-label="Link to heading 'Possible fix'" data-heading-content="Possible fix" class="anchor" style="margin-top: 0px;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">When <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0px; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Per_CPU_Get() != _Watchdog_Get_CPU( watchdog )</code>, defer the production to the owner via <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_Per_CPU_Submit_job()</code>: a <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">Per_CPU_Job</code> embedded in <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">Record_Control</code>, re-initialized each period, with submission skipped if the previous job has not completed. Cost is one IPI per secondary processor per anchor interval, which seems negligible. Alternatives look worse: producing into the remote ring violates the single-producer invariant; adding the processor index to the uptime events churns the protocol and clients and is only sound where the counter is system-global; handling it purely in the client cannot restore the per-ring at-least-one-item-per-2^22-cycles property that bounds timestamp wrap tracking.</p>
<p dir="auto" style="color: #3a383f; margin: 0px;" align="initial"><a href="https://gitlab.rtems.org/sebhub" title="Sebastian Huber" class="gfm gfm-project_member js-user-link" data-user="28" data-original="@sebhub" data-container="body" data-placement="top" data-reference-type="user" style="color: #284779; background-color: #cbe2f9; border-radius: .25rem; margin-top: 0px; padding: 0 2px;">@sebhub</a></p>
</div>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">

<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5671">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/4-7dm7rjt5qt2nyz5i9dzykgl8b-1d/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5671 at 1785286633
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Work item","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5671"}}</script>


</p>
</div>
</body>
</html>