Skip to contentSkip to conversation

sched/core: Remove double update_rq_clock() in __set_cpus_allowed_ptr_locked()

PATCH Applied Hao Jia 4 participants 4 messages Oct 29, 2025 – Nov 11, 2025 Scheduler

lore
Share & tools
lore

Hao Jia

author
#0 lore raw

PATCH 1/1 sched/core: Remove double update_rq_clock() in __set_cpus_allowed_ptr_locked()

From: Hao Jia <[email protected]>

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.

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")
---
 kernel/sched/core.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/core.c +0 -2
index 1842285eac1e..1123cd0ddffb 100644
@@ -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,
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hello Hao,

Quoted 9 lines · Hao Jia

From: Hao Jia <[email protected]>

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:

Signature · 2 lines
Thanks and Regards,
Prateek
Quoted 24 lines

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")
---
 kernel/sched/core.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/core.c +0 -2
index 1842285eac1e..1123cd0ddffb 100644
@@ -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,
maintainer
#2 lore raw
Quoted 10 lines · K Prateek Nayak

Hello Hao,

Quoted 7 lines · Hao Jia

From: Hao Jia <[email protected]>

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().

Quoted 7 lines
Quoted 2 lines

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:

Indeed, thanks!

merge bot Applied
#3 lore raw
In reply to Hao Jia
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     e40cea333e60c548e047eaddec6ca48c6632424b
Gitweb:        https://git.kernel.org/tip/e40cea333e60c548e047eaddec6ca48c6632424b
Author:        Hao Jia <[email protected]>
AuthorDate:    Wed, 29 Oct 2025 17:36:55 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 11 Nov 2025 12:33:38 +01:00

sched/core: Remove double update_rq_clock() in __set_cpus_allowed_ptr_locked()

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.

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")
---
 kernel/sched/core.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/core.c +0 -2
index 67b5f2f..68f19aa 100644
@@ -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,