Commit Graph

1104240 Commits

Author SHA1 Message Date
Abhijeet Dharmapurikar
11d8a97073 sched/walt: use prs for energy evaluation
Currently, the code uses walt util for energy evaluation. That could be
inaccurate because walt prs signals drive cpufreq. Change to using
prs.

Change-Id: Iea073c7963bf27ab1308950b07a2aead1c73805c
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:53 -07:00
Abhijeet Dharmapurikar
31be7e0e1e sched/walt: skip energy for uninvolved cluster
A cluster that does not host prev cpu and or any of the candidates
doesn't affect the energy values. Don't calculate their contributions.

Change-Id: Id1b890dbf157fa27d90287202f7916c6ab102bba
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:52 -07:00
Abhijeet Dharmapurikar
71a5697adb sched/walt: create walt friendly energy apis
Create walt lookalikes for compute_energy (walt_pd_
compute_energy) and em_cpu_energy (walt_em_cpu_energy).

Change-Id: Ib6cb0b90c1041b0d1c97729c1998c618fd60c81c
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:51 -07:00
Abhijeet Dharmapurikar
1156ad0e3b sched/walt: Track best target cpu for each cluster
Currently, energy evaluation occurs only on one target cpu chosen
across all CPU clusters.
Change the algorithm to track target cpus for each cluster and
subsequently perform energy calculations on these candidates.
For a cluster, if both an idle cpu and a busy cpu is found, prefer
idle cpu. That also means, once idle if found there is no need to
visit upcoming busy cpus as we traverse the cpus in a cluster.

Change-Id: Idd832748cdd01e0995783b1959332acd66e94cd6
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:50 -07:00
Sai Harshini Nimmala
b7c86b3ea2 sched: walt: Move perf counter trace to dynamic trace point
Currently the  sched_switch_ctrs trace event is dependent on
debugfs to get enabled, and not compatible with all builds.

Move the sched_switch_ctrs to dynamic trace point registration
under walt dynamic tp, as the trace event has considerable
overhead and need to enabled on need basis.

Change-Id: I6d9eb328ecf14a15e27d67dd5c1a46b0383aa860
Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
2022-06-28 18:50:49 -07:00
Lingutla Chandrasekhar
242434fe46 sched: walt: support dynamic trace event registration
Some trace events might not need to be enabled always, but
needed for debug purpose. It is not optimal to register trace
event, which is used for debug purpose only. So registering such
trace events might add extra overhead in hotpaths.

So add control knob for registering such trace events to trace points,
which can be enabled whenever needed them. And can be unregister when
not needed.

To enable such event registration, write:

echo 1 > /proc/sys/walt/sched_enable_tp

And register sched_overutilized trace event with dynamic support, this
event is copied from Qais's debug change in chrome project:
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2128628

Change-Id: I8983e31d405a635b38c7c985b56c2f564855d3e6
Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
2022-06-28 18:50:48 -07:00
Rishabh Bhatnagar
efabb036d0 sched: Disable LPM if CONSERVATIVE_BOOST is enabled
Disable LPM for hysteresis time if CONSERVATIVE_BOOST is enabled.

Change-Id: If88513b664c00ecb2cd48961b907bec719e822a9
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
2022-06-28 18:50:48 -07:00
Shaleen Agrawal
ddb1c85d60 sched: walt: Fix waltgov_next_freq format specifiers
Certain unsigned int values are being specified as %lu instead of %u and
it is leading to incorrectly displayed values.

Change-Id: I26f65ef24a89c277e2da0f88c1e3d683ef545057
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:47 -07:00
Stephen Dickey
9fdd530d51 sched/walt: improve debug of strange rq situations in walt
When a task is not on a rq when it should be, halt and
print some useful information.

Change-Id: Iaecbf372c712acba98879c8afb4e073d50a962f7
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:46 -07:00
Rishabh Bhatnagar
004502ad2d sched/walt: add sched_busy_hyst_time trace event
Create a trace event for tracking sched_busy_hyst
behavior to improve debugging.

Change-Id: I0921d8cc7e1f0781605a4963113a18e13827d6ac
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
2022-06-28 18:50:45 -07:00
Rishabh Bhatnagar
df94d80ceb sched: Add util_busy_hist feature
Add util_busy_hist feature which looks at the total cpu_util
across all CPUs as a metric for LPM biasing on CPUs.

Change-Id: Ie148178dfdc8f2b13fd447b1a87d60176f53f4a7
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
2022-06-28 18:50:42 -07:00
Rishabh Bhatnagar
13b036b5ef sched: Add util busy hist sysctl tunables
Add util_busy_hist sysctl tunables which solely
look at the sum of cpu_util across CPUs as a metric for
LPM biasing on any/all CPUs.

Change-Id: Ib981c21a58059ef02772ee797808c5f30547a688
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
2022-06-28 18:50:39 -07:00
Satya Durga Srinivasu Prabhala
9d8bdac63a sched/walt: improve logging in the error paths
Printing CPUs info is useful while going through error paths.

Change-Id: If84794163b6c417d419785fdddd2eed98588f2eb
Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
2022-06-28 18:50:39 -07:00
Pavankumar Kondeti
d233af280c sched/walt: Do the rq clock update before MVP tasks update
The rq clock gets updated in the scheduler tick. However, if the
lock is acquired remotely between the scheduler tick and the
vendor hook, the clock update flags gets reset. Do the clock
update in walt_cfs_account_mvp_runtime based on the clock update
flags.

Change-Id: Ie4254a191a18458cf1684070bc96ff63cf0103d3
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:50:37 -07:00
Pavankumar Kondeti
5a4738726d sched/walt: Fix locking issue in MVP tasks update
Protect MVP tasks list access in the tick path with rq lock.

Change-Id: I387aa104cbacaf445bf739b8fb6d631283bd0ada
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:50:37 -07:00
Abhijeet Dharmapurikar
8bbd8002ed sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: I3280c12b5446b8c12fd4269efc2c1dad70e4ae6a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:36 -07:00
Shaleen Agrawal
d804178181 sched: walt: Adjust nomenclature
Change min_freq and max_freq to be policy_min_freq, policy_max_freq.

Change-Id: Ief7ee31209338e6fc25f4ad8933b60256ac5eb95
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:35 -07:00
Shaleen Agrawal
39605473ba sched: walt: expand waltgov_util_update trace point
When experiencing frequency related issues, it will be helpful to be
aware of any potential clamping issues, as well as reasons why we might
end up not updating to a different frequency.

Change-Id: I0be24d713421357e077cd01d5c84f43138a17b24
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:34 -07:00
Tengfei Fan
a62a217748 sched/fair: Add sched_sync_hint_enable node
Add sched_sync_hint_enable not to enable/disable sync.

Change-Id: I455545487d002b4e3caf96c6cf8569549c3b1bbe
Signed-off-by: Tengfei Fan <tengfeif@codeaurora.org>
2022-06-28 18:50:33 -07:00
Satya Durga Srinivasu Prabhala
7d53585557 sched/walt: fix lock ordering issue between RTG lock and task's RQ lock
lock ordering issue is observed in below scenario where preferred cluster
for the task is being set on one CPU while task is being attached to
related thread group which leads to deadlock.

CPUX:
	scheduler_tick() --> acquire rq_lock()
	trace_android_rvh_tick_entry()
	android_rvh_tick_entry()
	set_preferred_cluster() --> try to acquire RTG lock taken by CPUY

CPUY:
	cpu_cgroup_attach()
	trace_android_rvh_cpu_cgroup_attach()
	android_rvh_cpu_cgroup_attach()
	__sched_set_group_id()
	add_task_to_group() --> acquire RTG lock
	__task_rq_lock() --> try to acquire task's rq_lock() which is CPUX

Fix the issue by moving set_preferred_cluster() related piece of code
which is being called from scheduler_tick() to android_vh_scheduler_tick
trace hook.

Change-Id: Ib9e2d70ae45a304d21cde3de6b8a84f9049061ab
Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
2022-06-28 18:50:32 -07:00
Abhijeet Dharmapurikar
5f5bd6a0d2 sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: I5f08d40d6e9f18a905d87db078fa1a70abaa9030
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:29 -07:00
Elliot Berman
2dbf2bb3b9 sched/walt: fixup_busy_time: Correct typo in lockdep_assert_held
The parameter to lockdep_assert_held should be a pointer to a lock, not the
lock itself.

Change-Id: I4586d86b8684b21370a2bc522862932481fef538
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
2022-06-28 18:50:27 -07:00
Satya Durga Srinivasu Prabhala
42aab9f364 sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: I9a94b20b18bf5b78946fd26d3337f5227d735e03
Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
2022-06-28 18:50:26 -07:00
Pavankumar Kondeti
fafe5c1f61 sched/walt: Fix newline issues
Fix newline issues in MVP tasks code.

Change-Id: I0d0ee2ae5e50b5b4310544d4c1fb818bff998773
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:50:25 -07:00
Abhijeet Dharmapurikar
4dcd5a2a02 sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: I2a10a999f94e2f21eb97761516c135aadbe305e7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:24 -07:00
Abhijeet Dharmapurikar
c565963618 walt: honor affinity in placement path
Walt placement code could return the prev_cpu for placement without
checking if it is in affinity mask.

Fix it by checking task's cpus_ptr.

Change-Id: I6edf2249bccffd1868dd546dc18b45af311cc91d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2022-06-28 18:50:23 -07:00
Sai Harshini Nimmala
550838ff0a sched/walt: Add MVP tasks feature
MVP tasks feature is intended for improving general scheduler
performance.

Change-Id: I7262daf52c3ca4c627642cc5e2aa33a7b33a2305
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
2022-06-28 18:50:23 -07:00
Stephen Dickey
0fa8c0d229 sched/walt: cleanup references to pr_emerg
In scheduler code printk_deferred should be used instead
of pr_emerg, as this will avoid taking any locks and defer
output to a safer time.

Change-Id: I06b9060754d97f4ca141c561eb80216530e0e25e
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:22 -07:00
Shaleen Agrawal
619670b06a sched: Improve the scheduler
There is a redundant check taking place in set_task_cpu hook. The cpu
will never be negative from core kernel side, so remove it.

Change-Id: I6d8ab62573f401d6aaeda9c5ddb1183c69e8c7d6
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:21 -07:00
Sai Harshini Nimmala
a822c7ebe1 sched/walt: Add small task filtering to uclamp
Currently, small tasks get placed on mid-cap CPUs if uclamp is active
on them. This causes power numbers to increase.
Introduce filtering such that small tasks stay on silver.

Change-Id: I7e31d8a5ffd4c4f64d7bd3668970216550d23d24
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
2022-06-28 18:50:20 -07:00
Pavankumar Kondeti
4dfdcf521a sched/walt: Cache the affinity of a user space task
When a user space task move across cpuset cgroups, the affinity
settings are lost. Fix this issue by caching the affinity of
a user space task during affinity change system call and restore
it during cpuset cgroup change when possible. The cpuset part
is implemented in the code but affinity system call part is
not implemented. This patch implements that.

Change-Id: I9322400eb275aeeb35fb623210417df4730cc6ad
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:50:17 -07:00
Stephen Dickey
2e720fa7e7 sched/walt: enhanced debug for double enqueue/dequeue
attempt to catch double enqueue/dequeue of a task, which
can impact walt accounting.

Change-Id: I2ff83e75d65f083c8d2896dd10313c193a16fa7b
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:14 -07:00
Stephen Dickey
594217b008 sched/walt: debug for fixup_cumulative_runnable_avg
Catch when the rq is not the same as this task's rq.
Catch a double enqueue or dequeue of the same task.

Change-Id: I322588f4c8ad59ee48c6d14bd87c5db6d842e6f6
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:13 -07:00
Sai Harshini Nimmala
717473462b sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: I2435c4ecd4c6a978af188a6385d306691376bb0a
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
2022-06-28 18:50:12 -07:00
Stephen Dickey
c7d56f9819 sched/walt: improved debug for tracking accounting cases
Introduce information into the debugging of
fixup_cumulative_runnable_avg by ensuring that the data from
the task of interest is dumped, and that the runqueue in
question is locked.

Change-Id: Idb6e3bd1b4ba67512fa6663555c22e933c9d0a6e
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:10 -07:00
jianzhou
2874629bd7 sched/walt: Apply binder vendor hook performance tune
Apply binder vendor hook performance tune for blocked binder
transaction.

Change-Id: Ia4a344fd260df12f4d5b364f7f4027c50c6f1a99
Signed-off-by: jianzhou <jianzhou@codeaurora.org>
2022-06-28 18:50:09 -07:00
Abhijeet Dharmapurikar
b07ef98a47 sched/walt: Improve the scheduler
This change is for general scheduler improvement.

Change-Id: Ife8de1eee2b7aa862979073c075466c97ba980e3
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:50:08 -07:00
Pavankumar Kondeti
216e06f3dd sched/walt: Initialize task groups from vendor hook
The current code does the task group initialization from a sysctl
handler invoked via post-boot. But some tasks could have been
added to the cgroups and walt would miss to act upon them.

Depending on user space to notify when to populate task group
pointers is racy. This patch moves away from this approach and use
the cpu controller cgroup online vendor hook to initialize the task
group pointers. During module load, iterate over all the existing
cgroups if any and do the initialization.

Change-Id: I133099a49f94de836b95403c5f1126587de84919
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:50:07 -07:00
Shaleen Agrawal
04d77db8ef sched: walt: Cleanup fbt_env boosted member
We are no longer using the boosted member in the fbt_env struct. Clean
it up.

Change-Id: If8d0a68b8fb090a889c59667eb0fd8534c62af65
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:06 -07:00
Shaleen Agrawal
1226d14b06 sched: walt: Improve FEEC energy variable nomenclature
We are using the terms "prev_delta" and "best_delta" to represent energy
consumption values. Change to "prev_energy" and "best_energy" to reflect
the same.

Change-Id: Ie63e3029c3be6ee5e8cc12867d690b0fc708416f
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:02 -07:00
Shaleen Agrawal
c79c755853 sched: walt: Shift boost status of current task
We check if the current task running on the CPU has the highest per task
boost to avoid placing task on said CPU. However, if the CPU is idle,
then this check becomes unnecessary.

Change-Id: I257df862ee2b344c0c602f36f254b38f61b78e55
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:01 -07:00
Shaleen Agrawal
4bc53e5700 sched: walt: Move spare_cap calculation
spare_cap is being calculated prior to idle_cpu evaluation. If an idle
cpu is found, then we have no need to go through this operation. As
such, move the computation to after idle cpu evaluation.

Change-Id: I86ff39909f2f0cb096ac39d02b6171838c257357
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:50:00 -07:00
Shaleen Agrawal
c87f1e133c sched: walt: remove extra function call
In FBT, we are making an additional call to uclamp_task_util while we
have already cached that value in a local variable. Use the cached value
instead of calling the function again.

Change-Id: I05828f02570056309256907aa7fee1396134706a
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
2022-06-28 18:49:59 -07:00
Stephen Dickey
f7fe6d6749 sched/walt: add rt_time to dump_throttled_rt_tasks
Add rq->rt.rt_time to debug output to better track the accumulated
time that exceeded runtime. This will allow us to have a better
understanding of the decision made to throttle RT threads.

Change-Id: Icd8bc43583bddd61019f0d7f73a2315a8103d94a
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:49:58 -07:00
Stephen Dickey
8237cc8693 sched/walt: null ptr dereference fix in walt_lb_active_migration
It is possible that wrq->push_task is null but
walt_lb_active_migration assumes it is non-null. Local variable
push_task is used after copying the value, and can be dereferenced.

Update walt_lb_active_migration to safely check push_task, and
ensure that the active migration flag is cleared.

Change-Id: I3b555430f1ba940053756fcbf2cca5c7d19de9fb
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:49:55 -07:00
Stephen Dickey
fe4c36c11b sched/walt: core_ctl init out of order
core_ctl is launching a kthread which uses a spinlock, prior
to initializing the spinlock.  This creates a race, and a lockup.

Change-Id: I170a77addc6e4c2cc90b6683b50723008760f2f4
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2022-06-28 18:49:52 -07:00
Pavankumar Kondeti
91bd0dce3b sched/walt: Read sysctl_sched_ravg_window_nr_ticks under mutex
When sched_ravg_window_nr_ticks tunable is read and write concurrently,
the read can return the previous value though the write is already
happened. Fix this by reading the sysctl_sched_ravg_window_nr_ticks
value under mutex.

Change-Id: Ie1146c47ac1a184fc8bf4a2824bf6db28fd7156d
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:49:51 -07:00
Pavankumar Kondeti
960f8d4f0f sched/walt: Remove unused sched_dynamic_ravg_window_enable tunable
sched_dynamic_ravg_window_enable tunable is not currently used. If 0
is written to this tunable, the dynamic window size feature is disabled
in the kernel which results in bad performance. So remove this unused
tunable.

Change-Id: I64282146e526f98d049be25502ef638f538b0496
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:49:50 -07:00
Pavankumar Kondeti
60dadb8382 sched/walt: sched_task_util trace point updates
As part of reducing the arguments to sched_task_util trace point,
remove is_rtg argument as well. It can be retrieved from task_struct.

The recent update to this trace point made walt_get_rtg_status()
an extern function. Move it to a header file and restore the inline
functionality.

Change-Id: If447600fd9835e3b78724eb7a94b87c79090fe7f
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2022-06-28 18:49:49 -07:00
Sai Harshini Nimmala
5e62bc10d0 sched/walt: Modify sched_task_util tracepoint
Reduce redundant parameters passed to sched_task_util tracepoint
by invoking relevant functions that return these values during
runtime.

Change-Id: Ie146a5a7a2ac6e4879115f49d4ccc6f7dcadcb52
Signed-off-by: Sai Harshini Nimmala <snimmala@codeaurora.org>
2022-06-28 18:49:47 -07:00