All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization
@ 2023-07-30 21:16 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-07-30 21:16 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <61e6fce60ca738215b6e5ad9033fb692c3a8fbb1.1690273854.git.yu.c.chen@intel.com>
References: <61e6fce60ca738215b6e5ad9033fb692c3a8fbb1.1690273854.git.yu.c.chen@intel.com>
TO: Chen Yu <yu.c.chen@intel.com>

Hi Chen,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on linus/master v6.5-rc4]
[cannot apply to next-20230728]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chen-Yu/sched-topology-Assign-sd_share-for-all-non-NUMA-sched-domains/20230727-144634
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/61e6fce60ca738215b6e5ad9033fb692c3a8fbb1.1690273854.git.yu.c.chen%40intel.com
patch subject: [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: m68k-randconfig-r052-20230730 (https://download.01.org/0day-ci/archive/20230731/202307310545.yIIAUNvV-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230731/202307310545.yIIAUNvV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202307310545.yIIAUNvV-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> kernel/sched/fair.c:10303:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

vim +10303 kernel/sched/fair.c

68d8d6c49d1ef0 Chen Yu 2023-07-27  10279  
f3d2a482eb6ae1 Chen Yu 2023-07-27  10280  static void update_ilb_group_scan(struct lb_env *env,
f3d2a482eb6ae1 Chen Yu 2023-07-27  10281  				  unsigned long sum_util,
f3d2a482eb6ae1 Chen Yu 2023-07-27  10282  				  struct sched_domain_shared *sd_share)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10283  {
f3d2a482eb6ae1 Chen Yu 2023-07-27  10284  	u64 tmp, nr_scan;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10285  
f3d2a482eb6ae1 Chen Yu 2023-07-27  10286  	if (!sched_feat(ILB_UTIL))
f3d2a482eb6ae1 Chen Yu 2023-07-27  10287  		return;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10288  
f3d2a482eb6ae1 Chen Yu 2023-07-27  10289  	if (!sd_share)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10290  		return;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10291  
f3d2a482eb6ae1 Chen Yu 2023-07-27  10292  	if (env->idle == CPU_NEWLY_IDLE)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10293  		return;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10294  
f3d2a482eb6ae1 Chen Yu 2023-07-27  10295  	/*
f3d2a482eb6ae1 Chen Yu 2023-07-27  10296  	 * Limit the newidle balance scan depth based on overall system
f3d2a482eb6ae1 Chen Yu 2023-07-27  10297  	 * utilization:
f3d2a482eb6ae1 Chen Yu 2023-07-27  10298  	 * nr_groups_scan = nr_groups * (1 - util_ratio)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10299  	 * and util_ratio = sum_util / (sd_weight * SCHED_CAPACITY_SCALE)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10300  	 */
f3d2a482eb6ae1 Chen Yu 2023-07-27  10301  	nr_scan = env->sd->nr_groups * sum_util;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10302  	tmp = env->sd->span_weight * SCHED_CAPACITY_SCALE;
f3d2a482eb6ae1 Chen Yu 2023-07-27 @10303  	do_div(nr_scan, tmp);
f3d2a482eb6ae1 Chen Yu 2023-07-27  10304  	nr_scan = env->sd->nr_groups - nr_scan;
f3d2a482eb6ae1 Chen Yu 2023-07-27  10305  	if ((int)nr_scan != sd_share->nr_sg_scan)
f3d2a482eb6ae1 Chen Yu 2023-07-27  10306  		WRITE_ONCE(sd_share->nr_sg_scan, (int)nr_scan);
f3d2a482eb6ae1 Chen Yu 2023-07-27  10307  }
f3d2a482eb6ae1 Chen Yu 2023-07-27  10308  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [RFC PATCH 0/7] Optimization to reduce the cost of newidle balance
@ 2023-07-27 14:33 Chen Yu
  2023-07-27 14:35 ` [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization Chen Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Yu @ 2023-07-27 14:33 UTC (permalink / raw)
  To: Peter Zijlstra, Vincent Guittot
  Cc: Ingo Molnar, Juri Lelli, Tim Chen, Mel Gorman, Dietmar Eggemann,
	K Prateek Nayak, Gautham R . Shenoy, Chen Yu, Aaron Lu,
	linux-kernel, Chen Yu

Hi,

This is the second version of the newidle balance optimization[1].
It aims to reduce the cost of newidle balance which is found to
occupy noticeable CPU cycles on some high-core count systems.

For example, when running sqlite on Intel Sapphire Rapids, which has
2 x 56C/112T = 224 CPUs:

6.69%    0.09%  sqlite3     [kernel.kallsyms]   [k] newidle_balance
5.39%    4.71%  sqlite3     [kernel.kallsyms]   [k] update_sd_lb_stats

To mitigate this cost, the optimization is inspired by the question
raised by Tim:
Do we always have to find the busiest group and pull from it? Would
a relatively busy group be enough?

There are two proposals in this patch set.
The first one is ILB_UTIL. It was proposed to limit the scan
depth in update_sd_lb_stats(). The scan depth is based on the
overall utilization of this sched domain. The higher the utilization
is, the less update_sd_lb_stats() scans. Vice versa.

The second one is ILB_FAST. Instead of always finding the busiest
group in update_sd_lb_stats(), lower the bar and try to find a
relatively busy group. ILB_FAST takes effect when the local group
is group_has_spare. Because when there are many CPUs running
newidle_balance() concurrently, the sched groups should have a
high idle percentage.

Compared between ILB_UTIL and ILB_FAST, the former inhibits the
sched group scan when the system is busy. While the latter
chooses a compromised busy group when the system is not busy.
So they are complementary to each other and work independently.

patch 1/7 and patch 2/7 are preparation for ILB_UTIL.

patch 3/7 is a preparation for both ILB_UTIL and ILB_FAST.

patch 4/7 is part of ILB_UTIL. It calculates the scan depth
          of sched groups which will be used by
          update_sd_lb_stats(). The depth is calculated by the
          periodic load balance.

patch 5/7 introduces the ILB_UTIL.

patch 6/7 introduces the ILB_FAST.

patch 7/7 is a debug patch to print more sched statistics, inspired
          by Prateek's test report.

In the previous version, Prateek found some regressions[2].
This is probably caused by:
1. Cross Numa access to sched_domain_shared. So this version removed
   the sched_domain_shared for Numa domain.
2. newidle balance did not try so hard to scan for the busiest
   group. This version still keeps the linear scan function. If
   the regression is still there, we can try to leverage the result
   of SIS_UTIL. Because SIS_UTIL is a quadratic function which
   could help scan the domain harder when the system is not
   overloaded.

Changes since the previous version:
1. For all levels except for NUMA, connect a sched_domain_shared
   instance. This makes the newidle balance optimization more
   generic, and not only for LLC domain. (Peter, Gautham)
2. Introduce ILB_FAST, which terminates the sched group scan
   earlier, if it finds a proper group rather than the busiest
   one (Tim).


Peter has suggested reusing the statistics of the sched group
if multiple CPUs trigger newidle balance concurrently[3]. I created
a prototype[4] based on this direction. According to the test, there
are some regressions. The bottlenecks are a spin_trylock() and the
memory load from the 'cached' shared region. It is still under
investigation so I did not include that change into this patch set.

Any comments would be appreciated.

[1] https://lore.kernel.org/lkml/cover.1686554037.git.yu.c.chen@intel.com/
[2] https://lore.kernel.org/lkml/7e31ad34-ce2c-f64b-a852-f88f8a5749a6@amd.com/
[3] https://lore.kernel.org/lkml/20230621111721.GA2053369@hirez.programming.kicks-ass.net/
[4] https://github.com/chen-yu-surf/linux/commit/a6b33df883b972d6aaab5fceeddb11c34cc59059.patch

Chen Yu (7):
  sched/topology: Assign sd_share for all non NUMA sched domains
  sched/topology: Introduce nr_groups in sched_domain to indicate the
    number of groups
  sched/fair: Save a snapshot of sched domain total_load and
    total_capacity
  sched/fair: Calculate the scan depth for idle balance based on system
    utilization
  sched/fair: Adjust the busiest group scanning depth in idle load
    balance
  sched/fair: Pull from a relatively busy group during newidle balance
  sched/stats: Track the scan number of groups during load balance

 include/linux/sched/topology.h |   5 ++
 kernel/sched/fair.c            | 114 ++++++++++++++++++++++++++++++++-
 kernel/sched/features.h        |   4 ++
 kernel/sched/stats.c           |   5 +-
 kernel/sched/topology.c        |  14 ++--
 5 files changed, 135 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-30 19:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-30 21:16 [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-07-27 14:33 [RFC PATCH 0/7] Optimization to reduce the cost of newidle balance Chen Yu
2023-07-27 14:35 ` [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization Chen Yu
2023-08-25  6:02   ` Shrikanth Hegde
2023-08-30 15:30     ` Chen Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.