[PATCH 1/2] sched/deadline: use online cpus for validating runtime

Shrikanth Hegde posted 2 patches 2 months ago
[PATCH 1/2] sched/deadline: use online cpus for validating runtime
Posted by Shrikanth Hegde 2 months ago
ftrace selftest reported failure since writing -1 to sched_rt_runtime_us
return -EBUSY. This happens when the possible CPUs is different than
the active CPUS.

Active CPUs are part of one root domain, while remaining CPUs are part
of def_root_domain. Since active cpumask is being used, this results in
cpus=0 when a non active CPUs is used in the loop.

Fix it by looping over the online CPUs instead for validation the
bandwidth calculations.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 2d0f571f95e9..7ea9c040c72f 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3187,7 +3187,7 @@ int sched_dl_global_validate(void)
 	 * value smaller than the currently allocated bandwidth in
 	 * any of the root_domains.
 	 */
-	for_each_possible_cpu(cpu) {
+	for_each_online_cpu(cpu) {
 		rcu_read_lock_sched();
 
 		if (dl_bw_visited(cpu, gen))
-- 
2.39.3
Re: [PATCH 1/2] sched/deadline: use online cpus for validating runtime
Posted by Juri Lelli 2 months ago
Hi!

On 06/03/25 10:59, Shrikanth Hegde wrote:
> ftrace selftest reported failure since writing -1 to sched_rt_runtime_us
> return -EBUSY. This happens when the possible CPUs is different than
> the active CPUS.
> 
> Active CPUs are part of one root domain, while remaining CPUs are part
> of def_root_domain. Since active cpumask is being used, this results in
> cpus=0 when a non active CPUs is used in the loop.
> 
> Fix it by looping over the online CPUs instead for validation the
> bandwidth calculations.
> 
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  kernel/sched/deadline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 2d0f571f95e9..7ea9c040c72f 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -3187,7 +3187,7 @@ int sched_dl_global_validate(void)
>  	 * value smaller than the currently allocated bandwidth in
>  	 * any of the root_domains.
>  	 */
> -	for_each_possible_cpu(cpu) {
> +	for_each_online_cpu(cpu) {
>  		rcu_read_lock_sched();
>  
>  		if (dl_bw_visited(cpu, gen))
> -- 

Makes sense to me.

Acked-by: Juri Lelli <juri.lelli@redhat.com>

Thanks,
Juri
[tip: sched/urgent] sched/deadline: Use online cpus for validating runtime
Posted by tip-bot2 for Shrikanth Hegde 2 months ago
The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     14672f059d83f591afb2ee1fff56858efe055e5a
Gitweb:        https://git.kernel.org/tip/14672f059d83f591afb2ee1fff56858efe055e5a
Author:        Shrikanth Hegde <sshegde@linux.ibm.com>
AuthorDate:    Thu, 06 Mar 2025 10:59:53 +05:30
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 06 Mar 2025 10:21:31 +01:00

sched/deadline: Use online cpus for validating runtime

The ftrace selftest reported a failure because writing -1 to
sched_rt_runtime_us returns -EBUSY. This happens when the possible
CPUs are different from active CPUs.

Active CPUs are part of one root domain, while remaining CPUs are part
of def_root_domain. Since active cpumask is being used, this results in
cpus=0 when a non active CPUs is used in the loop.

Fix it by looping over the online CPUs instead for validating the
bandwidth calculations.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://lore.kernel.org/r/20250306052954.452005-2-sshegde@linux.ibm.com
---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 38e4537..ff4df16 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3189,7 +3189,7 @@ int sched_dl_global_validate(void)
 	 * value smaller than the currently allocated bandwidth in
 	 * any of the root_domains.
 	 */
-	for_each_possible_cpu(cpu) {
+	for_each_online_cpu(cpu) {
 		rcu_read_lock_sched();
 
 		if (dl_bw_visited(cpu, gen))