* [PATCH v5 0/2] sched: consider missed ticks when updating cpu load
@ 2015-11-10 0:36 byungchul.park
2015-11-10 0:36 ` [PATCH v5 1/2] sched: make __update_cpu_load() handle NOHZ_FULL tickless byungchul.park
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: byungchul.park @ 2015-11-10 0:36 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, efault, tglx, fweisbec, Byungchul Park
From: Byungchul Park <byungchul.park@lge.com>
change from v4 to v5
- fix comments and commit message
- take new_load into account in update_cpu_load_nohz() and __update_cpu_load()
because it's non-zero in NOHZ_FULL
change from v3 to v4
- focus the problem on full NOHZ
change from v2 to v3
- add a patch which make __update_cpu_load() handle active tickless
change from v1 to v2
- add some additional commit message (logic is same exactly)
additionally i tried to use the return value of hrtimer_forward() instead of
jiffies to get pending tick for updating cpu load. it's easy for
update_cpu_load_nohz() to do that. but for update_idle_cpu_load(), i need
more time to think about how to implement it nicely.
and i will try to fix other stuffs caused by full NOHZ later with another
patch. i decided to send this patch at first because "cpu load update" is a
standalone problem which is not coupled with other stuffs.
Byungchul Park (2):
sched: make __update_cpu_load() handle NOHZ_FULL tickless
sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
include/linux/sched.h | 4 ++--
kernel/sched/fair.c | 57 +++++++++++++++++++++++++++++++++++++---------
kernel/time/tick-sched.c | 8 +++----
3 files changed, 52 insertions(+), 17 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 1/2] sched: make __update_cpu_load() handle NOHZ_FULL tickless
2015-11-10 0:36 [PATCH v5 0/2] sched: consider missed ticks when updating cpu load byungchul.park
@ 2015-11-10 0:36 ` byungchul.park
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
2015-11-11 9:38 ` [PATCH v5 0/2] sched: consider missed ticks when updating cpu load Byungchul Park
2 siblings, 0 replies; 9+ messages in thread
From: byungchul.park @ 2015-11-10 0:36 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, efault, tglx, fweisbec, Byungchul Park
From: Byungchul Park <byungchul.park@lge.com>
__update_cpu_load() assumes that a cpu is idle if the interval between
the cpu's ticks is more than 1/HZ. However the cpu can be non-idle even
though the interval is more than 1/HZ, in the NOHZ_FULL case.
Thus in the NOHZ_FULL tickless case, the current way to update cpu load
can be wrong. To update cpu load properly, __update_cpu_load() should be
changed so that it can handle NOHZ_FULL tickless case.
A decaying average can be computed by
load[i]' = (1 - 1/2^i) * load[i] + (1/2^i) * load
Because of NOHZ, it might not get called on every tick which gives need
for the @pending_updates argument.
load[i]_n = (1 - 1/2^i) * load[i]_n-1 + (1/2^i) * load_n-1
= A * load[i]_n-1 + B ; A := (1 - 1/2^i), B := (1/2^i) * load
= A * (A * load[i]_n-2 + B) + B
= A * (A * (A * load[i]_n-3 + B) + B) + B
= A^3 * load[i]_n-3 + (A^2 + A + 1) * B
= A^n * load[i]_0 + (A^(n-1) + A^(n-2) + ... + 1) * B
= A^n * load[i]_0 + ((1 - A^n) / (1 - A)) * B
= (1 - 1/2^i)^n * (load[i]_0 - load) + load
In the above we've assumed load_n := load, which is true for NOHZ_FULL as
any change in load would have resulted in the tick being turned back on.
For regular NOHZ, this reduces to:
load[i]_n = (1 - 1/2^i)^n * load[i]_0
[Commit message and comments become simpler, thanks to Peter Z.]
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/sched/fair.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 077076f..7760678 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4305,14 +4305,46 @@ decay_load_missed(unsigned long load, unsigned long missed_updates, int idx)
return load;
}
-/*
+/**
+ * __update_cpu_load - update the rq->cpu_load[] statistics
+ * @this_rq: The rq to update statistics for
+ * @this_load: The current load
+ * @pending_updates: The number of missed updates
+ * @active: !0 for NOHZ_FULL
+ *
* Update rq->cpu_load[] statistics. This function is usually called every
- * scheduler tick (TICK_NSEC). With tickless idle this will not be called
- * every tick. We fix it up based on jiffies.
+ * scheduler tick (TICK_NSEC).
+ *
+ * This function computes a decaying average:
+ *
+ * load[i]' = (1 - 1/2^i) * load[i] + (1/2^i) * load
+ *
+ * Because of NOHZ it might not get called on every tick which gives need for
+ * the @pending_updates argument.
+ *
+ * load[i]_n = (1 - 1/2^i) * load[i]_n-1 + (1/2^i) * load_n-1
+ * = A * load[i]_n-1 + B ; A := (1 - 1/2^i), B := (1/2^i) * load
+ * = A * (A * load[i]_n-2 + B) + B
+ * = A * (A * (A * load[i]_n-3 + B) + B) + B
+ * = A^3 * load[i]_n-3 + (A^2 + A + 1) * B
+ * = A^n * load[i]_0 + (A^(n-1) + A^(n-2) + ... + 1) * B
+ * = A^n * load[i]_0 + ((1 - A^n) / (1 - A)) * B
+ * = (1 - 1/2^i)^n * (load[i]_0 - load) + load
+ *
+ * In the above we've assumed load_n := load, which is true for NOHZ_FULL as
+ * any change in load would have resulted in the tick being turned back on.
+ *
+ * For regular NOHZ, this reduces to:
+ *
+ * load[i]_n = (1 - 1/2^i)^n * load[i]_0
+ *
+ * see decay_load_misses(). For NOHZ_FULL we get to subtract and add the extra
+ * term. See the @active paramter.
*/
static void __update_cpu_load(struct rq *this_rq, unsigned long this_load,
- unsigned long pending_updates)
+ unsigned long pending_updates, int active)
{
+ unsigned long tickless_load = active ? this_rq->cpu_load[0] : 0;
int i, scale;
this_rq->nr_load_updates++;
@@ -4324,8 +4356,9 @@ static void __update_cpu_load(struct rq *this_rq, unsigned long this_load,
/* scale is effectively 1 << i now, and >> i divides by scale */
- old_load = this_rq->cpu_load[i];
+ old_load = this_rq->cpu_load[i] - tickless_load;
old_load = decay_load_missed(old_load, pending_updates - 1, i);
+ old_load += tickless_load;
new_load = this_load;
/*
* Round up the averaging division if load is increasing. This
@@ -4380,7 +4413,7 @@ static void update_idle_cpu_load(struct rq *this_rq)
pending_updates = curr_jiffies - this_rq->last_load_update_tick;
this_rq->last_load_update_tick = curr_jiffies;
- __update_cpu_load(this_rq, load, pending_updates);
+ __update_cpu_load(this_rq, load, pending_updates, 0);
}
/*
@@ -4403,7 +4436,7 @@ void update_cpu_load_nohz(void)
* We were idle, this means load 0, the current load might be
* !0 due to remote wakeups and the sort.
*/
- __update_cpu_load(this_rq, 0, pending_updates);
+ __update_cpu_load(this_rq, 0, pending_updates, 0);
}
raw_spin_unlock(&this_rq->lock);
}
@@ -4419,7 +4452,7 @@ void update_cpu_load_active(struct rq *this_rq)
* See the mess around update_idle_cpu_load() / update_cpu_load_nohz().
*/
this_rq->last_load_update_tick = jiffies;
- __update_cpu_load(this_rq, load, 1);
+ __update_cpu_load(this_rq, load, 1, 1);
}
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
2015-11-10 0:36 [PATCH v5 0/2] sched: consider missed ticks when updating cpu load byungchul.park
2015-11-10 0:36 ` [PATCH v5 1/2] sched: make __update_cpu_load() handle NOHZ_FULL tickless byungchul.park
@ 2015-11-10 0:36 ` byungchul.park
2015-11-11 9:42 ` Byungchul Park
` (2 more replies)
2015-11-11 9:38 ` [PATCH v5 0/2] sched: consider missed ticks when updating cpu load Byungchul Park
2 siblings, 3 replies; 9+ messages in thread
From: byungchul.park @ 2015-11-10 0:36 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, efault, tglx, fweisbec, Byungchul Park
From: Byungchul Park <byungchul.park@lge.com>
Usually tick can be stopped for an idle cpu in NOHZ. However in NOHZ_FULL,
a non-idle cpu's tick also can be stopped. However, update_cpu_load_nohz()
does not consider the case a non-idle cpu's tick has been stopped at all.
This patch makes the update_cpu_load_nohz() know if the calling path comes
from NOHZ_FULL or idle NOHZ.
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
---
include/linux/sched.h | 4 ++--
kernel/sched/fair.c | 10 ++++++----
kernel/time/tick-sched.c | 8 ++++----
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 699228b..f1b59aa 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -177,9 +177,9 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
extern void calc_global_load(unsigned long ticks);
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
-extern void update_cpu_load_nohz(void);
+extern void update_cpu_load_nohz(int active);
#else
-static inline void update_cpu_load_nohz(void) { }
+static inline void update_cpu_load_nohz(int active) { }
#endif
extern unsigned long get_parent_ip(unsigned long addr);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7760678..3d93756 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4419,10 +4419,11 @@ static void update_idle_cpu_load(struct rq *this_rq)
/*
* Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
*/
-void update_cpu_load_nohz(void)
+void update_cpu_load_nohz(int active)
{
struct rq *this_rq = this_rq();
unsigned long curr_jiffies = READ_ONCE(jiffies);
+ unsigned long load = active ? weighted_cpuload(cpu_of(this_rq)) : 0;
unsigned long pending_updates;
if (curr_jiffies == this_rq->last_load_update_tick)
@@ -4433,10 +4434,11 @@ void update_cpu_load_nohz(void)
if (pending_updates) {
this_rq->last_load_update_tick = curr_jiffies;
/*
- * We were idle, this means load 0, the current load might be
- * !0 due to remote wakeups and the sort.
+ * In the regular NOHZ case, we were idle, this means load 0.
+ * In the NOHZ_FULL case, we were non-idle, we should consider
+ * its weighted load.
*/
- __update_cpu_load(this_rq, 0, pending_updates, 0);
+ __update_cpu_load(this_rq, load, pending_updates, active);
}
raw_spin_unlock(&this_rq->lock);
}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7c7ec45..515edf3 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -694,11 +694,11 @@ out:
return tick;
}
-static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
+static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now, int active)
{
/* Update jiffies first */
tick_do_update_jiffies64(now);
- update_cpu_load_nohz();
+ update_cpu_load_nohz(active);
calc_load_exit_idle();
touch_softlockup_watchdog();
@@ -725,7 +725,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
if (can_stop_full_tick())
tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
else if (ts->tick_stopped)
- tick_nohz_restart_sched_tick(ts, ktime_get());
+ tick_nohz_restart_sched_tick(ts, ktime_get(), 1);
#endif
}
@@ -916,7 +916,7 @@ void tick_nohz_idle_exit(void)
tick_nohz_stop_idle(ts, now);
if (ts->tick_stopped) {
- tick_nohz_restart_sched_tick(ts, now);
+ tick_nohz_restart_sched_tick(ts, now, 0);
tick_nohz_account_idle_ticks(ts);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 0/2] sched: consider missed ticks when updating cpu load
2015-11-10 0:36 [PATCH v5 0/2] sched: consider missed ticks when updating cpu load byungchul.park
2015-11-10 0:36 ` [PATCH v5 1/2] sched: make __update_cpu_load() handle NOHZ_FULL tickless byungchul.park
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
@ 2015-11-11 9:38 ` Byungchul Park
2015-11-12 6:59 ` Byungchul Park
2 siblings, 1 reply; 9+ messages in thread
From: Byungchul Park @ 2015-11-11 9:38 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, efault, tglx, fweisbec
On Tue, Nov 10, 2015 at 09:36:00AM +0900, byungchul.park@lge.com wrote:
> From: Byungchul Park <byungchul.park@lge.com>
>
> change from v4 to v5
> - fix comments and commit message
> - take new_load into account in update_cpu_load_nohz() and __update_cpu_load()
> because it's non-zero in NOHZ_FULL
>
> change from v3 to v4
> - focus the problem on full NOHZ
>
> change from v2 to v3
> - add a patch which make __update_cpu_load() handle active tickless
>
> change from v1 to v2
> - add some additional commit message (logic is same exactly)
>
> additionally i tried to use the return value of hrtimer_forward() instead of
> jiffies to get pending tick for updating cpu load. it's easy for
> update_cpu_load_nohz() to do that. but for update_idle_cpu_load(), i need
> more time to think about how to implement it nicely.
Actually because of update_idle_load() which is used when doing nohz
load balancing while the cpu has been still tick-stopped, this looks
not be able to be implemented without any kind of last_update_xxx
variable. What do you think about it, Peter?
>
> and i will try to fix other stuffs caused by full NOHZ later with another
> patch. i decided to send this patch at first because "cpu load update" is a
> standalone problem which is not coupled with other stuffs.
>
> Byungchul Park (2):
> sched: make __update_cpu_load() handle NOHZ_FULL tickless
> sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
>
> include/linux/sched.h | 4 ++--
> kernel/sched/fair.c | 57 +++++++++++++++++++++++++++++++++++++---------
> kernel/time/tick-sched.c | 8 +++----
> 3 files changed, 52 insertions(+), 17 deletions(-)
>
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
@ 2015-11-11 9:42 ` Byungchul Park
2015-11-20 13:19 ` Peter Zijlstra
2015-11-23 16:19 ` [tip:sched/core] sched/fair: Consider missed ticks in NOHZ_FULL in update_cpu_load_nohz() tip-bot for Byungchul Park
2 siblings, 0 replies; 9+ messages in thread
From: Byungchul Park @ 2015-11-11 9:42 UTC (permalink / raw)
To: fweisbec; +Cc: linux-kernel, efault, tglx, peterz, mingo
On Tue, Nov 10, 2015 at 09:36:02AM +0900, byungchul.park@lge.com wrote:
> From: Byungchul Park <byungchul.park@lge.com>
>
> Usually tick can be stopped for an idle cpu in NOHZ. However in NOHZ_FULL,
> a non-idle cpu's tick also can be stopped. However, update_cpu_load_nohz()
> does not consider the case a non-idle cpu's tick has been stopped at all.
>
> This patch makes the update_cpu_load_nohz() know if the calling path comes
> from NOHZ_FULL or idle NOHZ.
>
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> include/linux/sched.h | 4 ++--
> kernel/sched/fair.c | 10 ++++++----
> kernel/time/tick-sched.c | 8 ++++----
> 3 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 699228b..f1b59aa 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -177,9 +177,9 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
> extern void calc_global_load(unsigned long ticks);
>
> #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
> -extern void update_cpu_load_nohz(void);
> +extern void update_cpu_load_nohz(int active);
> #else
> -static inline void update_cpu_load_nohz(void) { }
> +static inline void update_cpu_load_nohz(int active) { }
> #endif
>
> extern unsigned long get_parent_ip(unsigned long addr);
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7760678..3d93756 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4419,10 +4419,11 @@ static void update_idle_cpu_load(struct rq *this_rq)
> /*
> * Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
> */
> -void update_cpu_load_nohz(void)
> +void update_cpu_load_nohz(int active)
> {
> struct rq *this_rq = this_rq();
> unsigned long curr_jiffies = READ_ONCE(jiffies);
> + unsigned long load = active ? weighted_cpuload(cpu_of(this_rq)) : 0;
Hello,
I added this part after you acked.. What do you think about this
modification?
> unsigned long pending_updates;
>
> if (curr_jiffies == this_rq->last_load_update_tick)
> @@ -4433,10 +4434,11 @@ void update_cpu_load_nohz(void)
> if (pending_updates) {
> this_rq->last_load_update_tick = curr_jiffies;
> /*
> - * We were idle, this means load 0, the current load might be
> - * !0 due to remote wakeups and the sort.
> + * In the regular NOHZ case, we were idle, this means load 0.
> + * In the NOHZ_FULL case, we were non-idle, we should consider
> + * its weighted load.
This, too.
> */
> - __update_cpu_load(this_rq, 0, pending_updates, 0);
> + __update_cpu_load(this_rq, load, pending_updates, active);
This, too.
Thank you,
byungchul
> }
> raw_spin_unlock(&this_rq->lock);
> }
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 7c7ec45..515edf3 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -694,11 +694,11 @@ out:
> return tick;
> }
>
> -static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
> +static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now, int active)
> {
> /* Update jiffies first */
> tick_do_update_jiffies64(now);
> - update_cpu_load_nohz();
> + update_cpu_load_nohz(active);
>
> calc_load_exit_idle();
> touch_softlockup_watchdog();
> @@ -725,7 +725,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
> if (can_stop_full_tick())
> tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
> else if (ts->tick_stopped)
> - tick_nohz_restart_sched_tick(ts, ktime_get());
> + tick_nohz_restart_sched_tick(ts, ktime_get(), 1);
> #endif
> }
>
> @@ -916,7 +916,7 @@ void tick_nohz_idle_exit(void)
> tick_nohz_stop_idle(ts, now);
>
> if (ts->tick_stopped) {
> - tick_nohz_restart_sched_tick(ts, now);
> + tick_nohz_restart_sched_tick(ts, now, 0);
> tick_nohz_account_idle_ticks(ts);
> }
>
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 0/2] sched: consider missed ticks when updating cpu load
2015-11-11 9:38 ` [PATCH v5 0/2] sched: consider missed ticks when updating cpu load Byungchul Park
@ 2015-11-12 6:59 ` Byungchul Park
0 siblings, 0 replies; 9+ messages in thread
From: Byungchul Park @ 2015-11-12 6:59 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, efault, tglx, fweisbec
On Wed, Nov 11, 2015 at 06:38:10PM +0900, Byungchul Park wrote:
> On Tue, Nov 10, 2015 at 09:36:00AM +0900, byungchul.park@lge.com wrote:
> > From: Byungchul Park <byungchul.park@lge.com>
> >
> > change from v4 to v5
> > - fix comments and commit message
> > - take new_load into account in update_cpu_load_nohz() and __update_cpu_load()
> > because it's non-zero in NOHZ_FULL
> >
> > change from v3 to v4
> > - focus the problem on full NOHZ
> >
> > change from v2 to v3
> > - add a patch which make __update_cpu_load() handle active tickless
> >
> > change from v1 to v2
> > - add some additional commit message (logic is same exactly)
> >
> > additionally i tried to use the return value of hrtimer_forward() instead of
> > jiffies to get pending tick for updating cpu load. it's easy for
> > update_cpu_load_nohz() to do that. but for update_idle_cpu_load(), i need
> > more time to think about how to implement it nicely.
>
> Actually because of update_idle_load() which is used when doing nohz
> load balancing while the cpu has been still tick-stopped, this looks
> not be able to be implemented without any kind of last_update_xxx
^^^
last_load_update_tick
> variable. What do you think about it, Peter?
>
> >
> > and i will try to fix other stuffs caused by full NOHZ later with another
> > patch. i decided to send this patch at first because "cpu load update" is a
> > standalone problem which is not coupled with other stuffs.
> >
> > Byungchul Park (2):
> > sched: make __update_cpu_load() handle NOHZ_FULL tickless
> > sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
> >
> > include/linux/sched.h | 4 ++--
> > kernel/sched/fair.c | 57 +++++++++++++++++++++++++++++++++++++---------
> > kernel/time/tick-sched.c | 8 +++----
> > 3 files changed, 52 insertions(+), 17 deletions(-)
> >
> > --
> > 1.7.9.5
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
2015-11-11 9:42 ` Byungchul Park
@ 2015-11-20 13:19 ` Peter Zijlstra
2015-11-23 2:32 ` Byungchul Park
2015-11-23 16:19 ` [tip:sched/core] sched/fair: Consider missed ticks in NOHZ_FULL in update_cpu_load_nohz() tip-bot for Byungchul Park
2 siblings, 1 reply; 9+ messages in thread
From: Peter Zijlstra @ 2015-11-20 13:19 UTC (permalink / raw)
To: byungchul.park; +Cc: mingo, linux-kernel, efault, tglx, fweisbec
On Tue, Nov 10, 2015 at 09:36:02AM +0900, byungchul.park@lge.com wrote:
> +++ b/kernel/sched/fair.c
> @@ -4419,10 +4419,11 @@ static void update_idle_cpu_load(struct rq *this_rq)
> /*
> * Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
> */
> -void update_cpu_load_nohz(void)
> +void update_cpu_load_nohz(int active)
> {
> struct rq *this_rq = this_rq();
> unsigned long curr_jiffies = READ_ONCE(jiffies);
> + unsigned long load = active ? weighted_cpuload(cpu_of(this_rq)) : 0;
> unsigned long pending_updates;
>
> if (curr_jiffies == this_rq->last_load_update_tick)
> @@ -4433,10 +4434,11 @@ void update_cpu_load_nohz(void)
> if (pending_updates) {
> this_rq->last_load_update_tick = curr_jiffies;
> /*
> - * We were idle, this means load 0, the current load might be
> - * !0 due to remote wakeups and the sort.
> + * In the regular NOHZ case, we were idle, this means load 0.
> + * In the NOHZ_FULL case, we were non-idle, we should consider
> + * its weighted load.
> */
> - __update_cpu_load(this_rq, 0, pending_updates, 0);
> + __update_cpu_load(this_rq, load, pending_updates, active);
> }
> raw_spin_unlock(&this_rq->lock);
> }
Bah, so I did all the work to get the actual number of lost ticks in
there, only to _then_ find out that's mostly pointless :-)
The problem is update_idle_cpu_load() is called while idle (from another
CPU), so it still needs the whole jiffy based thing.
So I'll take this patch for now. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL
2015-11-20 13:19 ` Peter Zijlstra
@ 2015-11-23 2:32 ` Byungchul Park
0 siblings, 0 replies; 9+ messages in thread
From: Byungchul Park @ 2015-11-23 2:32 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: mingo, linux-kernel, efault, tglx, fweisbec
On Fri, Nov 20, 2015 at 02:19:55PM +0100, Peter Zijlstra wrote:
> On Tue, Nov 10, 2015 at 09:36:02AM +0900, byungchul.park@lge.com wrote:
> > +++ b/kernel/sched/fair.c
> > @@ -4419,10 +4419,11 @@ static void update_idle_cpu_load(struct rq *this_rq)
> > /*
> > * Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
> > */
> > -void update_cpu_load_nohz(void)
> > +void update_cpu_load_nohz(int active)
> > {
> > struct rq *this_rq = this_rq();
> > unsigned long curr_jiffies = READ_ONCE(jiffies);
> > + unsigned long load = active ? weighted_cpuload(cpu_of(this_rq)) : 0;
> > unsigned long pending_updates;
> >
> > if (curr_jiffies == this_rq->last_load_update_tick)
> > @@ -4433,10 +4434,11 @@ void update_cpu_load_nohz(void)
> > if (pending_updates) {
> > this_rq->last_load_update_tick = curr_jiffies;
> > /*
> > - * We were idle, this means load 0, the current load might be
> > - * !0 due to remote wakeups and the sort.
> > + * In the regular NOHZ case, we were idle, this means load 0.
> > + * In the NOHZ_FULL case, we were non-idle, we should consider
> > + * its weighted load.
> > */
> > - __update_cpu_load(this_rq, 0, pending_updates, 0);
> > + __update_cpu_load(this_rq, load, pending_updates, active);
> > }
> > raw_spin_unlock(&this_rq->lock);
> > }
>
> Bah, so I did all the work to get the actual number of lost ticks in
> there, only to _then_ find out that's mostly pointless :-)
>
> The problem is update_idle_cpu_load() is called while idle (from another
> CPU), so it still needs the whole jiffy based thing.
>
> So I'll take this patch for now. Thanks.
Thank you.
Byungchul
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip:sched/core] sched/fair: Consider missed ticks in NOHZ_FULL in update_cpu_load_nohz()
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
2015-11-11 9:42 ` Byungchul Park
2015-11-20 13:19 ` Peter Zijlstra
@ 2015-11-23 16:19 ` tip-bot for Byungchul Park
2 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Byungchul Park @ 2015-11-23 16:19 UTC (permalink / raw)
To: linux-tip-commits
Cc: torvalds, byungchul.park, peterz, linux-kernel, hpa, tglx, mingo,
fweisbec, efault
Commit-ID: 525705d15e63b7455977408e4601e76e6bc41524
Gitweb: http://git.kernel.org/tip/525705d15e63b7455977408e4601e76e6bc41524
Author: Byungchul Park <byungchul.park@lge.com>
AuthorDate: Tue, 10 Nov 2015 09:36:02 +0900
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 23 Nov 2015 09:37:53 +0100
sched/fair: Consider missed ticks in NOHZ_FULL in update_cpu_load_nohz()
Usually the tick can be stopped for an idle CPU in NOHZ. However in NOHZ_FULL
mode, a non-idle CPU's tick can also be stopped. However, update_cpu_load_nohz()
does not consider the case a non-idle CPU's tick has been stopped at all.
This patch makes the update_cpu_load_nohz() know if the calling path comes
from NOHZ_FULL or idle NOHZ.
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1447115762-19734-3-git-send-email-byungchul.park@lge.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 4 ++--
kernel/sched/fair.c | 10 ++++++----
kernel/time/tick-sched.c | 8 ++++----
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index edad7a4..f425aac 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -177,9 +177,9 @@ extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
extern void calc_global_load(unsigned long ticks);
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
-extern void update_cpu_load_nohz(void);
+extern void update_cpu_load_nohz(int active);
#else
-static inline void update_cpu_load_nohz(void) { }
+static inline void update_cpu_load_nohz(int active) { }
#endif
extern unsigned long get_parent_ip(unsigned long addr);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 404006a..309b1d5 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4397,10 +4397,11 @@ static void update_idle_cpu_load(struct rq *this_rq)
/*
* Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
*/
-void update_cpu_load_nohz(void)
+void update_cpu_load_nohz(int active)
{
struct rq *this_rq = this_rq();
unsigned long curr_jiffies = READ_ONCE(jiffies);
+ unsigned long load = active ? weighted_cpuload(cpu_of(this_rq)) : 0;
unsigned long pending_updates;
if (curr_jiffies == this_rq->last_load_update_tick)
@@ -4411,10 +4412,11 @@ void update_cpu_load_nohz(void)
if (pending_updates) {
this_rq->last_load_update_tick = curr_jiffies;
/*
- * We were idle, this means load 0, the current load might be
- * !0 due to remote wakeups and the sort.
+ * In the regular NOHZ case, we were idle, this means load 0.
+ * In the NOHZ_FULL case, we were non-idle, we should consider
+ * its weighted load.
*/
- __update_cpu_load(this_rq, 0, pending_updates, 0);
+ __update_cpu_load(this_rq, load, pending_updates, active);
}
raw_spin_unlock(&this_rq->lock);
}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 7c7ec45..515edf3 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -694,11 +694,11 @@ out:
return tick;
}
-static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
+static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now, int active)
{
/* Update jiffies first */
tick_do_update_jiffies64(now);
- update_cpu_load_nohz();
+ update_cpu_load_nohz(active);
calc_load_exit_idle();
touch_softlockup_watchdog();
@@ -725,7 +725,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
if (can_stop_full_tick())
tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
else if (ts->tick_stopped)
- tick_nohz_restart_sched_tick(ts, ktime_get());
+ tick_nohz_restart_sched_tick(ts, ktime_get(), 1);
#endif
}
@@ -916,7 +916,7 @@ void tick_nohz_idle_exit(void)
tick_nohz_stop_idle(ts, now);
if (ts->tick_stopped) {
- tick_nohz_restart_sched_tick(ts, now);
+ tick_nohz_restart_sched_tick(ts, now, 0);
tick_nohz_account_idle_ticks(ts);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-11-23 16:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 0:36 [PATCH v5 0/2] sched: consider missed ticks when updating cpu load byungchul.park
2015-11-10 0:36 ` [PATCH v5 1/2] sched: make __update_cpu_load() handle NOHZ_FULL tickless byungchul.park
2015-11-10 0:36 ` [PATCH v5 2/2] sched: make update_cpu_load_nohz() consider missed ticks in NOHZ_FULL byungchul.park
2015-11-11 9:42 ` Byungchul Park
2015-11-20 13:19 ` Peter Zijlstra
2015-11-23 2:32 ` Byungchul Park
2015-11-23 16:19 ` [tip:sched/core] sched/fair: Consider missed ticks in NOHZ_FULL in update_cpu_load_nohz() tip-bot for Byungchul Park
2015-11-11 9:38 ` [PATCH v5 0/2] sched: consider missed ticks when updating cpu load Byungchul Park
2015-11-12 6:59 ` Byungchul Park
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.