BPF List
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Tejun Heo <tj@kernel.org>
Cc: torvalds@linux-foundation.org, mingo@redhat.com,
	peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org,
	joshdon@google.com, brho@google.com, pjt@google.com,
	derkling@google.com, haoluo@google.com, dvernet@meta.com,
	dschatzberg@meta.com, dskarlat@cs.cmu.edu, riel@surriel.com,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	kernel-team@meta.com
Subject: [PATCH] sched_ext: use msecs_to_jiffies consistently
Date: Sun, 11 Dec 2022 23:43:30 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2212112334020.29296@hadrien> (raw)

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

             reply	other threads:[~2022-12-11 22:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11 22:43 Julia Lawall [this message]
2022-12-12  2:17 ` [PATCH] sched_ext: use msecs_to_jiffies consistently Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2212112334020.29296@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brho@google.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=daniel@iogearbox.net \
    --cc=derkling@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=dschatzberg@meta.com \
    --cc=dskarlat@cs.cmu.edu \
    --cc=dvernet@meta.com \
    --cc=haoluo@google.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox