mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
Merge patch series "Uthreads"
Jerome Forissier <jerome.forissier@linaro.org> says: This series introduces threads and uses them to improve the performance of the USB bus scanning code and to implement background jobs in the shell via two new commands: 'spawn' and 'wait'. The threading framework is called 'uthread' and is inspired from the barebox threads [2]. setjmp() and longjmp() are used to save and restore contexts, as well as a non-standard extension called initjmp(). This new function is added in several patches, one for each architecture that supports HAVE_SETJMP. A new symbol is defined: HAVE_INITJMP. Two tests, one for initjmp() and one for the uthread scheduling, are added to the lib suite. After introducing threads and making schedule() and udelay() a thread re-scheduling point, the USB stack initialization is modified to benefit from concurrency when UTHREAD is enabled, where uthreads are used in usb_init() to initialize and scan multiple busses at the same time. The code was tested on arm64 and arm QEMU with 4 simulated XHCI buses and some devices. On this platform the USB scan takes 2.2 s instead of 5.6 s. Tested on i.MX93 EVK with two USB hubs, one ethernet adapter and one webcam on each, "usb start" takes 2.4 s instead of 4.6 s. Finally, the spawn and wait commands are introduced, allowing the use of threads from the shell. Tested on the i.MX93 EVK with a spinning HDD connected to USB1 and the network connected to ENET1. The USB plus DHCP init sequence "spawn usb start; spawn dhcp; wait" takes 4.5 seconds instead of 8 seconds for "usb start; dhcp". [1] https://patchwork.ozlabs.org/project/uboot/list/?series=446674 [2] https://github.com/barebox/barebox/blob/master/common/bthread.c Link: https://lore.kernel.org/r/20250418141114.2056981-1-jerome.forissier@linaro.org
This commit is contained in:
@@ -39,3 +39,4 @@ obj-$(CONFIG_CMD_WGET) += wget.o
|
||||
endif
|
||||
obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o
|
||||
endif
|
||||
obj-$(CONFIG_CMD_SPAWN) += spawn.o
|
||||
|
||||
32
test/cmd/spawn.c
Normal file
32
test/cmd/spawn.c
Normal file
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Tests for spawn and wait commands
|
||||
*
|
||||
* Copyright 2025, Linaro Ltd.
|
||||
*/
|
||||
|
||||
#include <command.h>
|
||||
#include <test/cmd.h>
|
||||
#include <test/test.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
static int test_cmd_spawn(struct unit_test_state *uts)
|
||||
{
|
||||
ut_assertok(run_command("wait; spawn sleep 2; setenv j ${job_id}; "
|
||||
"spawn setenv spawned true; "
|
||||
"setenv jj ${job_id}; wait; "
|
||||
"echo ${j} ${jj} ${spawned}", 0));
|
||||
console_record_readline(uts->actual_str, sizeof(uts->actual_str));
|
||||
ut_asserteq_ptr(uts->actual_str,
|
||||
strstr(uts->actual_str, "1 2 true"));
|
||||
|
||||
ut_assertok(run_command("spawn true; wait; setenv t $?; spawn false; "
|
||||
"wait; setenv f $?; wait; echo $t $f $?", 0));
|
||||
console_record_readline(uts->actual_str, sizeof(uts->actual_str));
|
||||
ut_asserteq_ptr(uts->actual_str,
|
||||
strstr(uts->actual_str, "0 1 0"));
|
||||
ut_assert_console_end();
|
||||
|
||||
return 0;
|
||||
}
|
||||
CMD_TEST(test_cmd_spawn, UTF_CONSOLE);
|
||||
Reference in New Issue
Block a user