From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH v4 7/7] sched/fair: Remove the energy margin in feec()
Date: Fri, 15 Apr 2022 19:58:15 +0800 [thread overview]
Message-ID: <202204151914.NKAe2ef1-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 17678 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220412134220.1588482-8-vincent.donnefort@arm.com>
References: <20220412134220.1588482-8-vincent.donnefort@arm.com>
TO: Vincent Donnefort <vincent.donnefort@arm.com>
Hi Vincent,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tip/sched/core]
[also build test WARNING on rafael-pm/linux-next rafael-pm/thermal v5.18-rc2 next-20220414]
[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/intel-lab-lkp/linux/commits/Vincent-Donnefort/feec-energy-margin-removal/20220412-214441
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 089c02ae2771a14af2928c59c56abfb9b885a8d7
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220415/202204151914.NKAe2ef1-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
kernel/sched/fair.c:6975 find_energy_efficient_cpu() error: uninitialized symbol 'best_energy_cpu'.
vim +/best_energy_cpu +6975 kernel/sched/fair.c
390031e4c309c9 Quentin Perret 2018-12-03 6814
732cd75b8c920d Quentin Perret 2018-12-03 6815 /*
732cd75b8c920d Quentin Perret 2018-12-03 6816 * find_energy_efficient_cpu(): Find most energy-efficient target CPU for the
732cd75b8c920d Quentin Perret 2018-12-03 6817 * waking task. find_energy_efficient_cpu() looks for the CPU with maximum
732cd75b8c920d Quentin Perret 2018-12-03 6818 * spare capacity in each performance domain and uses it as a potential
732cd75b8c920d Quentin Perret 2018-12-03 6819 * candidate to execute the task. Then, it uses the Energy Model to figure
732cd75b8c920d Quentin Perret 2018-12-03 6820 * out which of the CPU candidates is the most energy-efficient.
732cd75b8c920d Quentin Perret 2018-12-03 6821 *
732cd75b8c920d Quentin Perret 2018-12-03 6822 * The rationale for this heuristic is as follows. In a performance domain,
732cd75b8c920d Quentin Perret 2018-12-03 6823 * all the most energy efficient CPU candidates (according to the Energy
732cd75b8c920d Quentin Perret 2018-12-03 6824 * Model) are those for which we'll request a low frequency. When there are
732cd75b8c920d Quentin Perret 2018-12-03 6825 * several CPUs for which the frequency request will be the same, we don't
732cd75b8c920d Quentin Perret 2018-12-03 6826 * have enough data to break the tie between them, because the Energy Model
732cd75b8c920d Quentin Perret 2018-12-03 6827 * only includes active power costs. With this model, if we assume that
732cd75b8c920d Quentin Perret 2018-12-03 6828 * frequency requests follow utilization (e.g. using schedutil), the CPU with
732cd75b8c920d Quentin Perret 2018-12-03 6829 * the maximum spare capacity in a performance domain is guaranteed to be among
732cd75b8c920d Quentin Perret 2018-12-03 6830 * the best candidates of the performance domain.
732cd75b8c920d Quentin Perret 2018-12-03 6831 *
732cd75b8c920d Quentin Perret 2018-12-03 6832 * In practice, it could be preferable from an energy standpoint to pack
732cd75b8c920d Quentin Perret 2018-12-03 6833 * small tasks on a CPU in order to let other CPUs go in deeper idle states,
732cd75b8c920d Quentin Perret 2018-12-03 6834 * but that could also hurt our chances to go cluster idle, and we have no
732cd75b8c920d Quentin Perret 2018-12-03 6835 * ways to tell with the current Energy Model if this is actually a good
732cd75b8c920d Quentin Perret 2018-12-03 6836 * idea or not. So, find_energy_efficient_cpu() basically favors
732cd75b8c920d Quentin Perret 2018-12-03 6837 * cluster-packing, and spreading inside a cluster. That should at least be
732cd75b8c920d Quentin Perret 2018-12-03 6838 * a good thing for latency, and this is consistent with the idea that most
732cd75b8c920d Quentin Perret 2018-12-03 6839 * of the energy savings of EAS come from the asymmetry of the system, and
732cd75b8c920d Quentin Perret 2018-12-03 6840 * not so much from breaking the tie between identical CPUs. That's also the
732cd75b8c920d Quentin Perret 2018-12-03 6841 * reason why EAS is enabled in the topology code only for systems where
732cd75b8c920d Quentin Perret 2018-12-03 6842 * SD_ASYM_CPUCAPACITY is set.
732cd75b8c920d Quentin Perret 2018-12-03 6843 *
732cd75b8c920d Quentin Perret 2018-12-03 6844 * NOTE: Forkees are not accepted in the energy-aware wake-up path because
732cd75b8c920d Quentin Perret 2018-12-03 6845 * they don't have any useful utilization data yet and it's not possible to
732cd75b8c920d Quentin Perret 2018-12-03 6846 * forecast their impact on energy consumption. Consequently, they will be
732cd75b8c920d Quentin Perret 2018-12-03 6847 * placed by find_idlest_cpu() on the least loaded CPU, which might turn out
732cd75b8c920d Quentin Perret 2018-12-03 6848 * to be energy-inefficient in some use-cases. The alternative would be to
732cd75b8c920d Quentin Perret 2018-12-03 6849 * bias new tasks towards specific types of CPUs first, or to try to infer
732cd75b8c920d Quentin Perret 2018-12-03 6850 * their util_avg from the parent task, but those heuristics could hurt
732cd75b8c920d Quentin Perret 2018-12-03 6851 * other use-cases too. So, until someone finds a better way to solve this,
732cd75b8c920d Quentin Perret 2018-12-03 6852 * let's keep things simple by re-using the existing slow path.
732cd75b8c920d Quentin Perret 2018-12-03 6853 */
732cd75b8c920d Quentin Perret 2018-12-03 6854 static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
732cd75b8c920d Quentin Perret 2018-12-03 6855 {
04409022d37d2c Dietmar Eggemann 2022-04-12 6856 struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_rq_mask);
eb92692b2544d3 Quentin Perret 2019-09-12 6857 unsigned long prev_delta = ULONG_MAX, best_delta = ULONG_MAX;
ce557de247bd64 Vincent Donnefort 2022-04-12 6858 struct root_domain *rd = this_rq()->rd;
5311f1261af84b Vincent Donnefort 2022-04-12 6859 int cpu, best_energy_cpu, target = -1;
732cd75b8c920d Quentin Perret 2018-12-03 6860 struct sched_domain *sd;
eb92692b2544d3 Quentin Perret 2019-09-12 6861 struct perf_domain *pd;
ce557de247bd64 Vincent Donnefort 2022-04-12 6862 struct energy_env eenv;
732cd75b8c920d Quentin Perret 2018-12-03 6863
732cd75b8c920d Quentin Perret 2018-12-03 6864 rcu_read_lock();
732cd75b8c920d Quentin Perret 2018-12-03 6865 pd = rcu_dereference(rd->pd);
732cd75b8c920d Quentin Perret 2018-12-03 6866 if (!pd || READ_ONCE(rd->overutilized))
619e090c8e409e Pierre Gondois 2021-05-04 6867 goto unlock;
732cd75b8c920d Quentin Perret 2018-12-03 6868
732cd75b8c920d Quentin Perret 2018-12-03 6869 /*
732cd75b8c920d Quentin Perret 2018-12-03 6870 * Energy-aware wake-up happens on the lowest sched_domain starting
732cd75b8c920d Quentin Perret 2018-12-03 6871 * from sd_asym_cpucapacity spanning over this_cpu and prev_cpu.
732cd75b8c920d Quentin Perret 2018-12-03 6872 */
732cd75b8c920d Quentin Perret 2018-12-03 6873 sd = rcu_dereference(*this_cpu_ptr(&sd_asym_cpucapacity));
732cd75b8c920d Quentin Perret 2018-12-03 6874 while (sd && !cpumask_test_cpu(prev_cpu, sched_domain_span(sd)))
732cd75b8c920d Quentin Perret 2018-12-03 6875 sd = sd->parent;
732cd75b8c920d Quentin Perret 2018-12-03 6876 if (!sd)
619e090c8e409e Pierre Gondois 2021-05-04 6877 goto unlock;
619e090c8e409e Pierre Gondois 2021-05-04 6878
619e090c8e409e Pierre Gondois 2021-05-04 6879 target = prev_cpu;
732cd75b8c920d Quentin Perret 2018-12-03 6880
732cd75b8c920d Quentin Perret 2018-12-03 6881 sync_entity_load_avg(&p->se);
732cd75b8c920d Quentin Perret 2018-12-03 6882 if (!task_util_est(p))
732cd75b8c920d Quentin Perret 2018-12-03 6883 goto unlock;
732cd75b8c920d Quentin Perret 2018-12-03 6884
ce557de247bd64 Vincent Donnefort 2022-04-12 6885 eenv_task_busy_time(&eenv, p, prev_cpu);
ce557de247bd64 Vincent Donnefort 2022-04-12 6886
732cd75b8c920d Quentin Perret 2018-12-03 6887 for (; pd; pd = pd->next) {
ce557de247bd64 Vincent Donnefort 2022-04-12 6888 unsigned long cpu_cap, cpu_thermal_cap, util;
ce557de247bd64 Vincent Donnefort 2022-04-12 6889 unsigned long cur_delta, max_spare_cap = 0;
8d4c97c105ca07 Pierre Gondois 2021-05-04 6890 bool compute_prev_delta = false;
732cd75b8c920d Quentin Perret 2018-12-03 6891 int max_spare_cap_cpu = -1;
5311f1261af84b Vincent Donnefort 2022-04-12 6892 unsigned long base_energy;
732cd75b8c920d Quentin Perret 2018-12-03 6893
04409022d37d2c Dietmar Eggemann 2022-04-12 6894 cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask);
04409022d37d2c Dietmar Eggemann 2022-04-12 6895
ce557de247bd64 Vincent Donnefort 2022-04-12 6896 /* Account thermal pressure for the energy estimation */
ce557de247bd64 Vincent Donnefort 2022-04-12 6897 cpu = cpumask_first(cpus);
ce557de247bd64 Vincent Donnefort 2022-04-12 6898 cpu_thermal_cap = arch_scale_cpu_capacity(cpu);
ce557de247bd64 Vincent Donnefort 2022-04-12 6899 cpu_thermal_cap -= arch_scale_thermal_pressure(cpu);
ce557de247bd64 Vincent Donnefort 2022-04-12 6900
ce557de247bd64 Vincent Donnefort 2022-04-12 6901 eenv.cpu_cap = cpu_thermal_cap;
ce557de247bd64 Vincent Donnefort 2022-04-12 6902 eenv.pd_cap = 0;
ce557de247bd64 Vincent Donnefort 2022-04-12 6903
ce557de247bd64 Vincent Donnefort 2022-04-12 6904 for_each_cpu(cpu, cpus) {
ce557de247bd64 Vincent Donnefort 2022-04-12 6905 eenv.pd_cap += cpu_thermal_cap;
ce557de247bd64 Vincent Donnefort 2022-04-12 6906
ce557de247bd64 Vincent Donnefort 2022-04-12 6907 if (!cpumask_test_cpu(cpu, sched_domain_span(sd)))
ce557de247bd64 Vincent Donnefort 2022-04-12 6908 continue;
ce557de247bd64 Vincent Donnefort 2022-04-12 6909
3bd3706251ee8a Sebastian Andrzej Siewior 2019-04-23 6910 if (!cpumask_test_cpu(cpu, p->cpus_ptr))
732cd75b8c920d Quentin Perret 2018-12-03 6911 continue;
732cd75b8c920d Quentin Perret 2018-12-03 6912
732cd75b8c920d Quentin Perret 2018-12-03 6913 util = cpu_util_next(cpu, p, cpu);
732cd75b8c920d Quentin Perret 2018-12-03 6914 cpu_cap = capacity_of(cpu);
1d42509e475cdc Valentin Schneider 2019-12-11 6915
1d42509e475cdc Valentin Schneider 2019-12-11 6916 /*
1d42509e475cdc Valentin Schneider 2019-12-11 6917 * Skip CPUs that cannot satisfy the capacity request.
1d42509e475cdc Valentin Schneider 2019-12-11 6918 * IOW, placing the task there would make the CPU
1d42509e475cdc Valentin Schneider 2019-12-11 6919 * overutilized. Take uclamp into account to see how
1d42509e475cdc Valentin Schneider 2019-12-11 6920 * much capacity we can get out of the CPU; this is
a5418be9dffe70 Viresh Kumar 2020-12-08 6921 * aligned with sched_cpu_util().
1d42509e475cdc Valentin Schneider 2019-12-11 6922 */
1d42509e475cdc Valentin Schneider 2019-12-11 6923 util = uclamp_rq_util_with(cpu_rq(cpu), util, p);
60e17f5cef838e Viresh Kumar 2019-06-04 6924 if (!fits_capacity(util, cpu_cap))
732cd75b8c920d Quentin Perret 2018-12-03 6925 continue;
732cd75b8c920d Quentin Perret 2018-12-03 6926
ce557de247bd64 Vincent Donnefort 2022-04-12 6927 lsub_positive(&cpu_cap, util);
ce557de247bd64 Vincent Donnefort 2022-04-12 6928
732cd75b8c920d Quentin Perret 2018-12-03 6929 if (cpu == prev_cpu) {
8d4c97c105ca07 Pierre Gondois 2021-05-04 6930 /* Always use prev_cpu as a candidate. */
8d4c97c105ca07 Pierre Gondois 2021-05-04 6931 compute_prev_delta = true;
ce557de247bd64 Vincent Donnefort 2022-04-12 6932 } else if (cpu_cap > max_spare_cap) {
732cd75b8c920d Quentin Perret 2018-12-03 6933 /*
8d4c97c105ca07 Pierre Gondois 2021-05-04 6934 * Find the CPU with the maximum spare capacity
8d4c97c105ca07 Pierre Gondois 2021-05-04 6935 * in the performance domain.
732cd75b8c920d Quentin Perret 2018-12-03 6936 */
ce557de247bd64 Vincent Donnefort 2022-04-12 6937 max_spare_cap = cpu_cap;
732cd75b8c920d Quentin Perret 2018-12-03 6938 max_spare_cap_cpu = cpu;
732cd75b8c920d Quentin Perret 2018-12-03 6939 }
732cd75b8c920d Quentin Perret 2018-12-03 6940 }
732cd75b8c920d Quentin Perret 2018-12-03 6941
8d4c97c105ca07 Pierre Gondois 2021-05-04 6942 if (max_spare_cap_cpu < 0 && !compute_prev_delta)
8d4c97c105ca07 Pierre Gondois 2021-05-04 6943 continue;
8d4c97c105ca07 Pierre Gondois 2021-05-04 6944
8d4c97c105ca07 Pierre Gondois 2021-05-04 6945 /* Compute the 'base' energy of the pd, without @p */
ce557de247bd64 Vincent Donnefort 2022-04-12 6946 eenv_pd_busy_time(&eenv, cpus, p);
5311f1261af84b Vincent Donnefort 2022-04-12 6947 base_energy = compute_energy(&eenv, pd, cpus, p, -1);
8d4c97c105ca07 Pierre Gondois 2021-05-04 6948
8d4c97c105ca07 Pierre Gondois 2021-05-04 6949 /* Evaluate the energy impact of using prev_cpu. */
8d4c97c105ca07 Pierre Gondois 2021-05-04 6950 if (compute_prev_delta) {
ce557de247bd64 Vincent Donnefort 2022-04-12 6951 prev_delta = compute_energy(&eenv, pd, cpus, p,
ce557de247bd64 Vincent Donnefort 2022-04-12 6952 prev_cpu);
5311f1261af84b Vincent Donnefort 2022-04-12 6953 if (prev_delta < base_energy)
619e090c8e409e Pierre Gondois 2021-05-04 6954 goto unlock;
5311f1261af84b Vincent Donnefort 2022-04-12 6955 prev_delta -= base_energy;
8d4c97c105ca07 Pierre Gondois 2021-05-04 6956 best_delta = min(best_delta, prev_delta);
8d4c97c105ca07 Pierre Gondois 2021-05-04 6957 }
8d4c97c105ca07 Pierre Gondois 2021-05-04 6958
8d4c97c105ca07 Pierre Gondois 2021-05-04 6959 /* Evaluate the energy impact of using max_spare_cap_cpu. */
8d4c97c105ca07 Pierre Gondois 2021-05-04 6960 if (max_spare_cap_cpu >= 0) {
ce557de247bd64 Vincent Donnefort 2022-04-12 6961 cur_delta = compute_energy(&eenv, pd, cpus, p,
ce557de247bd64 Vincent Donnefort 2022-04-12 6962 max_spare_cap_cpu);
5311f1261af84b Vincent Donnefort 2022-04-12 6963 if (cur_delta < base_energy)
619e090c8e409e Pierre Gondois 2021-05-04 6964 goto unlock;
5311f1261af84b Vincent Donnefort 2022-04-12 6965 cur_delta -= base_energy;
eb92692b2544d3 Quentin Perret 2019-09-12 6966 if (cur_delta < best_delta) {
eb92692b2544d3 Quentin Perret 2019-09-12 6967 best_delta = cur_delta;
732cd75b8c920d Quentin Perret 2018-12-03 6968 best_energy_cpu = max_spare_cap_cpu;
732cd75b8c920d Quentin Perret 2018-12-03 6969 }
732cd75b8c920d Quentin Perret 2018-12-03 6970 }
732cd75b8c920d Quentin Perret 2018-12-03 6971 }
732cd75b8c920d Quentin Perret 2018-12-03 6972 rcu_read_unlock();
732cd75b8c920d Quentin Perret 2018-12-03 6973
5311f1261af84b Vincent Donnefort 2022-04-12 6974 if (best_delta < prev_delta)
619e090c8e409e Pierre Gondois 2021-05-04 @6975 target = best_energy_cpu;
732cd75b8c920d Quentin Perret 2018-12-03 6976
619e090c8e409e Pierre Gondois 2021-05-04 6977 return target;
732cd75b8c920d Quentin Perret 2018-12-03 6978
619e090c8e409e Pierre Gondois 2021-05-04 6979 unlock:
732cd75b8c920d Quentin Perret 2018-12-03 6980 rcu_read_unlock();
732cd75b8c920d Quentin Perret 2018-12-03 6981
619e090c8e409e Pierre Gondois 2021-05-04 6982 return target;
732cd75b8c920d Quentin Perret 2018-12-03 6983 }
732cd75b8c920d Quentin Perret 2018-12-03 6984
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next reply other threads:[~2022-04-15 11:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 11:58 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-04-12 13:42 [PATCH v3 0/7] feec() energy margin removal Vincent Donnefort
2022-04-12 13:42 ` [PATCH v4 7/7] sched/fair: Remove the energy margin in feec() Vincent Donnefort
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=202204151914.NKAe2ef1-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/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 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.