LibBSD | LibBSD quad-core SMP could fail and Shell and Timer task not avaiable (#52)

geng zhu (@zhugengyu2023) gitlab at rtems.org
Thu Aug 28 06:08:09 UTC 2025



geng zhu created an issue: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/issues/52



## Summary
<!--
Please provide as much information as possible such as error messages or attaching logs
-->

Hello everyone,

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.

![image](/uploads/796692e7f9148dbeb49565bd38356a6a/image.png){width=819 height=296}

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:
- 1. Occasionally, the shell fails to start during the system boot - up process.
- 2. After a continuous flood of ping requests (approximately after 8000 packets), ping echoes start to get lost. Additionally, the `cgem_tick` function (which runs in the TIME task) fails to execute.

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.

```c
void rtems_shell_usr_set (
  void
)
{
#if (CONFIGURE_MAXIMUM_PROCESSORS  > 1)
  cpu_set_t cpu_set;
  CPU_ZERO(&cpu_set);
  CPU_SET(1, &cpu_set);
  rtems_status_code sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpu_set), &cpu_set);
  if (sc != RTEMS_SUCCESSFUL) {
      printf("Failed to set task affinity: %d\n", sc);
  } else {
      printf("Shell task affinity set to CPU 1\n");
  }
#endif
}

static rtems_task rtems_shell_task(rtems_task_argument task_argument)
{
  rtems_shell_usr_set ();
  ...
}

void rtems_timer_usr_set (
  void
)
{
#if (CONFIGURE_MAXIMUM_PROCESSORS  > 1)
  cpu_set_t cpu_set;
  CPU_ZERO(&cpu_set);
  CPU_SET(1, &cpu_set);
  rtems_status_code sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(cpu_set), &cpu_set);
  if (sc != RTEMS_SUCCESSFUL) {
      printf("Failed to set task affinity: %d\n", sc);
  } else {
      printf("Timer task affinity set to CPU 1\n");
  }
#endif
}

static rtems_task _Timer_server_Body(
  rtems_task_argument arg
)
{
  rtems_timer_usr_set();
  ...
}
```

## Steps to reproduce

- Enable 4 - core SMP on an AARCH64 BSP.
- Utilize the pl011 UART with a polling shell.
- Employ the if_cgem network and perform a flood ping to the RTEMS system.

```
# task
[>0qID       NAME                 SHED PRI STATE  MODES    EVENTS WAITINFO
------------------------------------------------------------------------------
0a010001 UI1                  MEDF 2147483646 EV P:T:nA   NONE   
0a010002 BSWP                 MEDF 105 EV     P:T:nA   NONE   
0a010003 MDIA                 MEDF 200 EV     P:T:nA   NONE   
0a010004 USBR                 MEDF 2147483636 MSG P:T:nA   NONE   22010002
0a010005 USBO                 MEDF 2147483635 MSG P:T:nA   NONE   22010001
0a010006 USBR                 MEDF 2147483636 MSG P:T:nA   NONE   22010004
0a010007 USBO                 MEDF 2147483635 MSG P:T:nA   NONE   22010003
0a010008 TIME                 MEDF  98 SYSEV  P:T:nA   NONE   
0a010009 IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   
0a01000a IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   
0a01000b IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   
0a01000c IRQS                 MEDF  96 SYSEV  P:T:nA   NONE   
0a01000d _BSD kqueue_ctx task MEDF 100 WK     P:T:nA   NONE   -
0a01000e _BSD swi5: fast task MEDF 100 EV     P:T:nA   NONE   
0a01000f _BSD thread taskq    MEDF 100 WK     P:T:nA   NONE   -
0a010010 _BSD swi6: Giant tas MEDF 100 EV     P:T:nA   NONE   
0a010011 _BSD swi6: task queu MEDF 100 EV     P:T:nA   NONE   
0a010012 _BSD inm_free taskq  MEDF 100 WK     P:T:nA   NONE   -
0a010013 _BSD in6m_free taskq MEDF 100 WK     P:T:nA   NONE   -
0a010014 _BSD deferred_unmoun MEDF 100 WK     P:T:nA   NONE   -
0a010015 _BSD swi1: netisr 0  MEDF 100 EV     P:T:nA   NONE   
0a010016 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -
0a010017 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -
0a010018 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   -
0a010019 _BSD usbus0          MEDF 100 WK     P:T:nA   NONE   WCTRL
0a01001a _BSD usbus0          MEDF 100 READY  P:T:nA   NONE   
0a01001b _BSD bufdaemon       MEDF 100 WK     P:T:nA   NONE   psleep
0a01001c _BSD syncer          MEDF 100 WK     P:T:nA   NONE   syncer
0a01001d _BSD vnlru           MEDF 100 WK     P:T:nA   NONE   vlruwt
0a01001e _BSD bufspacedaemon- MEDF 100 WK     P:T:nA   NONE   -
0a01001f TNTa                 MEDF 100 SYSEV  P:T:nA   NONE   
0a010020 TNTb                 MEDF 100 SYSEV  P:T:nA   NONE   
0a010021 TNTc                 MEDF 100 SYSEV  P:T:nA   NONE   
0a010022 TNTd                 MEDF 100 SYSEV  P:T:nA   NONE   
0a010023 TNTe                 MEDF 100 SYSEV  P:T:nA   NONE   
0a010024 TNTD                 MEDF 100 WK     P:T:nA   NONE   accept
0a010025 SHLL                 MEDF 150 READY  P:T:nA   NONE   
```

### Pre - set options

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/issues/52
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250828/c97644c0/attachment-0001.htm>


More information about the bugs mailing list