Merge patch series "cyclic: update and optimization"
Patrice Chotard <patrice.chotard@foss.st.com> says: First patch is replacing uint64_t by u64 as suggested by b4 Second patch optimizes cyclic_run() to parse cyclic list only if a cyclic function's timestamp is elapsed. Link: https://lore.kernel.org/r/20260706-optimize_cyclic_run-v3-0-06ecbd74ef7c@foss.st.com
This commit is contained in:
+6
-4
@@ -41,7 +41,7 @@ static bool cyclic_is_registered(const struct cyclic_info *cyclic)
|
||||
}
|
||||
|
||||
void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,
|
||||
uint64_t delay_us, const char *name)
|
||||
u64 delay_us, const char *name)
|
||||
{
|
||||
cyclic_unregister(cyclic);
|
||||
|
||||
@@ -67,26 +67,28 @@ static void cyclic_run(void)
|
||||
{
|
||||
struct cyclic_info *cyclic;
|
||||
struct hlist_node *tmp;
|
||||
uint64_t now, cpu_time;
|
||||
u64 now, after, cpu_time;
|
||||
|
||||
/* Prevent recursion */
|
||||
if (gd->flags & GD_FLG_CYCLIC_RUNNING)
|
||||
return;
|
||||
|
||||
gd->flags |= GD_FLG_CYCLIC_RUNNING;
|
||||
now = get_timer_us(0);
|
||||
hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
|
||||
/*
|
||||
* Check if this cyclic function needs to get called, e.g.
|
||||
* do not call the cyclic func too often
|
||||
*/
|
||||
now = get_timer_us(0);
|
||||
if (time_after_eq64(now, cyclic->next_call)) {
|
||||
/* Call cyclic function and account it's cpu-time */
|
||||
cyclic->next_call = now + cyclic->delay_us;
|
||||
cyclic->func(cyclic);
|
||||
after = get_timer_us(0);
|
||||
cyclic->run_cnt++;
|
||||
cpu_time = get_timer_us(0) - now;
|
||||
cpu_time = after - now;
|
||||
cyclic->cpu_time_us += cpu_time;
|
||||
now = after;
|
||||
|
||||
/* Check if cpu-time exceeds max allowed time */
|
||||
if ((cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) &&
|
||||
|
||||
Reference in New Issue
Block a user