diff mbox series

sched_ext: use msecs_to_jiffies consistently

Message ID alpine.DEB.2.22.394.2212112334020.29296@hadrien (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series sched_ext: use msecs_to_jiffies consistently | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Julia Lawall Dec. 11, 2022, 10:43 p.m. UTC
The watchdog's timeout is processed by msecs_to_jiffies when it is
checked, but not when the delay for running the watchdog is set.  The
watchdog will thus run at a time that is later than that time at which it
is checked that it has run, and the scheduler aborts.

Add the needed calls to msecs_to_jiffies.

Signed-off-by: Julia Lawall <julia.lawall@inria.fr>

---

Another solution would be to use jiffies everywhere.

Comments

Tejun Heo Dec. 12, 2022, 2:17 a.m. UTC | #1
On Sun, Dec 11, 2022 at 11:43:30PM +0100, Julia Lawall wrote:
> The watchdog's timeout is processed by msecs_to_jiffies when it is
> checked, but not when the delay for running the watchdog is set.  The
> watchdog will thus run at a time that is later than that time at which it
> is checked that it has run, and the scheduler aborts.
> 
> Add the needed calls to msecs_to_jiffies.
> 
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
> 
> ---
> 
> Another solution would be to use jiffies everywhere.

Yeah, that was how David Vernet implemented it in the first place and I
insisted on using non-jiffies unit, which clearly seems like a mistake. I
think the right thing to do here is using jiffies for everything.

Thanks.
diff mbox series

Patch

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index a28144220501..9d711a70d996 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1626,6 +1626,7 @@  static bool check_rq_for_timeouts(struct rq *rq)
 static void scx_check_timeout_workfn(struct work_struct *work)
 {
 	int cpu;
+	unsigned long timeout;

 	last_timeout_check = jiffies;
 	for_each_online_cpu(cpu) {
@@ -1634,8 +1635,8 @@  static void scx_check_timeout_workfn(struct work_struct *work)

 		cond_resched();
 	}
-	queue_delayed_work(system_unbound_wq, to_delayed_work(work),
-			   task_runnable_timeout_ms / 2);
+	timeout = msecs_to_jiffies(task_runnable_timeout_ms);
+	queue_delayed_work(system_unbound_wq, to_delayed_work(work), timeout / 2);
 }

 static void task_tick_scx(struct rq *rq, struct task_struct *curr, int queued)
@@ -2590,6 +2591,7 @@  static int scx_ops_enable(struct sched_ext_ops *ops)
 {
 	struct scx_task_iter sti;
 	struct task_struct *p;
+	unsigned long timeout;
 	int i, ret;

 	mutex_lock(&scx_ops_enable_mutex);
@@ -2674,8 +2676,8 @@  static int scx_ops_enable(struct sched_ext_ops *ops)
 	}

 	last_timeout_check = jiffies;
-	queue_delayed_work(system_unbound_wq, &check_timeout_work,
-			   task_runnable_timeout_ms / 2);
+	timeout = msecs_to_jiffies(task_runnable_timeout_ms);
+	queue_delayed_work(system_unbound_wq, &check_timeout_work, timeout / 2);

 	/*
 	 * Lock out forks, cgroup on/offlining and moves before opening the