Re: [PATCH 1/5] sched: limit cpu search in select_idle_cpu

From: kbuild test robot
Date: Tue Jun 12 2018 - 16:34:14 EST


Hi subhra,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on v4.17 next-20180612]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/subhra-mazumdar/Improve-scheduler-scalability-for-fast-path/20180613-015158
config: i386-randconfig-x070-201823 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

kernel/sched/fair.c: In function 'select_idle_cpu':
>> kernel/sched/fair.c:6396:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
u64 span_avg = sd->span_weight * avg_idle;
^~~

vim +6396 kernel/sched/fair.c

10e2f1acd Peter Zijlstra 2016-05-09 6363
10e2f1acd Peter Zijlstra 2016-05-09 6364 /*
10e2f1acd Peter Zijlstra 2016-05-09 6365 * Scan the LLC domain for idle CPUs; this is dynamically regulated by
10e2f1acd Peter Zijlstra 2016-05-09 6366 * comparing the average scan cost (tracked in sd->avg_scan_cost) against the
10e2f1acd Peter Zijlstra 2016-05-09 6367 * average idle time for this rq (as found in rq->avg_idle).
10e2f1acd Peter Zijlstra 2016-05-09 6368 */
10e2f1acd Peter Zijlstra 2016-05-09 6369 static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target)
10e2f1acd Peter Zijlstra 2016-05-09 6370 {
9cfb38a7b Wanpeng Li 2016-10-09 6371 struct sched_domain *this_sd;
1ad3aaf3f Peter Zijlstra 2017-05-17 6372 u64 avg_cost, avg_idle;
10e2f1acd Peter Zijlstra 2016-05-09 6373 u64 time, cost;
10e2f1acd Peter Zijlstra 2016-05-09 6374 s64 delta;
8dd662615 subhra mazumdar 2018-06-12 6375 int cpu, limit, floor, nr = INT_MAX;
10e2f1acd Peter Zijlstra 2016-05-09 6376
9cfb38a7b Wanpeng Li 2016-10-09 6377 this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc));
9cfb38a7b Wanpeng Li 2016-10-09 6378 if (!this_sd)
9cfb38a7b Wanpeng Li 2016-10-09 6379 return -1;
9cfb38a7b Wanpeng Li 2016-10-09 6380
10e2f1acd Peter Zijlstra 2016-05-09 6381 /*
10e2f1acd Peter Zijlstra 2016-05-09 6382 * Due to large variance we need a large fuzz factor; hackbench in
10e2f1acd Peter Zijlstra 2016-05-09 6383 * particularly is sensitive here.
10e2f1acd Peter Zijlstra 2016-05-09 6384 */
1ad3aaf3f Peter Zijlstra 2017-05-17 6385 avg_idle = this_rq()->avg_idle / 512;
1ad3aaf3f Peter Zijlstra 2017-05-17 6386 avg_cost = this_sd->avg_scan_cost + 1;
1ad3aaf3f Peter Zijlstra 2017-05-17 6387
1ad3aaf3f Peter Zijlstra 2017-05-17 6388 if (sched_feat(SIS_AVG_CPU) && avg_idle < avg_cost)
10e2f1acd Peter Zijlstra 2016-05-09 6389 return -1;
10e2f1acd Peter Zijlstra 2016-05-09 6390
1ad3aaf3f Peter Zijlstra 2017-05-17 6391 if (sched_feat(SIS_PROP)) {
8dd662615 subhra mazumdar 2018-06-12 6392 floor = cpumask_weight(topology_sibling_cpumask(target));
8dd662615 subhra mazumdar 2018-06-12 6393 if (floor < 2)
8dd662615 subhra mazumdar 2018-06-12 6394 floor = 2;
8dd662615 subhra mazumdar 2018-06-12 6395 limit = 2*floor;
1ad3aaf3f Peter Zijlstra 2017-05-17 @6396 u64 span_avg = sd->span_weight * avg_idle;
8dd662615 subhra mazumdar 2018-06-12 6397 if (span_avg > floor*avg_cost) {
1ad3aaf3f Peter Zijlstra 2017-05-17 6398 nr = div_u64(span_avg, avg_cost);
8dd662615 subhra mazumdar 2018-06-12 6399 if (nr > limit)
8dd662615 subhra mazumdar 2018-06-12 6400 nr = limit;
8dd662615 subhra mazumdar 2018-06-12 6401 } else {
8dd662615 subhra mazumdar 2018-06-12 6402 nr = floor;
8dd662615 subhra mazumdar 2018-06-12 6403 }
1ad3aaf3f Peter Zijlstra 2017-05-17 6404 }
1ad3aaf3f Peter Zijlstra 2017-05-17 6405
10e2f1acd Peter Zijlstra 2016-05-09 6406 time = local_clock();
10e2f1acd Peter Zijlstra 2016-05-09 6407
c743f0a5c Peter Zijlstra 2017-04-14 6408 for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
1ad3aaf3f Peter Zijlstra 2017-05-17 6409 if (!--nr)
1ad3aaf3f Peter Zijlstra 2017-05-17 6410 return -1;
0c98d344f Ingo Molnar 2017-02-05 6411 if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
10e2f1acd Peter Zijlstra 2016-05-09 6412 continue;
943d355d7 Rohit Jain 2018-05-09 6413 if (available_idle_cpu(cpu))
10e2f1acd Peter Zijlstra 2016-05-09 6414 break;
10e2f1acd Peter Zijlstra 2016-05-09 6415 }
10e2f1acd Peter Zijlstra 2016-05-09 6416
10e2f1acd Peter Zijlstra 2016-05-09 6417 time = local_clock() - time;
10e2f1acd Peter Zijlstra 2016-05-09 6418 cost = this_sd->avg_scan_cost;
10e2f1acd Peter Zijlstra 2016-05-09 6419 delta = (s64)(time - cost) / 8;
10e2f1acd Peter Zijlstra 2016-05-09 6420 this_sd->avg_scan_cost += delta;
10e2f1acd Peter Zijlstra 2016-05-09 6421
10e2f1acd Peter Zijlstra 2016-05-09 6422 return cpu;
10e2f1acd Peter Zijlstra 2016-05-09 6423 }
10e2f1acd Peter Zijlstra 2016-05-09 6424

:::::: The code at line 6396 was first introduced by commit
:::::: 1ad3aaf3fcd2444406628a19a9b9e0922b95e2d4 sched/core: Implement new approach to scale select_idle_cpu()

:::::: TO: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
:::::: CC: Ingo Molnar <mingo@xxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip