* [PATCHv2] cpufreq/schedutil: Only bind threads if needed
@ 2024-09-27 8:59 Christian Loehle
2024-10-01 10:01 ` Viresh Kumar
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Christian Loehle @ 2024-09-27 8:59 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki, Juri Lelli
Cc: Qais Yousef, Vincent Guittot, linux-kernel@vger.kernel.org,
linux-pm, Peter Zijlstra, Dietmar Eggemann, Pierre Gondois
Remove the unconditional binding of sugov kthreads to the affected CPUs
if the cpufreq driver indicates that updates can happen from any CPU.
This allows userspace to set affinities to either save power (waking up
bigger CPUs on HMP can be expensive) or increasing performance (by
letting the utilized CPUs run without preemption of the sugov kthread).
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
- v2: Add comment for the dl_task_check_affinity return (Juri)
v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/
kernel/sched/cpufreq_schedutil.c | 6 +++++-
kernel/sched/syscalls.c | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index c6ba15388ea7..10faab849a3e 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -691,7 +691,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
}
sg_policy->thread = thread;
- kthread_bind_mask(thread, policy->related_cpus);
+ if (policy->dvfs_possible_from_any_cpu)
+ set_cpus_allowed_ptr(thread, policy->related_cpus);
+ else
+ kthread_bind_mask(thread, policy->related_cpus);
+
init_irq_work(&sg_policy->irq_work, sugov_irq_work);
mutex_init(&sg_policy->work_lock);
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index aa70beee9895..2ef1cb8626bc 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -1172,6 +1172,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask)
if (!task_has_dl_policy(p) || !dl_bandwidth_enabled())
return 0;
+ /*
+ * The special/sugov task isn't part of regular bandwidth/admission
+ * control so let userspace change affinities.
+ */
+ if (dl_entity_is_special(&p->dl))
+ return 0;
+
/*
* Since bandwidth control happens on root_domain basis,
* if admission test is enabled, we only admit -deadline
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-09-27 8:59 [PATCHv2] cpufreq/schedutil: Only bind threads if needed Christian Loehle
@ 2024-10-01 10:01 ` Viresh Kumar
2024-10-01 10:14 ` Vincent Guittot
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2024-10-01 10:01 UTC (permalink / raw)
To: Christian Loehle
Cc: Rafael J. Wysocki, Juri Lelli, Qais Yousef, Vincent Guittot,
linux-kernel@vger.kernel.org, linux-pm, Peter Zijlstra,
Dietmar Eggemann, Pierre Gondois
On 27-09-24, 09:59, Christian Loehle wrote:
> Remove the unconditional binding of sugov kthreads to the affected CPUs
> if the cpufreq driver indicates that updates can happen from any CPU.
> This allows userspace to set affinities to either save power (waking up
> bigger CPUs on HMP can be expensive) or increasing performance (by
> letting the utilized CPUs run without preemption of the sugov kthread).
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
> ---
> - v2: Add comment for the dl_task_check_affinity return (Juri)
> v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/
>
> kernel/sched/cpufreq_schedutil.c | 6 +++++-
> kernel/sched/syscalls.c | 7 +++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-09-27 8:59 [PATCHv2] cpufreq/schedutil: Only bind threads if needed Christian Loehle
2024-10-01 10:01 ` Viresh Kumar
@ 2024-10-01 10:14 ` Vincent Guittot
2024-10-01 18:31 ` Rafael J. Wysocki
2024-10-07 13:40 ` Juri Lelli
3 siblings, 0 replies; 8+ messages in thread
From: Vincent Guittot @ 2024-10-01 10:14 UTC (permalink / raw)
To: Christian Loehle
Cc: Viresh Kumar, Rafael J. Wysocki, Juri Lelli, Qais Yousef,
linux-kernel@vger.kernel.org, linux-pm, Peter Zijlstra,
Dietmar Eggemann, Pierre Gondois
On Fri, 27 Sept 2024 at 10:59, Christian Loehle
<christian.loehle@arm.com> wrote:
>
> Remove the unconditional binding of sugov kthreads to the affected CPUs
> if the cpufreq driver indicates that updates can happen from any CPU.
> This allows userspace to set affinities to either save power (waking up
> bigger CPUs on HMP can be expensive) or increasing performance (by
> letting the utilized CPUs run without preemption of the sugov kthread).
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> - v2: Add comment for the dl_task_check_affinity return (Juri)
> v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/
>
> kernel/sched/cpufreq_schedutil.c | 6 +++++-
> kernel/sched/syscalls.c | 7 +++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index c6ba15388ea7..10faab849a3e 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -691,7 +691,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
> }
>
> sg_policy->thread = thread;
> - kthread_bind_mask(thread, policy->related_cpus);
> + if (policy->dvfs_possible_from_any_cpu)
> + set_cpus_allowed_ptr(thread, policy->related_cpus);
> + else
> + kthread_bind_mask(thread, policy->related_cpus);
> +
> init_irq_work(&sg_policy->irq_work, sugov_irq_work);
> mutex_init(&sg_policy->work_lock);
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index aa70beee9895..2ef1cb8626bc 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -1172,6 +1172,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask)
> if (!task_has_dl_policy(p) || !dl_bandwidth_enabled())
> return 0;
>
> + /*
> + * The special/sugov task isn't part of regular bandwidth/admission
> + * control so let userspace change affinities.
> + */
> + if (dl_entity_is_special(&p->dl))
> + return 0;
> +
> /*
> * Since bandwidth control happens on root_domain basis,
> * if admission test is enabled, we only admit -deadline
> --
> 2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-09-27 8:59 [PATCHv2] cpufreq/schedutil: Only bind threads if needed Christian Loehle
2024-10-01 10:01 ` Viresh Kumar
2024-10-01 10:14 ` Vincent Guittot
@ 2024-10-01 18:31 ` Rafael J. Wysocki
2024-10-07 10:42 ` Christian Loehle
2024-10-07 13:40 ` Juri Lelli
3 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2024-10-01 18:31 UTC (permalink / raw)
To: Christian Loehle
Cc: Viresh Kumar, Rafael J. Wysocki, Juri Lelli, Qais Yousef,
Vincent Guittot, linux-kernel@vger.kernel.org, linux-pm,
Peter Zijlstra, Dietmar Eggemann, Pierre Gondois
On Fri, Sep 27, 2024 at 10:59 AM Christian Loehle
<christian.loehle@arm.com> wrote:
>
> Remove the unconditional binding of sugov kthreads to the affected CPUs
> if the cpufreq driver indicates that updates can happen from any CPU.
> This allows userspace to set affinities to either save power (waking up
> bigger CPUs on HMP can be expensive) or increasing performance (by
> letting the utilized CPUs run without preemption of the sugov kthread).
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
and I'm assuming that this will go in via tip.
> ---
> - v2: Add comment for the dl_task_check_affinity return (Juri)
> v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/
>
> kernel/sched/cpufreq_schedutil.c | 6 +++++-
> kernel/sched/syscalls.c | 7 +++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index c6ba15388ea7..10faab849a3e 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -691,7 +691,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
> }
>
> sg_policy->thread = thread;
> - kthread_bind_mask(thread, policy->related_cpus);
> + if (policy->dvfs_possible_from_any_cpu)
> + set_cpus_allowed_ptr(thread, policy->related_cpus);
> + else
> + kthread_bind_mask(thread, policy->related_cpus);
> +
> init_irq_work(&sg_policy->irq_work, sugov_irq_work);
> mutex_init(&sg_policy->work_lock);
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index aa70beee9895..2ef1cb8626bc 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -1172,6 +1172,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask)
> if (!task_has_dl_policy(p) || !dl_bandwidth_enabled())
> return 0;
>
> + /*
> + * The special/sugov task isn't part of regular bandwidth/admission
> + * control so let userspace change affinities.
> + */
> + if (dl_entity_is_special(&p->dl))
> + return 0;
> +
> /*
> * Since bandwidth control happens on root_domain basis,
> * if admission test is enabled, we only admit -deadline
> --
> 2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-10-01 18:31 ` Rafael J. Wysocki
@ 2024-10-07 10:42 ` Christian Loehle
2024-10-24 9:13 ` Christian Loehle
0 siblings, 1 reply; 8+ messages in thread
From: Christian Loehle @ 2024-10-07 10:42 UTC (permalink / raw)
To: Rafael J. Wysocki, Peter Zijlstra, Juri Lelli
Cc: Viresh Kumar, Qais Yousef, Vincent Guittot,
linux-kernel@vger.kernel.org, linux-pm, Dietmar Eggemann,
Pierre Gondois
On 10/1/24 19:31, Rafael J. Wysocki wrote:
> On Fri, Sep 27, 2024 at 10:59 AM Christian Loehle
> <christian.loehle@arm.com> wrote:
>>
>> Remove the unconditional binding of sugov kthreads to the affected CPUs
>> if the cpufreq driver indicates that updates can happen from any CPU.
>> This allows userspace to set affinities to either save power (waking up
>> bigger CPUs on HMP can be expensive) or increasing performance (by
>> letting the utilized CPUs run without preemption of the sugov kthread).
>>
>> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
>
> Acked-by: Rafael J. Wysocki <rafael@kernel.org>
>
> and I'm assuming that this will go in via tip.
Peter, is that fine with you?
@Juri: I didn't add your (somewhat implied?) ACK on v2, so I'd be happy to
get it on the dl_task_check_affinity() part.
Regards,
Christian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-09-27 8:59 [PATCHv2] cpufreq/schedutil: Only bind threads if needed Christian Loehle
` (2 preceding siblings ...)
2024-10-01 18:31 ` Rafael J. Wysocki
@ 2024-10-07 13:40 ` Juri Lelli
3 siblings, 0 replies; 8+ messages in thread
From: Juri Lelli @ 2024-10-07 13:40 UTC (permalink / raw)
To: Christian Loehle
Cc: Viresh Kumar, Rafael J. Wysocki, Qais Yousef, Vincent Guittot,
linux-kernel@vger.kernel.org, linux-pm, Peter Zijlstra,
Dietmar Eggemann, Pierre Gondois
Hi,
On 27/09/24 09:59, Christian Loehle wrote:
> Remove the unconditional binding of sugov kthreads to the affected CPUs
> if the cpufreq driver indicates that updates can happen from any CPU.
> This allows userspace to set affinities to either save power (waking up
> bigger CPUs on HMP can be expensive) or increasing performance (by
> letting the utilized CPUs run without preemption of the sugov kthread).
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
> ---
> - v2: Add comment for the dl_task_check_affinity return (Juri)
> v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/
>
> kernel/sched/cpufreq_schedutil.c | 6 +++++-
> kernel/sched/syscalls.c | 7 +++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index c6ba15388ea7..10faab849a3e 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -691,7 +691,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
> }
>
> sg_policy->thread = thread;
> - kthread_bind_mask(thread, policy->related_cpus);
> + if (policy->dvfs_possible_from_any_cpu)
> + set_cpus_allowed_ptr(thread, policy->related_cpus);
> + else
> + kthread_bind_mask(thread, policy->related_cpus);
> +
> init_irq_work(&sg_policy->irq_work, sugov_irq_work);
> mutex_init(&sg_policy->work_lock);
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index aa70beee9895..2ef1cb8626bc 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -1172,6 +1172,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask)
> if (!task_has_dl_policy(p) || !dl_bandwidth_enabled())
> return 0;
>
> + /*
> + * The special/sugov task isn't part of regular bandwidth/admission
> + * control so let userspace change affinities.
> + */
> + if (dl_entity_is_special(&p->dl))
> + return 0;
> +
> /*
> * Since bandwidth control happens on root_domain basis,
> * if admission test is enabled, we only admit -deadline
For the DEADLINE related bits,
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Thanks,
Juri
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-10-07 10:42 ` Christian Loehle
@ 2024-10-24 9:13 ` Christian Loehle
2024-10-31 14:59 ` Christian Loehle
0 siblings, 1 reply; 8+ messages in thread
From: Christian Loehle @ 2024-10-24 9:13 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Viresh Kumar, Qais Yousef, Vincent Guittot,
linux-kernel@vger.kernel.org, linux-pm, Dietmar Eggemann,
Pierre Gondois, Juri Lelli, Vincent Guittot
On 10/7/24 11:42, Christian Loehle wrote:
> On 10/1/24 19:31, Rafael J. Wysocki wrote:
>> On Fri, Sep 27, 2024 at 10:59 AM Christian Loehle
>> <christian.loehle@arm.com> wrote:
>>>
>>> Remove the unconditional binding of sugov kthreads to the affected CPUs
>>> if the cpufreq driver indicates that updates can happen from any CPU.
>>> This allows userspace to set affinities to either save power (waking up
>>> bigger CPUs on HMP can be expensive) or increasing performance (by
>>> letting the utilized CPUs run without preemption of the sugov kthread).
>>>
>>> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
>>
>> Acked-by: Rafael J. Wysocki <rafael@kernel.org>
>>
>> and I'm assuming that this will go in via tip.
>
> Peter, is that fine with you?
>
> @Juri: I didn't add your (somewhat implied?) ACK on v2, so I'd be happy to
> get it on the dl_task_check_affinity() part.
>
Peter,
gentle ping on this.
Thank you.
Regards,
Christian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2] cpufreq/schedutil: Only bind threads if needed
2024-10-24 9:13 ` Christian Loehle
@ 2024-10-31 14:59 ` Christian Loehle
0 siblings, 0 replies; 8+ messages in thread
From: Christian Loehle @ 2024-10-31 14:59 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Viresh Kumar, Qais Yousef, Vincent Guittot,
linux-kernel@vger.kernel.org, linux-pm, Dietmar Eggemann,
Pierre Gondois, Juri Lelli
On 10/24/24 10:13, Christian Loehle wrote:
> On 10/7/24 11:42, Christian Loehle wrote:
>> On 10/1/24 19:31, Rafael J. Wysocki wrote:
>>> On Fri, Sep 27, 2024 at 10:59 AM Christian Loehle
>>> <christian.loehle@arm.com> wrote:
>>>>
>>>> Remove the unconditional binding of sugov kthreads to the affected CPUs
>>>> if the cpufreq driver indicates that updates can happen from any CPU.
>>>> This allows userspace to set affinities to either save power (waking up
>>>> bigger CPUs on HMP can be expensive) or increasing performance (by
>>>> letting the utilized CPUs run without preemption of the sugov kthread).
>>>>
>>>> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
>>>
>>> Acked-by: Rafael J. Wysocki <rafael@kernel.org>
>>>
>>> and I'm assuming that this will go in via tip.
>>
>> Peter, is that fine with you?
>>
>> @Juri: I didn't add your (somewhat implied?) ACK on v2, so I'd be happy to
>> get it on the dl_task_check_affinity() part.
>>
>
> Peter,
> gentle ping on this.
> Thank you.
Hi Peter,
Another gentle ping.
The accumulated ACKs are:
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Regards,
Christian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-10-31 14:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27 8:59 [PATCHv2] cpufreq/schedutil: Only bind threads if needed Christian Loehle
2024-10-01 10:01 ` Viresh Kumar
2024-10-01 10:14 ` Vincent Guittot
2024-10-01 18:31 ` Rafael J. Wysocki
2024-10-07 10:42 ` Christian Loehle
2024-10-24 9:13 ` Christian Loehle
2024-10-31 14:59 ` Christian Loehle
2024-10-07 13:40 ` Juri Lelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox