jingfei195887 opened a new pull request, #20652:
URL: https://github.com/apache/nuttx/pull/20652

   ## Summary
   
   Two more footprint changes related to #20414 (follow-up to #20628). Both keep
   behavior unchanged and only drop flash.
   
   1. **sched/wqueue: move `g_hpwork`/`g_lpwork` to `.bss`**
      The static initializers put both kernel work queues in `.data`, so their
      initial image is stored in flash. Only the two self-referencing list heads
      and the thread count are non-zero; the semaphores, spinlock and timer were
      already zero-initialized. The queues now live in `.bss`, and
      `work_initialize()` sets those three fields at the start of `nx_start()`,
      before anything can queue work.
   
   2. **sched/spawn: skip policy handling on FIFO-only builds**
      With `CONFIG_RR_INTERVAL=0` and no `CONFIG_SCHED_SPORADIC`, `SCHED_FIFO` 
is
      the only scheduling policy and every task already uses it, yet
      `posix_spawnattr_init()` queries the caller's policy and 
`spawn_execattrs()`
      calls `nxsched_set_scheduler()`, which keeps the policy-switching code
      linked. In that configuration the spawn policy now defaults to 
`SCHED_FIFO`
      and only the priority is applied. Other policies are still rejected with
      `-EINVAL`, as before.
   
   ## Impact
   
   - (1) applies to every build with `CONFIG_SCHED_WORKQUEUE`. 120 bytes per 
queue
     move from `.data` to `.bss`, so total RAM is unchanged.
   - (2) applies only to FIFO-only builds (`RR_INTERVAL=0`, no sporadic, 280
     in-tree defconfigs). Builds with round-robin or sporadic scheduling are
     unchanged.
   - No API or ABI change. Make and CMake are unaffected (no new sources).
   
   ## Testing
   
   Host: Ubuntu x86_64, arm-none-eabi-gcc 10.3.1 20210621. Clean CMake builds of
   `stm32f103-minimum:nsh` on master f6e5be7972. Flash = text + data.
   
   | configuration | master | this PR | delta |
   |---|---:|---:|---:|
   | defconfig (text/data/bss) | 51975 / 468 / 2952 | 52007 / 348 / 3072 | 
flash **-88** |
   | `+SCHED_LPWORK` (flash) | 52611 | 52419 | **-192** |
   | `RR_INTERVAL=0` (flash, on top of commit 1) | 52123 | 51947 | **-176** |
   | defconfig, commit 2 only effect | 52355 | 52355 | 0 |
   
   With `RR_INTERVAL=0`, `nxsched_set_scheduler`, `nxsched_get_scheduler` and
   `sched_getscheduler` are no longer linked; with `RR_INTERVAL=0` plus
   `SCHED_SPORADIC=y` they are still linked and the build is unchanged.
   
   Other checks:
   - Builds: `sim:nsh` (RR_INTERVAL=0), `sim:ostest`, `sim:smp`, and
     `stm32f103-minimum:nsh` with `RR_INTERVAL=0 SCHED_SPORADIC=y`.
   - `sim:smp` boots to `nsh>`.
   - `sim:nsh` with `RR_INTERVAL=0`: `hello` runs and `ps` shows the same
     policy (FIFO) and priorities as master.
   - `sim:ostest` (with and without `RR_INTERVAL=0`): runs reached `wqueue_test`
     in a 300 s timeout with no `ERROR`, assertion or panic, same test order as
     master. ostest did not finish within the timeout in either build, so this
     shows no difference rather than a full pass.
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   
   Not tested on hardware.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to