From: zhangsong <zhangsong34@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>
Cc: <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>,
<linux-kernel@vger.kernel.org>, zhangsong <zhangsong34@gmail.com>
Subject: [PATCH] sched/fair: Allow non-idle task to preempt idle task directly
Date: Fri, 1 Apr 2022 17:11:27 +0800 [thread overview]
Message-ID: <20220401091127.3234638-1-zhangsong34@huawei.com> (raw)
From: zhangsong <zhangsong34@gmail.com>
In check_preempt_tick(), the sched idle task may exectue at least
`sysctl_sched_min_granularity` time but any other cfs tasks cannot
preempt it. So it is nessesary to ignore the `sysctl_sched_min_granularity`
resctriction for sched idle task preemption.
Signed-off-by: zhangsong <zhangsong34@gmail.com>
---
kernel/sched/fair.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d4bd299d6..edcb33440 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4477,6 +4477,15 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
struct sched_entity *se;
s64 delta;
+ se = __pick_first_entity(cfs_rq);
+
+ if ((cfs_rq->last && se_is_idle(cfs_rq->last) - se_is_idle(curr) < 0) ||
+ (cfs_rq->next && se_is_idle(cfs_rq->last) - se_is_idle(curr) < 0) ||
+ se_is_idle(se) - se_is_idle(curr) < 0) {
+ resched_curr(rq_of(cfs_rq));
+ return;
+ }
+
ideal_runtime = sched_slice(cfs_rq, curr);
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
if (delta_exec > ideal_runtime) {
@@ -4497,7 +4506,6 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
if (delta_exec < sysctl_sched_min_granularity)
return;
- se = __pick_first_entity(cfs_rq);
delta = curr->vruntime - se->vruntime;
if (delta < 0)
--
2.27.0
next reply other threads:[~2022-04-01 9:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 9:11 zhangsong [this message]
2022-04-01 13:09 ` Vincent Guittot
2022-04-02 3:32 ` zhangsong (J)
2022-04-04 10:16 ` Vincent Guittot
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=20220401091127.3234638-1-zhangsong34@huawei.com \
--to=zhangsong34@huawei.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=zhangsong34@gmail.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
all inboxes | Powered by JetHome®