BPF List
 help / color / mirror / Atom feed
* [PATCH] sched_ext: use msecs_to_jiffies consistently
@ 2022-12-11 22:43 Julia Lawall
  2022-12-12  2:17 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2022-12-11 22:43 UTC (permalink / raw)
  To: Tejun Heo
  Cc: torvalds, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	ast, daniel, andrii, martin.lau, joshdon, brho, pjt, derkling,
	haoluo, dvernet, dschatzberg, dskarlat, riel, linux-kernel, bpf,
	kernel-team

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.

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched_ext: use msecs_to_jiffies consistently
  2022-12-11 22:43 [PATCH] sched_ext: use msecs_to_jiffies consistently Julia Lawall
@ 2022-12-12  2:17 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2022-12-12  2:17 UTC (permalink / raw)
  To: Julia Lawall
  Cc: torvalds, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
	ast, daniel, andrii, martin.lau, joshdon, brho, pjt, derkling,
	haoluo, dvernet, dschatzberg, dskarlat, riel, linux-kernel, bpf,
	kernel-team

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.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-12  2:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-11 22:43 [PATCH] sched_ext: use msecs_to_jiffies consistently Julia Lawall
2022-12-12  2:17 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox