From: Alexander Graf <graf@amazon.com>
To: <linux-kernel@vger.kernel.org>
Cc: Vineeth Remanan Pillai <vpillai@digitalocean.com>,
Nishanth Aravamudan <naravamudan@digitalocean.com>,
Julien Desfossez <jdesfossez@digitalocean.com>,
Peter Zijlstra <peterz@infradead.org>,
"Tim Chen" <tim.c.chen@linux.intel.com>, <mingo@kernel.org>,
<tglx@linutronix.de>, <pjt@google.com>,
<torvalds@linux-foundation.org>, <subhra.mazumdar@oracle.com>,
<fweisbec@gmail.com>, <keescook@chromium.org>,
<kerrnel@google.com>, Phil Auld <pauld@redhat.com>,
Aaron Lu <aaron.lwe@gmail.com>,
Aubrey Li <aubrey.intel@gmail.com>,
Valentin Schneider <valentin.schneider@arm.com>,
Mel Gorman <mgorman@techsingularity.net>,
"Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Joel Fernandes <joelaf@google.com>, <joel@joelfernandes.org>,
<vineethrp@gmail.com>, Chen Yu <yu.c.chen@intel.com>,
Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH 1/3] sched: Allow hrticks to work with core scheduling
Date: Thu, 27 Aug 2020 02:42:48 +0200 [thread overview]
Message-ID: <20200827004250.4853-2-graf@amazon.com> (raw)
In-Reply-To: <20200827004250.4853-1-graf@amazon.com>
The core scheduling logic bypasses the scheduling class's
pick_next_task() which starts the hrtick logic usually. Instead,
it explicitly calls set_next_task() or leaves the current task
running without any callback into the CFS scheduler.
To ensure that we still configure the hrtick timer properly when we
know which task we want to run, let's add an explicit callback to
the scheduler class which can then be triggered from the core's
pick_next_task().
With this patch, core scheduling with HRTICK enabled does see
improved responsiveness on scheduling decisions.
Signed-off-by: Alexander Graf <graf@amazon.com>
---
kernel/sched/core.c | 13 +++++++++++++
kernel/sched/fair.c | 9 +++++++++
kernel/sched/sched.h | 4 ++++
3 files changed, 26 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0362102fa3d2..72bf837422bf 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4486,6 +4486,12 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
set_next_task(rq, next);
}
+#ifdef CONFIG_SCHED_HRTICK
+ /* Trigger next hrtick after task selection */
+ if (next->sched_class->hrtick_update)
+ next->sched_class->hrtick_update(rq);
+#endif
+
trace_printk("pick pre selected (%u %u %u): %s/%d %lx\n",
rq->core->core_task_seq,
rq->core->core_pick_seq,
@@ -4667,6 +4673,13 @@ next_class:;
done:
set_next_task(rq, next);
+
+#ifdef CONFIG_SCHED_HRTICK
+ /* Trigger next hrtick after task selection */
+ if (next->sched_class->hrtick_update)
+ next->sched_class->hrtick_update(rq);
+#endif
+
return next;
}
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 435b460d3c3f..0d4ff3ab2572 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5512,6 +5512,11 @@ static inline void hrtick_update(struct rq *rq)
}
#endif
+static void hrtick_update_fair(struct rq *rq)
+{
+ hrtick_update(rq);
+}
+
#ifdef CONFIG_SMP
static inline unsigned long cpu_util(int cpu);
@@ -11391,6 +11396,10 @@ const struct sched_class fair_sched_class = {
#ifdef CONFIG_UCLAMP_TASK
.uclamp_enabled = 1,
#endif
+
+#ifdef CONFIG_SCHED_HRTICK
+ .hrtick_update = hrtick_update_fair,
+#endif
};
#ifdef CONFIG_SCHED_DEBUG
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6445943d3215..b382e0ee0c87 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1942,6 +1942,10 @@ struct sched_class {
#ifdef CONFIG_FAIR_GROUP_SCHED
void (*task_change_group)(struct task_struct *p, int type);
#endif
+
+#ifdef CONFIG_SCHED_HRTICK
+ void (*hrtick_update)(struct rq *rq);
+#endif
};
static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
--
2.26.2
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
next prev parent reply other threads:[~2020-08-27 0:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 0:42 [PATCH 0/3] Add HRTICK support to Core Scheduling Alexander Graf
2020-08-27 0:42 ` Alexander Graf [this message]
2020-08-27 0:42 ` [PATCH 2/3] sched: Trigger new hrtick if timer expires too fast Alexander Graf
2020-08-27 0:42 ` [PATCH 3/3] sched: Use hrticks even with >sched_nr_latency tasks Alexander Graf
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=20200827004250.4853-2-graf@amazon.com \
--to=graf@amazon.com \
--cc=aaron.lwe@gmail.com \
--cc=aubrey.intel@gmail.com \
--cc=christian.brauner@ubuntu.com \
--cc=fweisbec@gmail.com \
--cc=jdesfossez@digitalocean.com \
--cc=joel@joelfernandes.org \
--cc=joelaf@google.com \
--cc=keescook@chromium.org \
--cc=kerrnel@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mingo@kernel.org \
--cc=naravamudan@digitalocean.com \
--cc=pauld@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=subhra.mazumdar@oracle.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=valentin.schneider@arm.com \
--cc=vineethrp@gmail.com \
--cc=vpillai@digitalocean.com \
--cc=yu.c.chen@intel.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