Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semaphore: change semaphore count to atomic operation #15075

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

zyfeier
Copy link
Contributor

@zyfeier zyfeier commented Dec 6, 2024

Summary

Add sem_wait fast operations, use atomic to ensure atomicity of semcount operations, and do not depend on critical section.

Test with robot board:
before modify:
nxmutex_lock cost: 78 ns
nxmutex_unlock cost: 82 ns

after modify:
nxmutex_lock cost: 28 ns
nxmutex_unlock cost: 14 ns

Impact

semaphore

Testing

bes board with monkey test pass
sabre-6quad:smp with ostest pass
sim:citest pass

@github-actions github-actions bot added Area: OS Components OS Components issues Size: M The size of the change in this PR is medium labels Dec 6, 2024
@nuttxpr
Copy link

nuttxpr commented Dec 6, 2024

[Experimental Bot, please feedback here]

No. The PR description lacks several key details required by the NuttX guidelines.

Here's a breakdown:

  • Insufficient Summary: While the summary mentions what changed, it lacks crucial why information. Why was this change necessary? What problem does it solve? What are the benefits of using atomic operations and avoiding the critical section?
  • Missing Impact Details: Simply stating "semaphore" is insufficient. The impact section needs specific YES/NO answers for all listed questions. For any "YES" answers, a detailed explanation is required. For example, even if the user impact is NO, explicitly state "Impact on user: NO." Consider these points for your impact assessment:
    • Performance: The summary mentions performance improvements. This should be explicitly stated in the Impact section, quantifying the improvement.
    • Behavior Change: Does this change the behavior of semaphores in any way beyond performance? Even subtle changes can affect existing applications.
    • Portability: Does this change affect portability to other architectures? Does it rely on specific atomic operations that might not be available everywhere?
  • Incomplete Testing Information: While testing environments are mentioned, it lacks details required by the template. The provided information is too vague.
    • Build Host: Specify OS version, compiler version (e.g., GCC 12.2), etc.
    • Target: Be specific. Instead of "sim," specify the simulator being used (e.g., qemu-system-arm). For boards, specify the configuration used (e.g., sabre-6quad:smp).
  • Missing "Before" and "After" Logs: The provided timing information is helpful, but insufficient. The template specifically requests logs, not just summarized timings. Show relevant log excerpts demonstrating the semaphore behavior before and after the change. Include more than just the timings - show the context of the semaphore usage in the test.
  • Missing Issue References: Are there any related NuttX or NuttX Apps issues that prompted this change? If so, include links.

In short: The PR needs to be significantly expanded to address these missing details before it can be considered complete according to the NuttX requirements. Focus on providing specific, detailed answers to all questions in the template.

@zyfeier zyfeier force-pushed the sem_atomic_3 branch 2 times, most recently from 22e0542 to 4b89636 Compare December 9, 2024 14:21
@xiaoxiang781216 xiaoxiang781216 marked this pull request as ready for review December 9, 2024 17:29
define nx_atomic_compare_exchange_weak and nx_atomic_compare_exchange_strong function

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Add sem_wait fast operations, use atomic to ensure
atomicity of semcount operations, and do not depend
on critical section.

Test with robot:
before modify:
nxmutex_lock cost: 78 ns
nxmutex_unlock cost: 82 ns

after modify:
nxmutex_lock cost: 28 ns
nxmutex_unlock cost: 14 ns

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
mqueue sysv not used, remove to reduce sram usage

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
After SEM_VALUE_MAX change to INT_MAX, need to support
skip result.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit fb4a246 into apache:master Dec 10, 2024
27 checks passed
tmedicci added a commit to tmedicci/nuttx that referenced this pull request Dec 11, 2024
After apache#15075, the static
assertion at `nuttx/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c`
was being triggered when building any of the ESP32-S3's defconfigs.
This commit updates the reserved size to reflect the changes
introduced by the related PR.
xiaoxiang781216 pushed a commit that referenced this pull request Dec 11, 2024
After #15075, the static
assertion at `nuttx/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c`
was being triggered when building any of the ESP32-S3's defconfigs.
This commit updates the reserved size to reflect the changes
introduced by the related PR.
jerpelea pushed a commit to jerpelea/nuttx that referenced this pull request Dec 12, 2024
After apache#15075, the static
assertion at `nuttx/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c`
was being triggered when building any of the ESP32-S3's defconfigs.
This commit updates the reserved size to reflect the changes
introduced by the related PR.
xiaoxiang781216 pushed a commit that referenced this pull request Dec 12, 2024
After #15075, the static
assertion at `nuttx/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c`
was being triggered when building any of the ESP32-S3's defconfigs.
This commit updates the reserved size to reflect the changes
introduced by the related PR.
tmedicci added a commit to tmedicci/nuttx that referenced this pull request Dec 12, 2024
After apache#15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
tmedicci added a commit to tmedicci/nuttx that referenced this pull request Dec 12, 2024
After apache#15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 4096 to avoid stack overflow.
xiaoxiang781216 pushed a commit that referenced this pull request Dec 12, 2024
After #15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
jerpelea pushed a commit to jerpelea/nuttx that referenced this pull request Dec 13, 2024
After apache#15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
xiaoxiang781216 pushed a commit that referenced this pull request Dec 13, 2024
After #15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
linguini1 pushed a commit to CarletonURocketry/nuttx that referenced this pull request Jan 15, 2025
After apache#15075, the static
assertion at `nuttx/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c`
was being triggered when building any of the ESP32-S3's defconfigs.
This commit updates the reserved size to reflect the changes
introduced by the related PR.
linguini1 pushed a commit to CarletonURocketry/nuttx that referenced this pull request Jan 15, 2025
After apache#15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CI Area: OS Components OS Components issues Area: Tooling Board: arm Size: M The size of the change in this PR is medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants