mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/11] common: introduce bthreads, co-operative
@ 2021-03-01 11:00 Ahmad Fatoum
  2021-03-01 11:00 ` [PATCH v2 01/11] console: unconditionally run poller_call in ctrlc() Ahmad Fatoum
                   ` (11 more replies)
  0 siblings, 12 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2021-03-01 11:00 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas, Stafford Horne, sha

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2021-03-14 12:43 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 11:00 [PATCH v2 00/11] common: introduce bthreads, co-operative Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 01/11] console: unconditionally run poller_call in ctrlc() Ahmad Fatoum
2021-03-03 10:20   ` [PATCH] fixup! common: introduce bthreads, co-operative barebox threads Ahmad Fatoum
2021-03-04  8:49     ` Sascha Hauer
2021-03-04  9:17       ` Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 02/11] " Ahmad Fatoum
2021-03-01 12:42   ` Peter Korsgaard
2021-03-02  8:56     ` Ahmad Fatoum
2021-03-02  8:56   ` [PATCH] fixup! " Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 03/11] ARM: asm: setjmp: annotate setjmp/longjmp for GCC Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 04/11] ARM: asm: setjmp: implement coroutine dependency initjmp() Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 05/11] sandbox: asm: implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 06/11] riscv: Add asm/asm.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 07/11] riscv: Add asm/linkage.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 08/11] riscv: Implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 09/11] mips: Add linkage.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 10/11] mips: Implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-02 22:19   ` Peter Mamonov
2021-03-04  8:38     ` Sascha Hauer
2021-03-07 12:00       ` Peter Mamonov
2021-03-10  8:17         ` Ahmad Fatoum
2021-03-14 12:40           ` Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 11/11] powerpc: Implement initjmp/setjmp/longjmp Ahmad Fatoum
2021-03-03 12:15 ` [PATCH v2 00/11] common: introduce bthreads, co-operative Stafford Horne
2021-03-03 13:35   ` Stafford Horne
2021-03-03 13:58   ` Ahmad Fatoum
2021-03-03 15:12   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox