[PATCH v2 00/11] common: introduce bthreads, co-operative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

This is v2 of barebox coroutine support:
    https://lists.infradead.org/pipermail/barebox/2021-February/035032.html

As discussed with Sascha, if this is to be added, this should be added for
all architectures and not be optional. If we have this as integral part,
it means we can substitute coroutines for:
    - pollers: just wrap the code in a loop
    - async pollers: just call a delay function in the loop
    - workqueues: assert_command_context yields until in command context

In addition, we will have much less work porting over threaded code from
Linux. See the referenced series for an example of a USB mass storage
gadget.

To prepare for replacing them, the functionality is renamed to
bthreads (as in barebox threads) and is made separate from pollers.

How to add new architecture support:

  - Apply this series or check out https://github.com/a3f/barebox/tree/bthread
  - Add implementations for setjmp, longjmp
    - Most easily extracted out of a libc, because they are C standard functions
    - Floating context backup can be omitted
  - Add implementation of initjmp
    - copy out the parts of setjmp that set return address and stack pointer
    - Check the architecture implemented in this series for examples
  - Add type definition and prototypes to <asm/setjmp.h>
  - select HAS_ARCH_SJLJ from arch config symbol
  - Test by running bthread -v


Current state of CONFIG_HAS_ARCH_SJLJ

    [x] arm 32-bit (Ahmad)
    [x] arm 64-bit (Sascha)
    [x] mips (Sascha)
    [x] powerpc (Sascha)
    [x] riscv (Sascha)
    [x] sandbox (Ahmad)
    [-] nios2 (Removed; Sascha)
    [?] x86 32-bit (Ahmad)
    [?] x86 64-bit (Ahmad)
    [?] openrisc (Stafford?)
    [?] kvx (Jules?)

Legend: [-] arch removed, [x] implemented, [?] TODO

@Sascha, could this already be merged? I won't add a new users till it
can be selected for all architectures.

Cheers,
Ahmad Fatoum (5):
  console: unconditionally run poller_call in ctrlc()
  common: introduce bthreads, co-operative barebox threads
  ARM: asm: setjmp: annotate setjmp/longjmp for GCC
  ARM: asm: setjmp: implement coroutine dependency initjmp()
  sandbox: asm: implement setjmp/longjmp/initjmp

Sascha Hauer (6):
  riscv: Add asm/asm.h
  riscv: Add asm/linkage.h
  riscv: Implement setjmp/longjmp/initjmp
  mips: Add linkage.h
  mips: Implement setjmp/longjmp/initjmp
  powerpc: Implement initjmp/setjmp/longjmp

 Documentation/devel/background-execution.rst |  43 +++-
 arch/arm/Kconfig                             |   1 +
 arch/arm/include/asm/setjmp.h                |   6 +-
 arch/arm/lib32/setjmp.S                      |   8 +
 arch/arm/lib64/setjmp.S                      |   9 +
 arch/mips/Kconfig                            |   1 +
 arch/mips/include/asm/linkage.h              |   9 +
 arch/mips/include/asm/setjmp.h               |  32 +++
 arch/mips/lib/Makefile                       |   1 +
 arch/mips/lib/setjmp.S                       |  50 +++++
 arch/powerpc/Kconfig                         |   1 +
 arch/powerpc/include/asm/setjmp.h            |  21 ++
 arch/powerpc/lib/Makefile                    |   2 +-
 arch/powerpc/lib/setjmp.S                    |  86 ++++++++
 arch/riscv/Kconfig                           |   1 +
 arch/riscv/include/asm/asm.h                 |  69 ++++++
 arch/riscv/include/asm/linkage.h             |  12 ++
 arch/riscv/include/asm/setjmp.h              |  27 +++
 arch/riscv/lib/Makefile                      |   2 +-
 arch/riscv/lib/longjmp.S                     |  28 +++
 arch/riscv/lib/setjmp.S                      |  35 +++
 arch/sandbox/Kconfig                         |   1 +
 arch/sandbox/Makefile                        |   5 +-
 arch/sandbox/include/asm/setjmp.h            |  17 ++
 arch/sandbox/os/Makefile                     |   5 +-
 arch/sandbox/os/setjmp.c                     | 180 ++++++++++++++++
 commands/Kconfig                             |   9 +
 commands/Makefile                            |   1 +
 common/Kconfig                               |  13 ++
 common/Makefile                              |   1 +
 common/bthread.c                             | 214 +++++++++++++++++++
 common/clock.c                               |   5 +-
 common/console.c                             |   6 +-
 include/bthread.h                            |  31 +++
 include/slice.h                              |  16 +-
 lib/readline.c                               |   5 +-
 36 files changed, 929 insertions(+), 24 deletions(-)
 create mode 100644 arch/mips/include/asm/linkage.h
 create mode 100644 arch/mips/include/asm/setjmp.h
 create mode 100644 arch/mips/lib/setjmp.S
 create mode 100644 arch/powerpc/include/asm/setjmp.h
 create mode 100644 arch/powerpc/lib/setjmp.S
 create mode 100644 arch/riscv/include/asm/asm.h
 create mode 100644 arch/riscv/include/asm/linkage.h
 create mode 100644 arch/riscv/include/asm/setjmp.h
 create mode 100644 arch/riscv/lib/longjmp.S
 create mode 100644 arch/riscv/lib/setjmp.S
 create mode 100644 arch/sandbox/include/asm/setjmp.h
 create mode 100644 arch/sandbox/os/setjmp.c
 create mode 100644 common/bthread.c
 create mode 100644 include/bthread.h

-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux