2020-08-27 15:40:00

by Vincent Donnefort

[permalink] [raw]
Subject: [PATCH] sched/debug: Add new tracepoint to track cpu_capacity

From: Vincent Donnefort <[email protected]>

rq->cpu_capacity is a key element in several scheduler parts, such as EAS
task placement and load balancing. Tracking this value enables testing
and/or debugging by a toolkit.

Signed-off-by: Vincent Donnefort <[email protected]>

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 021ad7b..7e19d59 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2055,6 +2055,7 @@ const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq);
const struct sched_avg *sched_trace_rq_avg_irq(struct rq *rq);

int sched_trace_rq_cpu(struct rq *rq);
+int sched_trace_rq_cpu_capacity(struct rq *rq);
int sched_trace_rq_nr_running(struct rq *rq);

const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 8ab48b3..f94ddd1 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -630,6 +630,10 @@ DECLARE_TRACE(pelt_se_tp,
TP_PROTO(struct sched_entity *se),
TP_ARGS(se));

+DECLARE_TRACE(sched_cpu_capacity_tp,
+ TP_PROTO(struct rq *rq),
+ TP_ARGS(rq));
+
DECLARE_TRACE(sched_overutilized_tp,
TP_PROTO(struct root_domain *rd, bool overutilized),
TP_ARGS(rd, overutilized));
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 06b0a40..e468271 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -36,6 +36,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_rt_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_dl_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_irq_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_se_tp);
+EXPORT_TRACEPOINT_SYMBOL_GPL(sched_cpu_capacity_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 44f7a0b..e11f724 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8116,6 +8116,8 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu)
capacity = 1;

cpu_rq(cpu)->cpu_capacity = capacity;
+ trace_sched_cpu_capacity_tp(cpu_rq(cpu));
+
sdg->sgc->capacity = capacity;
sdg->sgc->min_capacity = capacity;
sdg->sgc->max_capacity = capacity;
@@ -11318,6 +11320,12 @@ int sched_trace_rq_cpu(struct rq *rq)
}
EXPORT_SYMBOL_GPL(sched_trace_rq_cpu);

+int sched_trace_rq_cpu_capacity(struct rq *rq)
+{
+ return rq ? rq->cpu_capacity : -1;
+}
+EXPORT_SYMBOL_GPL(sched_trace_rq_cpu_capacity);
+
const struct cpumask *sched_trace_rd_span(struct root_domain *rd)
{
#ifdef CONFIG_SMP
--
2.7.4


2020-08-27 19:12:04

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] sched/debug: Add new tracepoint to track cpu_capacity

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on tip/perf/core tip/auto-latest linus/master v5.9-rc2 next-20200827]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/vincent-donnefort-arm-com/sched-debug-Add-new-tracepoint-to-track-cpu_capacity/20200827-233803
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 4fc472f1214ef75e5450f207e23ff13af6eecad4
config: x86_64-randconfig-a015-20200827 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 71f3169e1baeff262583b35ef88f8fb6df7be85e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> kernel/sched/fair.c:11314:18: error: no member named 'cpu_capacity' in 'struct rq'
return rq ? rq->cpu_capacity : -1;
~~ ^
1 error generated.

# https://github.com/0day-ci/linux/commit/85b324a307f8d602382ecbfb149f6411eb99bd03
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review vincent-donnefort-arm-com/sched-debug-Add-new-tracepoint-to-track-cpu_capacity/20200827-233803
git checkout 85b324a307f8d602382ecbfb149f6411eb99bd03
vim +11314 kernel/sched/fair.c

11311
11312 int sched_trace_rq_cpu_capacity(struct rq *rq)
11313 {
11314 return rq ? rq->cpu_capacity : -1;
11315 }
11316 EXPORT_SYMBOL_GPL(sched_trace_rq_cpu_capacity);
11317

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.25 kB)
.config.gz (40.51 kB)
Download all attachments

2020-08-27 19:27:28

by Valentin Schneider

[permalink] [raw]
Subject: Re: [PATCH] sched/debug: Add new tracepoint to track cpu_capacity


On 27/08/20 20:08, kernel test robot wrote:
> All errors (new ones prefixed by >>):
>
>>> kernel/sched/fair.c:11314:18: error: no member named 'cpu_capacity' in 'struct rq'
> return rq ? rq->cpu_capacity : -1;
> ~~ ^
> 1 error generated.
>

The joys of !SMP; you'll want to wrap this in an #ifdef CONFIG_SMP like
some of the other TP's. The !SMP case can probably return
SCHED_CAPACITY_SCALE for the sake of pedantism, AFAICT that TP can't fire
on !SMP (that, or only define it for SMP).