<!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: rgba(255,255,255,.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: rgba(255,255,255,.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;">
<a href="https://gitlab.rtems.org/zhugengyu2023">geng zhu</a> created an issue: <a href="https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/issues/52">#52</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">
<a href="#summary" aria-hidden="true" class="anchor" id="user-content-summary" style="margin-top: 0; margin-left: -20px; text-decoration: none; outline: none; position: absolute; width: 20px;"></a>Summary</h2>

<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Hello everyone,</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">I am currently conducting tests on RTEMS 6.1 in conjunction with rtems - libbsd 6.1 and FreeBSD - 14. During the testing process, I've encountered some issues when using the SMP (Symmetric Multi - Processing) mode of libbsd.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial"><a class="no-attachment-icon gfm" href="https://gitlab.rtems.org/-/project/13/uploads/796692e7f9148dbeb49565bd38356a6a/image.png" target="_blank" rel="noopener noreferrer" data-canonical-src="/uploads/796692e7f9148dbeb49565bd38356a6a/image.png" data-link="true" style="margin-top: 0;"><img src="https://gitlab.rtems.org/-/project/13/uploads/796692e7f9148dbeb49565bd38356a6a/image.png" alt="image" width="819" height="296" data-canonical-src="/uploads/796692e7f9148dbeb49565bd38356a6a/image.png" class="gfm" style="max-width: 100%; height: auto; margin-top: 0; vertical-align: baseline; object-fit: contain; object-position: top;"></a></p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The UP (Uniprocessor) mode of libbsd functions quite smoothly. However, when it comes to the SMP mode, specifically on a 4 - core system (comprising two little cores and two big cores), I've identified two problems:</p>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0 0 1rem; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<ol style="margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Occasionally, the shell fails to start during the system boot - up process.</li>
</ol>
</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<ol start="2" style="margin: 0; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">After a continuous flood of ping requests (approximately after 8000 packets), ping echoes start to get lost. Additionally, the <code style='font-size: 90%; color: #18171d; word-wrap: break-word; border-radius: .25rem; background-color: #ececef; margin-top: 0; 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;'>cgem_tick</code> function (which runs in the TIME task) fails to execute.</li>
</ol>
</li>
</ul>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">It appears that there are conflicts between the interrupt tasks running on Core 0 and the Shell/Timer tasks. After binding both the Shell task and the Timer task to Core 1, the aforementioned two issues seem to have disappeared.</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: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; border-radius: .25rem; background-color: inherit; white-space: pre; margin-top: 0; 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: 0;"><span class="kt" style="margin-top: 0;">void</span> <span class="nf">rtems_shell_usr_set</span> <span class="p">(</span></span>
<span id="LC2" class="line" lang="c">  <span class="kt" style="margin-top: 0;">void</span></span>
<span id="LC3" class="line" lang="c"><span class="p" style="margin-top: 0;">)</span></span>
<span id="LC4" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC5" class="line" lang="c"><span class="cp" style="margin-top: 0;">#if (CONFIGURE_MAXIMUM_PROCESSORS  > 1)</span></span>
<span id="LC6" class="line" lang="c">  <span class="n" style="margin-top: 0;">cpu_set_t</span> <span class="n">cpu_set</span><span class="p">;</span></span>
<span id="LC7" class="line" lang="c">  <span class="n" style="margin-top: 0;">CPU_ZERO</span><span class="p">(</span><span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC8" class="line" lang="c">  <span class="n" style="margin-top: 0;">CPU_SET</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC9" class="line" lang="c">  <span class="n" style="margin-top: 0;">rtems_status_code</span> <span class="n">sc</span> <span class="o">=</span> <span class="n">rtems_task_set_affinity</span><span class="p">(</span><span class="n">RTEMS_SELF</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">cpu_set</span><span class="p">),</span> <span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC10" class="line" lang="c">  <span class="k" style="margin-top: 0;">if</span> <span class="p">(</span><span class="n">sc</span> <span class="o">!=</span> <span class="n">RTEMS_SUCCESSFUL</span><span class="p">)</span> <span class="p">{</span></span>
<span id="LC11" class="line" lang="c">      <span class="n" style="margin-top: 0;">printf</span><span class="p">(</span><span class="s">"Failed to set task affinity: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">sc</span><span class="p">);</span></span>
<span id="LC12" class="line" lang="c">  <span class="p" style="margin-top: 0;">}</span> <span class="k">else</span> <span class="p">{</span></span>
<span id="LC13" class="line" lang="c">      <span class="n" style="margin-top: 0;">printf</span><span class="p">(</span><span class="s">"Shell task affinity set to CPU 1</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span></span>
<span id="LC14" class="line" lang="c">  <span class="p" style="margin-top: 0;">}</span></span>
<span id="LC15" class="line" lang="c"><span class="cp" style="margin-top: 0;">#endif</span></span>
<span id="LC16" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC17" class="line" lang="c"></span>
<span id="LC18" class="line" lang="c"><span class="k" style="margin-top: 0;">static</span> <span class="n">rtems_task</span> <span class="nf">rtems_shell_task</span><span class="p">(</span><span class="n">rtems_task_argument</span> <span class="n">task_argument</span><span class="p">)</span></span>
<span id="LC19" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC20" class="line" lang="c">  <span class="n" style="margin-top: 0;">rtems_shell_usr_set</span> <span class="p">();</span></span>
<span id="LC21" class="line" lang="c">  <span class="p" style="margin-top: 0;">...</span></span>
<span id="LC22" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC23" class="line" lang="c"></span>
<span id="LC24" class="line" lang="c"><span class="kt" style="margin-top: 0;">void</span> <span class="nf">rtems_timer_usr_set</span> <span class="p">(</span></span>
<span id="LC25" class="line" lang="c">  <span class="kt" style="margin-top: 0;">void</span></span>
<span id="LC26" class="line" lang="c"><span class="p" style="margin-top: 0;">)</span></span>
<span id="LC27" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC28" class="line" lang="c"><span class="cp" style="margin-top: 0;">#if (CONFIGURE_MAXIMUM_PROCESSORS  > 1)</span></span>
<span id="LC29" class="line" lang="c">  <span class="n" style="margin-top: 0;">cpu_set_t</span> <span class="n">cpu_set</span><span class="p">;</span></span>
<span id="LC30" class="line" lang="c">  <span class="n" style="margin-top: 0;">CPU_ZERO</span><span class="p">(</span><span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC31" class="line" lang="c">  <span class="n" style="margin-top: 0;">CPU_SET</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC32" class="line" lang="c">  <span class="n" style="margin-top: 0;">rtems_status_code</span> <span class="n">sc</span> <span class="o">=</span> <span class="n">rtems_task_set_affinity</span><span class="p">(</span><span class="n">RTEMS_SELF</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">cpu_set</span><span class="p">),</span> <span class="o">&</span><span class="n">cpu_set</span><span class="p">);</span></span>
<span id="LC33" class="line" lang="c">  <span class="k" style="margin-top: 0;">if</span> <span class="p">(</span><span class="n">sc</span> <span class="o">!=</span> <span class="n">RTEMS_SUCCESSFUL</span><span class="p">)</span> <span class="p">{</span></span>
<span id="LC34" class="line" lang="c">      <span class="n" style="margin-top: 0;">printf</span><span class="p">(</span><span class="s">"Failed to set task affinity: %d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">sc</span><span class="p">);</span></span>
<span id="LC35" class="line" lang="c">  <span class="p" style="margin-top: 0;">}</span> <span class="k">else</span> <span class="p">{</span></span>
<span id="LC36" class="line" lang="c">      <span class="n" style="margin-top: 0;">printf</span><span class="p">(</span><span class="s">"Timer task affinity set to CPU 1</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span></span>
<span id="LC37" class="line" lang="c">  <span class="p" style="margin-top: 0;">}</span></span>
<span id="LC38" class="line" lang="c"><span class="cp" style="margin-top: 0;">#endif</span></span>
<span id="LC39" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC40" class="line" lang="c"></span>
<span id="LC41" class="line" lang="c"><span class="k" style="margin-top: 0;">static</span> <span class="n">rtems_task</span> <span class="nf">_Timer_server_Body</span><span class="p">(</span></span>
<span id="LC42" class="line" lang="c">  <span class="n" style="margin-top: 0;">rtems_task_argument</span> <span class="n">arg</span></span>
<span id="LC43" class="line" lang="c"><span class="p" style="margin-top: 0;">)</span></span>
<span id="LC44" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC45" class="line" lang="c">  <span class="n" style="margin-top: 0;">rtems_timer_usr_set</span><span class="p">();</span></span>
<span id="LC46" class="line" lang="c">  <span class="p" style="margin-top: 0;">...</span></span>
<span id="LC47" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#steps-to-reproduce" aria-hidden="true" class="anchor" id="user-content-steps-to-reproduce" style="margin-top: 0; margin-left: -20px; text-decoration: none; outline: none; position: absolute; width: 20px;"></a>Steps to reproduce</h2>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0 0 1rem; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Enable 4 - core SMP on an AARCH64 BSP.</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Utilize the pl011 UART with a polling shell.</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">Employ the if_cgem network and perform a flood ping to the RTEMS system.</li>
</ul>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" 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: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; border-radius: .25rem; background-color: inherit; white-space: pre; margin-top: 0; 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="plaintext" style="margin-top: 0;"># task</span>
<span id="LC2" class="line" lang="plaintext">[>0qID       NAME                 SHED PRI STATE  MODES    EVENTS WAITINFO</span>
<span id="LC3" class="line" lang="plaintext">------------------------------------------------------------------------------</span>
<span id="LC4" class="line" lang="plaintext">0a010001 UI1                  MEDF 2147483646 EV P:T:nA   NONE   </span>
<span id="LC5" class="line" lang="plaintext">0a010002 BSWP                 MEDF 105 EV     P:T:nA   NONE   </span>
<span id="LC6" class="line" lang="plaintext">0a010003 MDIA                 MEDF 200 EV     P:T:nA   NONE   </span>
<span id="LC7" class="line" lang="plaintext">0a010004 USBR                 MEDF 2147483636 MSG P:T:nA   NONE   22010002</span>
<span id="LC8" class="line" lang="plaintext">0a010005 USBO                 MEDF 2147483635 MSG P:T:nA   NONE   22010001</span>
<span id="LC9" class="line" lang="plaintext">0a010006 USBR                 MEDF 2147483636 MSG P:T:nA   NONE   22010004</span>
<span id="LC10" class="line" lang="plaintext">0a010007 USBO                 MEDF 2147483635 MSG P:T:nA   NONE   22010003</span>
<span id="LC11" class="line" lang="plaintext">0a010008 TIME                 MEDF  98 SYSEV  P:T:nA   NONE   </span>
<span id="LC12" class="line" lang="plaintext">0a010009 IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   </span>
<span id="LC13" class="line" lang="plaintext">0a01000a IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   </span>
<span id="LC14" class="line" lang="plaintext">0a01000b IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   </span>
<span id="LC15" class="line" lang="plaintext">0a01000c IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   </span>
<span id="LC16" class="line" lang="plaintext">0a01000d _BSD kqueue_ctx task MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC17" class="line" lang="plaintext">0a01000e _BSD swi5: fast task MEDF 100 EV     P:T:nA   NONE   </span>
<span id="LC18" class="line" lang="plaintext">0a01000f _BSD thread taskq    MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC19" class="line" lang="plaintext">0a010010 _BSD swi6: Giant tas MEDF 100 EV     P:T:nA   NONE   </span>
<span id="LC20" class="line" lang="plaintext">0a010011 _BSD swi6: task queu MEDF 100 EV     P:T:nA   NONE   </span>
<span id="LC21" class="line" lang="plaintext">0a010012 _BSD inm_free taskq  MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC22" class="line" lang="plaintext">0a010013 _BSD in6m_free taskq MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC23" class="line" lang="plaintext">0a010014 _BSD deferred_unmoun MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC24" class="line" lang="plaintext">0a010015 _BSD swi1: netisr 0  MEDF 100 EV     P:T:nA   NONE   </span>
<span id="LC25" class="line" lang="plaintext">0a010016 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC26" class="line" lang="plaintext">0a010017 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC27" class="line" lang="plaintext">0a010018 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC28" class="line" lang="plaintext">0a010019 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   WCTRL</span>
<span id="LC29" class="line" lang="plaintext">0a01001a _BSD usbus0          MEDF 100 READY  P:T:nA   NONE   </span>
<span id="LC30" class="line" lang="plaintext">0a01001b _BSD bufdaemon       MEDF 100 WK     P:T:nA   NONE   psleep</span>
<span id="LC31" class="line" lang="plaintext">0a01001c _BSD syncer          MEDF 100 WK     P:T:nA   NONE   syncer</span>
<span id="LC32" class="line" lang="plaintext">0a01001d _BSD vnlru           MEDF 100 WK     P:T:nA   NONE   vlruwt</span>
<span id="LC33" class="line" lang="plaintext">0a01001e _BSD bufspacedaemon- MEDF 100 WK     P:T:nA   NONE   -</span>
<span id="LC34" class="line" lang="plaintext">0a01001f TNTa                 MEDF 100 SYSEV  P:T:nA   NONE   </span>
<span id="LC35" class="line" lang="plaintext">0a010020 TNTb                 MEDF 100 SYSEV  P:T:nA   NONE   </span>
<span id="LC36" class="line" lang="plaintext">0a010021 TNTc                 MEDF 100 SYSEV  P:T:nA   NONE   </span>
<span id="LC37" class="line" lang="plaintext">0a010022 TNTd                 MEDF 100 SYSEV  P:T:nA   NONE   </span>
<span id="LC38" class="line" lang="plaintext">0a010023 TNTe                 MEDF 100 SYSEV  P:T:nA   NONE   </span>
<span id="LC39" class="line" lang="plaintext">0a010024 TNTD                 MEDF 100 WK     P:T:nA   NONE   accept</span>
<span id="LC40" class="line" lang="plaintext">0a010025 SHLL                 MEDF 150 READY  P:T:nA   NONE   </span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h3 dir="auto" style="margin-top: 1.5rem; margin-bottom: 0; font-weight: 600; font-size: 1.125rem; letter-spacing: inherit; line-height: 1.25; color: #18171d;" align="initial">
<a href="#pre---set-options" aria-hidden="true" class="anchor" id="user-content-pre---set-options" style="margin-top: 0; margin-left: -20px; text-decoration: none; outline: none; position: absolute; width: 20px;"></a>Pre - set options</h3>
</div>

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

<br>
<a href="https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/issues/52">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/eaa6ed23546d8d0aecee89afd89b49e6/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/pkg/rtems-libbsd/-/issues/52 at 1756361288
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/issues/52"}}</script>


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