[PATCH 2/2] cyclic: parse cyclic list only if next cyclic timestamp is reached

Patrice CHOTARD patrice.chotard at foss.st.com
Tue Jul 7 08:03:52 CEST 2026



On 7/6/26 18:00, Marek Vasut wrote:
> On 7/6/26 5:16 PM, Patrice CHOTARD wrote:
> 
> Hello Patrice,
> 
>>>> I did a test, it doesn't bring any noticeable improvements, but nevertheless i will submit a v3 with this update.
>>>
>>> Does the list iteration exit when it finds the first entry that is not going to be executed at this time ? If it does not, then there will be no improvement. But for this to work, the list would have to be surely fully ordered in incrementing timestamp order, is it ?
>>
>> No, the list iteration parse all entries.
>>
>> I see your point, on original implementation, entries are not sort by incrementing timestamp order.
>> I did some implementation test, by sorting cyclic entries in cyclic_list when :
>>    _ registering a new cyclic callback, put it directly in the right position in cyclic_list.
>>    _ in cyclic_run(), after running a cyclic, compute its next call and insrt it in the right position in cyclic_list.
>>
>> There is no noticeable gain.
> 
> Did you also break from the iteration when you reached the first entry with future timestamp ? That might actually help.
> 

In cyclic_run(), as now entries was sorted by increasing timestamp, only the first cyclic in cyclic_list is parsed, 
we don't need to parse all cyclic_list element.

Nevertheless, in v2, Rasmus identified that get_timer_us() is the expensive part of the cyclic_run() execution. 
And he also noticed that my patch didn't cover every corner cases.

He suggested me a more simple patch i tested and the result are identical to mine, 
see v3 : https://patchwork.ozlabs.org/project/uboot/list/?series=512333
 

Patrice


More information about the U-Boot mailing list