Re: [PATCH] sched/core: Remove double update_rq_clock() in __set_cpus_allowed_ptr_locked()

From: K Prateek Nayak

Date: Thu Oct 30 2025 - 00:04:10 EST


Hello Hao,

On 10/29/2025 3:06 PM, Hao Jia wrote:
> From: Hao Jia <jiahao1@xxxxxxxxxxx>
>
> Since commit d4c64207b88a ("sched: Cleanup the sched_change NOCLOCK usage"),
> update_rq_clock() is called in do_set_cpus_allowed() -> sched_change_begin()
> to update the rq clock. This results in a duplicate call update_rq_clock()
> in __set_cpus_allowed_ptr_locked().
>
> While holding the rq lock and before calling do_set_cpus_allowed(),
> there is nothing that depends on an updated rq_clock.

I couldn't spot any dependency on rq_clock() until do_set_cpus_allowed()
either so please feel free to include:

Reviewed-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>

--
Thanks and Regards,
Prateek

>
> Therefore, remove the redundant update_rq_clock() in
> __set_cpus_allowed_ptr_locked() to avoid the warning about double
> rq clock updates.
>
> Fixes: d4c64207b88a ("sched: Cleanup the sched_change NOCLOCK usage")
> Signed-off-by: Hao Jia <jiahao1@xxxxxxxxxxx>
> ---
> kernel/sched/core.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 1842285eac1e..1123cd0ddffb 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2999,8 +2999,6 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
> unsigned int dest_cpu;
> int ret = 0;
>
> - update_rq_clock(rq);
> -
> if (kthread || is_migration_disabled(p)) {
> /*
> * Kernel threads are allowed on online && !active CPUs,