Messages in this thread | | | Date | Thu, 11 May 2023 12:05:23 +0800 | Subject | Re: [External] Re: [PATCH v2 2/2] sched/core: Avoid double calling update_rq_clock() | From | Hao Jia <> |
| |
On 2023/5/10 Peter Zijlstra wrote: > On Wed, May 10, 2023 at 04:34:50PM +0800, Hao Jia wrote:
>> For the __balance_push_cpu_stop() case, we remove update_rq_clock() from >> the __migrate_task() function to avoid double updating the rq clock. >> And in order to avoid missing rq clock update, add update_rq_clock() >> call before migration_cpu_stop() calls __migrate_task(). >> >> For the unthrottle_cfs_rq() case, we use rq_clock_start_loop_update() to >> prevent multiple calls to update_rq_clock() in unthrottle_cfs_rq(). >> >> Note that the rq clock has been updated before the set_rq_offline() >> function runs, so we don't need to call update_rq_clock() in >> unthrottle_offline_cfs_rqs(). > > This reads like 3 separate issues -- in which case this ought to be 3 > separate patches.
I will do it in the next version.
Thanks, Hao
> > >> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h >> index ec7b3e0a2b20..9c712f29e5a4 100644 >> --- a/kernel/sched/sched.h >> +++ b/kernel/sched/sched.h >> @@ -1536,6 +1536,27 @@ static inline void rq_clock_skip_update(struct rq *rq) >> rq->clock_update_flags |= RQCF_REQ_SKIP; >> } >> >> +/* >> + * During cpu offlining and rq wide unthrottling, we can trigger >> + * an update_rq_clock() for several cfs and rt runqueues (Typically >> + * when using list_for_each_entry_*) >> + * rq_clock_start_loop_update() can be called after updating the clock >> + * once and before iterating over the list to prevent multiple update. >> + * After the iterative traversal, we need to call rq_clock_stop_loop_update() >> + * to restore rq->clock_update_flags. > ^^^^^^^ >> + */ >> +static inline void rq_clock_start_loop_update(struct rq *rq) >> +{ >> + lockdep_assert_rq_held(rq); >> + rq->clock_update_flags |= RQCF_ACT_SKIP; >> +} >> + >> +static inline void rq_clock_stop_loop_update(struct rq *rq) >> +{ >> + lockdep_assert_rq_held(rq); >> + rq->clock_update_flags &= ~RQCF_ACT_SKIP; >> +} > > This does not restore the flag, it clears the flag.
Thanks for your review. I will also modify it in the next version.
Thanks, Hao
| |