Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1226565 > unrolled thread
| Started by | Yunhong Jiang <yunhong.jiang@linux.intel.com> |
|---|---|
| First post | 2015-09-17 01:30 +0200 |
| Last post | 2015-09-18 20:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] nohz: make the idle_entrytime/idle_exittime correct Yunhong Jiang <yunhong.jiang@linux.intel.com> - 2015-09-17 01:30 +0200
Re: [PATCH] nohz: make the idle_entrytime/idle_exittime correct Thomas Gleixner <tglx@linutronix.de> - 2015-09-17 23:50 +0200
Re: [PATCH] nohz: make the idle_entrytime/idle_exittime correct Yunhong Jiang <yunhong.jiang@linux.intel.com> - 2015-09-18 20:50 +0200
| From | Yunhong Jiang <yunhong.jiang@linux.intel.com> |
|---|---|
| Date | 2015-09-17 01:30 +0200 |
| Subject | [PATCH] nohz: make the idle_entrytime/idle_exittime correct |
| Message-ID | <q9ujg-2iU-11@gated-at.bofh.it> |
Currently the idle_entrytime is updated on idle_entry, idle_exit and
get_cpu_idle/iowait_time_us() with non-NULL parameter. This makes the
idle_entrytime not the real entrytime anymore. The idle_exittiime is
updated when exit tickless state, which can be idle tickless or full
tickless.
Change the idle_entrytime to be updated only when enter idle, the
idle_exittime to be updated only when exit idle. Update
the get_cpu_idle_iowait_time_us() accordingly.
Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
---
kernel/time/tick-sched.c | 44 ++++++++++++++++----------------------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index c792429e98c6..f8470ff20f77 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -448,7 +448,7 @@ static void tick_nohz_update_jiffies(ktime_t now)
* Updates the per cpu time idle statistics counters
*/
static void
-update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_update_time)
+update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now)
{
ktime_t delta;
@@ -458,17 +458,13 @@ update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_upda
ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta);
else
ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
- ts->idle_entrytime = now;
}
-
- if (last_update_time)
- *last_update_time = ktime_to_us(now);
-
}
static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now)
{
- update_ts_time_stats(smp_processor_id(), ts, now, NULL);
+ update_ts_time_stats(smp_processor_id(), ts, now);
+ ts->idle_exittime = now;
ts->idle_active = 0;
sched_clock_idle_wakeup_event(0);
@@ -507,21 +503,16 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
return -1;
now = ktime_get();
- if (last_update_time) {
- update_ts_time_stats(cpu, ts, now, last_update_time);
- idle = ts->idle_sleeptime;
- } else {
- if (ts->idle_active && !nr_iowait_cpu(cpu)) {
- ktime_t delta = ktime_sub(now, ts->idle_entrytime);
+ idle = ts->idle_sleeptime;
+ if (ts->idle_active && !nr_iowait_cpu(cpu)) {
+ ktime_t delta = ktime_sub(now, ts->idle_entrytime);
- idle = ktime_add(ts->idle_sleeptime, delta);
- } else {
- idle = ts->idle_sleeptime;
- }
+ idle = ktime_add(ts->idle_sleeptime, delta);
}
+ if (last_update_time)
+ *last_update_time = ktime_to_us(now);
return ktime_to_us(idle);
-
}
EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
@@ -548,19 +539,16 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
return -1;
now = ktime_get();
- if (last_update_time) {
- update_ts_time_stats(cpu, ts, now, last_update_time);
- iowait = ts->iowait_sleeptime;
- } else {
- if (ts->idle_active && nr_iowait_cpu(cpu) > 0) {
- ktime_t delta = ktime_sub(now, ts->idle_entrytime);
+ iowait = ts->iowait_sleeptime;
+ if (ts->idle_active && nr_iowait_cpu(cpu) > 0) {
+ ktime_t delta = ktime_sub(now, ts->idle_entrytime);
- iowait = ktime_add(ts->iowait_sleeptime, delta);
- } else {
- iowait = ts->iowait_sleeptime;
- }
+ iowait = ktime_add(ts->iowait_sleeptime, delta);
}
+ if (last_update_time)
+ *last_update_time = ktime_to_us(now);
+
return ktime_to_us(iowait);
}
EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
--
1.8.3.1
--
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/
[toc] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-09-17 23:50 +0200 |
| Message-ID | <q9Pe2-7Ti-17@gated-at.bofh.it> |
| In reply to | #1226565 |
On Wed, 16 Sep 2015, Yunhong Jiang wrote: > Currently the idle_entrytime is updated on idle_entry, idle_exit and > get_cpu_idle/iowait_time_us() with non-NULL parameter. This makes the > idle_entrytime not the real entrytime anymore. The idle_exittiime is > updated when exit tickless state, which can be idle tickless or full > tickless. If something calls one of the functions then the cpu is not idle. It's running code. > Change the idle_entrytime to be updated only when enter idle, the > idle_exittime to be updated only when exit idle. Update > the get_cpu_idle_iowait_time_us() accordingly. And the rationale for this change is? Thanks, tglx -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Yunhong Jiang <yunhong.jiang@linux.intel.com> |
|---|---|
| Date | 2015-09-18 20:50 +0200 |
| Message-ID | <qa8To-2tx-5@gated-at.bofh.it> |
| In reply to | #1227427 |
On Thu, Sep 17, 2015 at 11:45:37PM +0200, Thomas Gleixner wrote: > On Wed, 16 Sep 2015, Yunhong Jiang wrote: > > > Currently the idle_entrytime is updated on idle_entry, idle_exit and > > get_cpu_idle/iowait_time_us() with non-NULL parameter. This makes the > > idle_entrytime not the real entrytime anymore. The idle_exittiime is > > updated when exit tickless state, which can be idle tickless or full > > tickless. > > If something calls one of the functions then the cpu is not idle. It's > running code. I think the get_cpu_idle/iowait_time_us() can be called from other CPUs. Hmm, I should state this patch as "no idle_entrytime update on get_cpu_idle/iowait_time_us()". If you think this statement is correct, I will re-submit a patch for it. > > > Change the idle_entrytime to be updated only when enter idle, the > > idle_exittime to be updated only when exit idle. Update > > the get_cpu_idle_iowait_time_us() accordingly. > > And the rationale for this change is? I tried to check /proc/timer_list for idle_entrytime/idle_exittime, and noticed this when reading the corresponding code. So no special reason for this change, just correctness. Thanks --jyh > > Thanks, > > tglx > -- > 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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web