[PATCH v2] usb: gadget: f_mass_storage: Move schedule() in sleep_thread()
Marek Vasut
marek.vasut at mailbox.org
Wed Jul 1 09:24:04 CEST 2026
On 7/1/26 8:27 AM, Patrice CHOTARD wrote:
Hello Patrice,
>> What takes 700ms in sleep_thread() , surely not schedule() ?
>
> Hi Marek
>
> On STM32MP157C-dk2, each schedule() execution takes between 2 and 4us depending of the cyclics function to execute.
That is about 1100 instructions on 650 MHz CA7 which is way too much , I
think that is the problem we need to solve first.
Look ta common/cyclic.c schedule() , I think it is the list iteration in
cyclic_run() that takes forever. And I think the fix is simple, let the
list iteration surely run through once on the first run of cyclic_run(),
and while it is running, for each entry, figure out when the entry
should be run NEXT, and note the NEXT run timestamp down. At the end of
cyclic_run(), figure out when the nearest NEXT timestamp is (you can do
that as part of the list iteration of course), and store that
information in some global variable. Finally, add at the beginning of
cyclic_run() a test whether this timestamp was reached. If not, do
nothing, because you already know that nothing has to be executed yet,
and you will avoid the expensive list traversal this way.
That should make the execution time of cyclic_run() negligible for the
majority case.
What do you think ?
More information about the U-Boot
mailing list