Re: [patch V2 38/38] posix-cpu-timers: Utilize timerqueue for storage

From: Frederic Weisbecker
Date: Mon Aug 26 2019 - 20:48:52 EST


On Wed, Aug 21, 2019 at 09:09:25PM +0200, Thomas Gleixner wrote:
> /**
> @@ -92,14 +130,10 @@ struct posix_cputimers {
>
> static inline void posix_cputimers_init(struct posix_cputimers *pct)
> {
> - pct->timers_active = 0;
> - pct->expiry_active = 0;

No more need to initialize these?

> + memset(pct->bases, 0, sizeof(pct->bases));
> pct->bases[0].nextevt = U64_MAX;
> pct->bases[1].nextevt = U64_MAX;
> pct->bases[2].nextevt = U64_MAX;
> - INIT_LIST_HEAD(&pct->bases[0].cpu_timers);
> - INIT_LIST_HEAD(&pct->bases[1].cpu_timers);
> - INIT_LIST_HEAD(&pct->bases[2].cpu_timers);
> }

[...]

> @@ -393,15 +395,15 @@ static int posix_cpu_timer_del(struct k_
> sighand = lock_task_sighand(p, &flags);
> if (unlikely(sighand == NULL)) {
> /*
> - * We raced with the reaping of the task.
> - * The deletion should have cleared us off the list.
> + * This raced with the reaping of the task. The exit cleanup
> + * should have removed this timer from the timer queue.
> */
> - WARN_ON_ONCE(!list_empty(&timer->it.cpu.entry));
> + WARN_ON_ONCE(ctmr->head || timerqueue_node_queued(&ctmr->node));

Should we clear ctmr->head upon cleanup_timerqueue() ?

Thanks.


> } else {
> if (timer->it.cpu.firing)
> ret = TIMER_RETRY;
> else
> - list_del(&timer->it.cpu.entry);
> + cpu_timer_dequeue(ctmr);
>
> unlock_task_sighand(p, &flags);
> }
> @@ -412,12 +414,12 @@ static int posix_cpu_timer_del(struct k_
> return ret;
> }
>
> -static void cleanup_timers_list(struct list_head *head)
> +static void cleanup_timerqueue(struct timerqueue_head *head)
> {
> - struct cpu_timer_list *timer, *next;
> + struct timerqueue_node *node;
>
> - list_for_each_entry_safe(timer, next, head, entry)
> - list_del_init(&timer->entry);
> + while ((node = timerqueue_getnext(head)))
> + timerqueue_del(head, node);
> }