* [PATCH] tick/nohz: Make the idle_exittime update correctly @ 2020-12-05 9:41 Yunfeng Ye 2020-12-15 12:06 ` Yunfeng Ye 2021-02-19 12:33 ` Frederic Weisbecker 0 siblings, 2 replies; 7+ messages in thread From: Yunfeng Ye @ 2020-12-05 9:41 UTC (permalink / raw) To: fweisbec, tglx, mingo, linux-kernel; +Cc: Shiyuan Hu, Hewenliang The idle_exittime field of tick_sched is used to record the time when the idle state was left. but currently the idle_exittime is updated in the function tick_nohz_restart_sched_tick(), which is not always in idle state when nohz_full is configured. tick_irq_exit tick_nohz_irq_exit tick_nohz_full_update_tick tick_nohz_restart_sched_tick ts->idle_exittime = now; So move to tick_nohz_stop_idle() to make the idle_exittime update correctly. Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> --- kernel/time/tick-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 749ec2a583de..be2e5d772d50 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) { update_ts_time_stats(smp_processor_id(), ts, now, NULL); ts->idle_active = 0; + ts->idle_exittime = now; sched_clock_idle_wakeup_event(); } @@ -901,7 +902,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) * Cancel the scheduled timer and restore the tick */ ts->tick_stopped = 0; - ts->idle_exittime = now; tick_nohz_restart(ts, now); } -- 2.18.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-05 9:41 [PATCH] tick/nohz: Make the idle_exittime update correctly Yunfeng Ye @ 2020-12-15 12:06 ` Yunfeng Ye 2020-12-15 14:47 ` Frederic Weisbecker 2021-02-19 12:33 ` Frederic Weisbecker 1 sibling, 1 reply; 7+ messages in thread From: Yunfeng Ye @ 2020-12-15 12:06 UTC (permalink / raw) To: fweisbec, tglx, mingo, linux-kernel; +Cc: Shiyuan Hu, Hewenliang The idle_exittime field of tick_sched is used to record the time when the idle state was left. but currently the idle_exittime is updated in the function tick_nohz_restart_sched_tick(), which is not always in idle state when nohz_full is configured. tick_irq_exit tick_nohz_irq_exit tick_nohz_full_update_tick tick_nohz_restart_sched_tick ts->idle_exittime = now; So move to tick_nohz_stop_idle() to make the idle_exittime update correctly. Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> --- kernel/time/tick-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 749ec2a583de..be2e5d772d50 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) { update_ts_time_stats(smp_processor_id(), ts, now, NULL); ts->idle_active = 0; + ts->idle_exittime = now; sched_clock_idle_wakeup_event(); } @@ -901,7 +902,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) * Cancel the scheduled timer and restore the tick */ ts->tick_stopped = 0; - ts->idle_exittime = now; tick_nohz_restart(ts, now); } -- 2.18.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-15 12:06 ` Yunfeng Ye @ 2020-12-15 14:47 ` Frederic Weisbecker 2020-12-17 6:51 ` Yunfeng Ye 0 siblings, 1 reply; 7+ messages in thread From: Frederic Weisbecker @ 2020-12-15 14:47 UTC (permalink / raw) To: Yunfeng Ye; +Cc: fweisbec, tglx, mingo, linux-kernel, Shiyuan Hu, Hewenliang On Tue, Dec 15, 2020 at 08:06:34PM +0800, Yunfeng Ye wrote: > The idle_exittime field of tick_sched is used to record the time when > the idle state was left. but currently the idle_exittime is updated in > the function tick_nohz_restart_sched_tick(), which is not always in idle > state when nohz_full is configured. > > tick_irq_exit > tick_nohz_irq_exit > tick_nohz_full_update_tick > tick_nohz_restart_sched_tick > ts->idle_exittime = now; > > So move to tick_nohz_stop_idle() to make the idle_exittime update > correctly. > > Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> > --- > kernel/time/tick-sched.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index 749ec2a583de..be2e5d772d50 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) > { > update_ts_time_stats(smp_processor_id(), ts, now, NULL); > ts->idle_active = 0; > + ts->idle_exittime = now; This changes a bit the meaning of idle_exittime then since this is also called from idle interrupt entry. __tick_nohz_idle_restart_tick() would be a better place. Thanks. > > sched_clock_idle_wakeup_event(); > } > @@ -901,7 +902,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) > * Cancel the scheduled timer and restore the tick > */ > ts->tick_stopped = 0; > - ts->idle_exittime = now; > > tick_nohz_restart(ts, now); > } > -- > 2.18.4 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-15 14:47 ` Frederic Weisbecker @ 2020-12-17 6:51 ` Yunfeng Ye 2020-12-17 13:59 ` Frederic Weisbecker 0 siblings, 1 reply; 7+ messages in thread From: Yunfeng Ye @ 2020-12-17 6:51 UTC (permalink / raw) To: Frederic Weisbecker Cc: fweisbec, tglx, mingo, linux-kernel, Shiyuan Hu, Hewenliang On 2020/12/15 22:47, Frederic Weisbecker wrote: > On Tue, Dec 15, 2020 at 08:06:34PM +0800, Yunfeng Ye wrote: >> The idle_exittime field of tick_sched is used to record the time when >> the idle state was left. but currently the idle_exittime is updated in >> the function tick_nohz_restart_sched_tick(), which is not always in idle >> state when nohz_full is configured. >> >> tick_irq_exit >> tick_nohz_irq_exit >> tick_nohz_full_update_tick >> tick_nohz_restart_sched_tick >> ts->idle_exittime = now; >> >> So move to tick_nohz_stop_idle() to make the idle_exittime update >> correctly. >> >> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> >> --- >> kernel/time/tick-sched.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c >> index 749ec2a583de..be2e5d772d50 100644 >> --- a/kernel/time/tick-sched.c >> +++ b/kernel/time/tick-sched.c >> @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) >> { >> update_ts_time_stats(smp_processor_id(), ts, now, NULL); >> ts->idle_active = 0; >> + ts->idle_exittime = now; > > This changes a bit the meaning of idle_exittime then since this is also called > from idle interrupt entry. > > __tick_nohz_idle_restart_tick() would be a better place. > So is it necessary to modify the comment "@idle_exittime: Time when the idle state was left" ? On the other hand, if the patch "nohz: Update tick instead of restarting tick in tick_nohz_idle_exit()" (https://www.spinics.net/lists/kernel/msg3747039.html ) applied, __tick_nohz_idle_restart_tick will not be called always, So is it put here also a better place? Thanks. > Thanks. > >> >> sched_clock_idle_wakeup_event(); >> } >> @@ -901,7 +902,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) >> * Cancel the scheduled timer and restore the tick >> */ >> ts->tick_stopped = 0; >> - ts->idle_exittime = now; >> >> tick_nohz_restart(ts, now); >> } >> -- >> 2.18.4 >> > . > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-17 6:51 ` Yunfeng Ye @ 2020-12-17 13:59 ` Frederic Weisbecker 2020-12-18 0:54 ` Yunfeng Ye 0 siblings, 1 reply; 7+ messages in thread From: Frederic Weisbecker @ 2020-12-17 13:59 UTC (permalink / raw) To: Yunfeng Ye; +Cc: fweisbec, tglx, mingo, linux-kernel, Shiyuan Hu, Hewenliang On Thu, Dec 17, 2020 at 02:51:58PM +0800, Yunfeng Ye wrote: > > > On 2020/12/15 22:47, Frederic Weisbecker wrote: > > On Tue, Dec 15, 2020 at 08:06:34PM +0800, Yunfeng Ye wrote: > >> The idle_exittime field of tick_sched is used to record the time when > >> the idle state was left. but currently the idle_exittime is updated in > >> the function tick_nohz_restart_sched_tick(), which is not always in idle > >> state when nohz_full is configured. > >> > >> tick_irq_exit > >> tick_nohz_irq_exit > >> tick_nohz_full_update_tick > >> tick_nohz_restart_sched_tick > >> ts->idle_exittime = now; > >> > >> So move to tick_nohz_stop_idle() to make the idle_exittime update > >> correctly. > >> > >> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> > >> --- > >> kernel/time/tick-sched.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > >> index 749ec2a583de..be2e5d772d50 100644 > >> --- a/kernel/time/tick-sched.c > >> +++ b/kernel/time/tick-sched.c > >> @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) > >> { > >> update_ts_time_stats(smp_processor_id(), ts, now, NULL); > >> ts->idle_active = 0; > >> + ts->idle_exittime = now; > > > > This changes a bit the meaning of idle_exittime then since this is also called > > from idle interrupt entry. > > > > __tick_nohz_idle_restart_tick() would be a better place. > > > So is it necessary to modify the comment "@idle_exittime: Time when the idle state was left" ? > > On the other hand, if the patch "nohz: Update tick instead of restarting tick in tick_nohz_idle_exit()" > (https://www.spinics.net/lists/kernel/msg3747039.html ) applied, __tick_nohz_idle_restart_tick will not > be called always, So is it put here also a better place? Right but I need to re-order some code before. That's ok, I'll integrate this patch inside the changes. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-17 13:59 ` Frederic Weisbecker @ 2020-12-18 0:54 ` Yunfeng Ye 0 siblings, 0 replies; 7+ messages in thread From: Yunfeng Ye @ 2020-12-18 0:54 UTC (permalink / raw) To: Frederic Weisbecker Cc: fweisbec, tglx, mingo, linux-kernel, Shiyuan Hu, Hewenliang On 2020/12/17 21:59, Frederic Weisbecker wrote: > On Thu, Dec 17, 2020 at 02:51:58PM +0800, Yunfeng Ye wrote: >> >> >> On 2020/12/15 22:47, Frederic Weisbecker wrote: >>> On Tue, Dec 15, 2020 at 08:06:34PM +0800, Yunfeng Ye wrote: >>>> The idle_exittime field of tick_sched is used to record the time when >>>> the idle state was left. but currently the idle_exittime is updated in >>>> the function tick_nohz_restart_sched_tick(), which is not always in idle >>>> state when nohz_full is configured. >>>> >>>> tick_irq_exit >>>> tick_nohz_irq_exit >>>> tick_nohz_full_update_tick >>>> tick_nohz_restart_sched_tick >>>> ts->idle_exittime = now; >>>> >>>> So move to tick_nohz_stop_idle() to make the idle_exittime update >>>> correctly. >>>> >>>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> >>>> --- >>>> kernel/time/tick-sched.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c >>>> index 749ec2a583de..be2e5d772d50 100644 >>>> --- a/kernel/time/tick-sched.c >>>> +++ b/kernel/time/tick-sched.c >>>> @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) >>>> { >>>> update_ts_time_stats(smp_processor_id(), ts, now, NULL); >>>> ts->idle_active = 0; >>>> + ts->idle_exittime = now; >>> >>> This changes a bit the meaning of idle_exittime then since this is also called >>> from idle interrupt entry. >>> >>> __tick_nohz_idle_restart_tick() would be a better place. >>> >> So is it necessary to modify the comment "@idle_exittime: Time when the idle state was left" ? >> >> On the other hand, if the patch "nohz: Update tick instead of restarting tick in tick_nohz_idle_exit()" >> (https://www.spinics.net/lists/kernel/msg3747039.html ) applied, __tick_nohz_idle_restart_tick will not >> be called always, So is it put here also a better place? > > Right but I need to re-order some code before. That's ok, I'll integrate this > patch inside the changes. > Ok, thanks. > Thanks. > . > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tick/nohz: Make the idle_exittime update correctly 2020-12-05 9:41 [PATCH] tick/nohz: Make the idle_exittime update correctly Yunfeng Ye 2020-12-15 12:06 ` Yunfeng Ye @ 2021-02-19 12:33 ` Frederic Weisbecker 1 sibling, 0 replies; 7+ messages in thread From: Frederic Weisbecker @ 2021-02-19 12:33 UTC (permalink / raw) To: Yunfeng Ye; +Cc: fweisbec, tglx, mingo, linux-kernel, Shiyuan Hu, Hewenliang On Sat, Dec 05, 2020 at 05:41:52PM +0800, Yunfeng Ye wrote: > The idle_exittime field of tick_sched is used to record the time when > the idle state was left. but currently the idle_exittime is updated in > the function tick_nohz_restart_sched_tick(), which is not always in idle > state when nohz_full is configured. > > tick_irq_exit > tick_nohz_irq_exit > tick_nohz_full_update_tick > tick_nohz_restart_sched_tick > ts->idle_exittime = now; > > So move to tick_nohz_stop_idle() to make the idle_exittime update > correctly. > > Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> > --- > kernel/time/tick-sched.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index 749ec2a583de..be2e5d772d50 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -591,6 +591,7 @@ static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now) > { > update_ts_time_stats(smp_processor_id(), ts, now, NULL); > ts->idle_active = 0; > + ts->idle_exittime = now; > > sched_clock_idle_wakeup_event(); > } > @@ -901,7 +902,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) > * Cancel the scheduled timer and restore the tick > */ > ts->tick_stopped = 0; > - ts->idle_exittime = now; > > tick_nohz_restart(ts, now); > } Hi, I've edited and queued on top of latest changes, see below. I'll post it after the merge window. --- From: Yunfeng Ye <yeyunfeng@huawei.com> Date: Wed, 10 Feb 2021 00:08:54 +0100 Subject: [PATCH] tick/nohz: Update idle_exittime on actual idle exit The idle_exittime field of tick_sched is used to record the time when the idle state was left. but currently the idle_exittime is updated in the function tick_nohz_restart_sched_tick(), which is not always in idle state when nohz_full is configured: tick_irq_exit tick_nohz_irq_exit tick_nohz_full_update_tick tick_nohz_restart_sched_tick ts->idle_exittime = now; It's thus overwritten by mistake on nohz_full tick restart. Move the update to the appropriate idle exit path instead. Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> --- kernel/time/tick-sched.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 79796286a4ba..2907c762a8fe 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -918,8 +918,6 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now) * Cancel the scheduled timer and restore the tick */ ts->tick_stopped = 0; - ts->idle_exittime = now; - tick_nohz_restart(ts, now); } @@ -1231,6 +1229,7 @@ static void tick_nohz_idle_update_tick(struct tick_sched *ts, ktime_t now) else tick_nohz_restart_sched_tick(ts, now); + ts->idle_exittime = now; tick_nohz_account_idle_ticks(ts); } -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-19 12:33 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-05 9:41 [PATCH] tick/nohz: Make the idle_exittime update correctly Yunfeng Ye 2020-12-15 12:06 ` Yunfeng Ye 2020-12-15 14:47 ` Frederic Weisbecker 2020-12-17 6:51 ` Yunfeng Ye 2020-12-17 13:59 ` Frederic Weisbecker 2020-12-18 0:54 ` Yunfeng Ye 2021-02-19 12:33 ` Frederic Weisbecker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).