Skip to contentSkip to conversation

sched: Document capacity aware scheduling

PATCH In review Valentin Schneider 2 participants 6 messages Jul 31, 2020 – Aug 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover sched: Document capacity aware scheduling

Hi,

This stems from John Mathew et al's documentation efforts; see the brief exchange between Dietmar and I at [1].

This is written as a standalone documentation bit, the emphasis here being on the "why" and "what" rather than the "how". I can try to rebase that on top of John's series, but I think this could go in on its own.

[1]: https://lkml.kernel.org/r/[email protected]

Cheers,
Valentin

Valentin Schneider (3):
sched: Document arch_scale_*_capacity() sched/doc: Document capacity aware scheduling sched/doc: Factorize bits between sched-energy.rst &
sched-capacity.rst

 Documentation/scheduler/index.rst          |   1 +
 Documentation/scheduler/sched-capacity.rst | 439 +++++++++++++++++++++
 Documentation/scheduler/sched-energy.rst   |  12 +-
 include/linux/sched/topology.h             |  10 +
 kernel/sched/sched.h                       |  10 +
 5 files changed, 462 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/scheduler/sched-capacity.rst
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/3 sched: Document arch_scale_*_capacity()

Rather that hide their purpose in some dark, damp corner of Documentation/, add some documentation to the default implementations.

---
 include/linux/sched/topology.h | 10 ++++++++++
 kernel/sched/sched.h           | 10 ++++++++++
 2 files changed, 20 insertions(+)
include/linux/sched/topology.h +10 -0
index 764222d637b7..820511289857 100644
@@ -217,6 +217,16 @@ static inline bool cpus_share_cache(int this_cpu, int that_cpu)
 #endif	/* !CONFIG_SMP */
 
 #ifndef arch_scale_cpu_capacity
+/**
+ * arch_scale_cpu_capacity - get the capacity scale factor of a given CPU.
+ * @cpu: the CPU in question.
+ *
+ * Return: the CPU scale factor normalized against SCHED_CAPACITY_SCALE, i.e.
+ *
+ *             max_perf(cpu)
+ *      ----------------------------- * SCHED_CAPACITY_SCALE
+ *      max(max_perf(c) : c \in CPUs)
+ */
 static __always_inline
 unsigned long arch_scale_cpu_capacity(int cpu)
 {
kernel/sched/sched.h +10 -0
index 296efd30d8c9..3fd283892761 100644
@@ -2049,6 +2049,16 @@ void arch_scale_freq_tick(void)
 #endif
 
 #ifndef arch_scale_freq_capacity
+/**
+ * arch_scale_freq_capacity - get the frequency scale factor of a given CPU.
+ * @cpu: the CPU in question.
+ *
+ * Return: the frequency scale factor normalized against SCHED_CAPACITY_SCALE, i.e.
+ *
+ *     f_curr
+ *     ------ * SCHED_CAPACITY_SCALE
+ *     f_max
+ */
 static __always_inline
 unsigned long arch_scale_freq_capacity(int cpu)
 {
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/3 sched/doc: Document capacity aware scheduling

In reply to Valentin Schneider

Add some documentation detailing the concepts, requirements and implementation of capacity aware scheduling across the different scheduler classes.

---
 Documentation/scheduler/index.rst          |   1 +
 Documentation/scheduler/sched-capacity.rst | 439 +++++++++++++++++++++
 2 files changed, 440 insertions(+)
 create mode 100644 Documentation/scheduler/sched-capacity.rst
Documentation/scheduler/index.rst +1 -0
index 69074e5de9c4..88900aabdbf7 100644
@@ -12,6 +12,7 @@ Linux Scheduler
     sched-deadline
     sched-design-CFS
     sched-domains
+    sched-capacity
     sched-energy
     sched-nice-design
     sched-rt-group
Documentation/scheduler/sched-capacity.rst new file +439 -0

439 lines not on this page · raw message

Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH 2/3] sched/doc: Document capacity aware scheduling

Quoted 8 lines · Valentin Schneider

Add some documentation detailing the concepts, requirements and implementation of capacity aware scheduling across the different scheduler classes.

---
 Documentation/scheduler/index.rst          |   1 +
 Documentation/scheduler/sched-capacity.rst | 439 +++++++++++++++++++++

How about I make this a .txt file and remove all that unreadable rst nonsense?

#4 lore raw

Re: [PATCH 2/3] sched/doc: Document capacity aware scheduling

Quoted 5 lines · On 04/08/20 12:26, [email protected] wrote:
Quoted 4 lines · Valentin Schneider

Add some documentation detailing the concepts, requirements and implementation of capacity aware scheduling across the different scheduler classes.

Quoted 7 lines
Quoted 4 lines
---
 Documentation/scheduler/index.rst          |   1 +
 Documentation/scheduler/sched-capacity.rst | 439 +++++++++++++++++++++

How about I make this a .txt file and remove all that unreadable rst nonsense?

I wouldn't mind *too* much, all diagrams are ASCII-based and the rest would just be plain text.

I get that the whole backtick thing is a bit annoying, but it's only there for symbols that aren't functions (since "foo()" gets automagically detected as a C reference), and because they aren't functions I would've gone for some other form of emphasis anyway (quotes or asterisks or something).

That said, Ingo picked it up early and it's already gone in via the sched/core PR.

#5 lore raw

PATCH 3/3 sched/doc: Factorize bits between sched-energy.rst & sched-capacity.rst

In reply to Valentin Schneider

Documentation/scheduler/sched-capacity.rst ought to be the canonical place to blabber about SD_ASYM_CPUCAPACITY, so remove its explanation from sched-energy.rst and point to sched-capacity.rst instead.

---
 Documentation/scheduler/sched-energy.rst | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
Documentation/scheduler/sched-energy.rst +2 -10
index 9580c57a52bc..78f850778982 100644
@@ -331,16 +331,8 @@ asymmetric CPU topologies for now. This requirement is checked at run-time by
 looking for the presence of the SD_ASYM_CPUCAPACITY flag when the scheduling
 domains are built.
 
-The flag is set/cleared automatically by the scheduler topology code whenever
-there are CPUs with different capacities in a root domain. The capacities of
-CPUs are provided by arch-specific code through the arch_scale_cpu_capacity()
-callback. As an example, arm and arm64 share an implementation of this callback
-which uses a combination of CPUFreq data and device-tree bindings to compute the
-capacity of CPUs (see drivers/base/arch_topology.c for more details).
-
-So, in order to use EAS on your platform your architecture must implement the
-arch_scale_cpu_capacity() callback, and some of the CPUs must have a lower
-capacity than others.
+See Documentation/sched/sched-capacity.rst for requirements to be met for this
+flag to be set in the sched_domain hierarchy.
 
 Please note that EAS is not fundamentally incompatible with SMP, but no
 significant savings on SMP platforms have been observed yet. This restriction
Signature · 1 line
2.27.0