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

wqueue remove enter_critical_section #14623

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Conversation

hujun260
Copy link
Contributor

@hujun260 hujun260 commented Nov 4, 2024

Summary

we use small lock to replace enter_critical_section to avoid busywait

reason:
We decouple semcount from business logic
by using an independent counting variable,
which allows us to remove critical sections in many cases.

Impact

work queue

Testing

Build Host:

OS: Ubuntu 20.04
CPU: x86_64
Compiler: GCC 9.4.0
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic
-machine virt,virtualization=on,gic-version=3
-net none -chardev stdio,id=con,mux=on -serial chardev:con
-mon chardev=con,mode=readline -kernel ./nuttx

@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Arch: ceva Issues related to CEVA architecture Arch: hc Issues related to HC architecture Arch: mips Issues related to the MIPS architecture Arch: openrisc Issues related to the OpenRISC architecture Arch: renesas Issues related to the Renesas chips Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Arch: sparc Issues related to the SPARC architecture Arch: tricore Issues related to the TriCore architecture from Infineon Arch: x86 Issues related to the x86 architecture Arch: x86_64 Issues related to the x86_64 architecture Arch: xtensa Issues related to the Xtensa architecture Arch: z16 Issues related to the Z16 architecture Arch: z80 Issues related to the Z80 architecture Area: File System File System issues Area: OS Components OS Components issues Size: L The size of the change in this PR is large labels Nov 4, 2024
@hujun260 hujun260 changed the title Apache 8 wqueue remove enter_critical_section Nov 4, 2024
@github-actions github-actions bot removed Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Arch: ceva Issues related to CEVA architecture Arch: hc Issues related to HC architecture Arch: mips Issues related to the MIPS architecture Arch: openrisc Issues related to the OpenRISC architecture Arch: renesas Issues related to the Renesas chips labels Nov 4, 2024
@hujun260 hujun260 marked this pull request as draft November 4, 2024 09:27
@acassis
Copy link
Contributor

acassis commented Nov 5, 2024

Note that some places said work_cancel() only returns success, these comments need to be fixed. i.e.:

      ret = work_cancel(LPWORK, &priv->cbwork);
      if (ret < 0)
        {
          /* NOTE: Currently, work_cancel only returns success */
  
          lcderr("ERROR: Failed to cancel work: %d\n", ret);
        }

@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Area: File System File System issues labels Nov 6, 2024
@hujun260
Copy link
Contributor Author

hujun260 commented Nov 6, 2024

This PR requires #14578 to be merged first.

@hujun260 hujun260 marked this pull request as ready for review November 6, 2024 13:31
sched/wqueue/wqueue.h Outdated Show resolved Hide resolved
sched/wqueue/wqueue.h Outdated Show resolved Hide resolved
sched/wqueue/kwork_notifier.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_notifier.c Show resolved Hide resolved
sched/wqueue/kwork_queue.c Show resolved Hide resolved
@xiaoxiang781216
Copy link
Contributor

@hujun260 many comments aren't addressed in the new reversion yet.

@hujun260 hujun260 force-pushed the apache_8 branch 3 times, most recently from 45c5016 to cc2f64b Compare January 12, 2025 05:50
sched/wqueue/kwork_thread.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_thread.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_thread.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_queue.c Outdated Show resolved Hide resolved
sched/wqueue/wqueue.h Outdated Show resolved Hide resolved
sched/wqueue/kwork_notifier.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_notifier.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_queue.c Outdated Show resolved Hide resolved
sched/wqueue/kwork_queue.c Show resolved Hide resolved
@hujun260 hujun260 force-pushed the apache_8 branch 2 times, most recently from d3376ae to e74c6b7 Compare January 14, 2025 01:09
reason:
We decouple semcount from business logic
by using an independent counting variable,
which allows us to remove critical sections in many cases.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 61f0c97 into apache:master Jan 15, 2025
39 checks passed
hujun260 added a commit to hujun260/nuttx that referenced this pull request Jan 17, 2025
reason:
work_timer_expiry may be called in thread context

Signed-off-by: hujun5 <hujun5@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Jan 17, 2025
reason:
work_timer_expiry may be called in thread context

Signed-off-by: hujun5 <hujun5@xiaomi.com>
SPRESENSE added a commit to SPRESENSE/nuttx that referenced this pull request Jan 17, 2025
* apache/nuttx/master:
  arch/armv7-r: fix gic.h build error
  sim: fix regression from apache#14623
  arch/Kconfig: allow FLASH config for non-MMU chips
  nuttx: add open and close callback functions for the mouse.
  nuttx: Open mouse/touch/keyboard options can be configured
  nuttx: Support for rpmsgdev custom ioctl
  nuttx: Support for the mouse ioctl interface
  sensors/sht4x: Converted SHT4X driver to UORB framework.
  Add GD55 QSPI NOR Flash support
  sensors/msxxxx-crc4: Modify CRC calculation so that it passes with MS5611.
  sched/wqueue: fix potential deadlock
  sched/wdog: remove wd_cancel_irq() implement
  risc-v: replace fence.i with __ISB for instruction sync
  libc/gnssutils: remove C99 standard flag from Make.defs
  libs/lib_tempbuffer: set `errno` when fails
  Add uid file needed for ethernet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: arm Issues related to ARM (32-bit) architecture Area: File System File System issues Area: OS Components OS Components issues 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.

4 participants