From: Yao Zi <ziyao@disroot.org>
To: Jerome Forissier <jerome.forissier@linaro.org>, u-boot@lists.denx.de
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Sughosh Ganu <sughosh.ganu@linaro.org>,
Raymond Mao <raymond.mao@linaro.org>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Michal Simek <michal.simek@amd.com>
Subject: Re: [RFC PATCH 06/10] uthread: add cooperative multi-tasking interface
Date: Fri, 14 Feb 2025 18:25:59 +0000 [thread overview]
Message-ID: <Z6-KtxZxp2JfsSMP@pie.lan> (raw)
In-Reply-To: <20250214140031.484344-7-jerome.forissier@linaro.org>
On Fri, Feb 14, 2025 at 03:00:21PM +0100, Jerome Forissier wrote:
> Add an new internal API called uthread (Kconfig symbol: UTHREAD) which
> provides cooperative multi-tasking. The goal is to be able to improve
> the performance of some parts of U-Boot by overlapping lengthy
> operations. Each uthread has its own stack allocated on the heap. The
> default stack size is defined by the UTHREAD_STACK_SIZE symbol and is
> used when uthread_create() is passed zero for the stack_sz argument.
>
> The implementation is based on context-switching via initjmp()/setjmp()/
> longjmp() and is inspired from barebox threads [1].
>
> [1] https://github.com/barebox/barebox/blob/master/common/bthread.c
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
> include/uthread.h | 31 ++++++++++++++
> lib/Kconfig | 19 ++++++++
> lib/Makefile | 2 +
> lib/uthread.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 159 insertions(+)
> create mode 100644 include/uthread.h
> create mode 100644 lib/uthread.c
>
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 1a683dea670..c3416bbd0be 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -1255,6 +1255,25 @@ config PHANDLE_CHECK_SEQ
> enable this config option to distinguish them using
> phandles in fdtdec_get_alias_seq() function.
>
> +config UTHREAD
> + bool "Enable thread support"
> + depends on HAVE_INITJMP
> + help
> + Implement a simple form of cooperative multi-tasking based on
> + context-switching via initjmp(), setjmp() and longjmp(). The
> + uthread_ interface enables the main thread of execution to create
> + one or more secondary threads and schedule them until they all have
> + returned. At any point a thread may suspend its execution and
> + schedule another thread, which allows for the efficient multiplexing
> + of leghthy operations.
> +
> +config UTHREAD_STACK_SIZE
> + int "Default uthread stack size"
> + depends on UTHREAD
> + default 32168
Why choose 32168? It's even not a power of two. Typo for 32768?
> + help
> + The default stask size for uthreads. Each uthread has its own stack.
> +
> endmenu
>
> source "lib/fwu_updates/Kconfig"
Thanks,
Yao Zi
next prev parent reply other threads:[~2025-02-14 18:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 14:00 [RFC PATCH 00/10] Uthreads Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 01/10] arch: introduce symbol HAVE_INITJMP Jerome Forissier
2025-02-14 14:41 ` Heinrich Schuchardt
2025-02-14 15:03 ` Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 02/10] arm: add initjmp() Jerome Forissier
2025-02-14 14:35 ` Heinrich Schuchardt
2025-02-17 13:10 ` Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 03/10] riscv: " Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 04/10] sandbox: " Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 05/10] test: lib: add initjmp() test Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 06/10] uthread: add cooperative multi-tasking interface Jerome Forissier
2025-02-14 14:47 ` Heinrich Schuchardt
2025-02-14 18:25 ` Yao Zi [this message]
2025-02-17 9:48 ` Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 07/10] lib: time: hook uthread_schedule() into udelay() Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 08/10] dm: usb: move bus initialization into new static function usb_init_bus() Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 09/10] dm: usb: initialize and scan multiple buses simultaneously with uthread Jerome Forissier
2025-02-14 14:00 ` [RFC PATCH 10/10] test: lib: add uthread test Jerome Forissier
2025-02-14 18:41 ` Yao Zi
2025-02-17 9:49 ` Jerome Forissier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6-KtxZxp2JfsSMP@pie.lan \
--to=ziyao@disroot.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@linaro.org \
--cc=michal.simek@amd.com \
--cc=patrick.rudolph@9elements.com \
--cc=raymond.mao@linaro.org \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox