-void task_tick_mm_cid(struct rq *rq, struct task_struct *curr)In v13 we had:
+void task_queue_mm_cid(struct task_struct *curr)
{
- struct callback_head *work = &curr->cid_work;
- unsigned long now = jiffies;
+ int requeued;
- if (!curr->mm || (curr->flags & (PF_EXITING | PF_KTHREAD)) ||
- work->next != work)
- return;
- if (time_before(now, READ_ONCE(curr->mm->mm_cid_next_scan)))
- return;
-
- /* No page allocation under rq lock */
- task_work_add(curr, work, TWA_RESUME);
+ /*
+ * @curr must be a user thread and the timer must not be pending.
+ * Access to this timer is not serialised across threads sharing the
+ * same mm: ensure racing threads don't postpone enqueued timers and
+ * don't mmgrab() if they didn't enqueue the timer themselves.
+ * mmgrab() is necessary to ensure the mm exists until the timer runs.
+ */
+ requeued = timer_reduce(&curr->mm->cid_timer,
+ jiffies + msecs_to_jiffies(MM_CID_SCAN_DELAY));
+ if (!requeued && timer_pending(&curr->mm->cid_timer))
+ mmgrab(curr->mm);
}