The patch titled dynticks core: Fix idle time accounting has been added to the -mm tree. Its filename is dynticks-core-fix-idle-time-accounting.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: dynticks core: Fix idle time accounting From: Thomas Gleixner <tglx@xxxxxxxxxxxxx> The extended sleeps during idle must be accounted to the idle thread. The original accounting fixup was too naive. The time must be accounted when the idle thread is interrupted and the jiffies update code has forwarded jiffies. Otherwise the accounting is done on random targets. Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- kernel/hrtimer.c | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff -puN kernel/hrtimer.c~dynticks-core-fix-idle-time-accounting kernel/hrtimer.c --- a/kernel/hrtimer.c~dynticks-core-fix-idle-time-accounting +++ a/kernel/hrtimer.c @@ -44,6 +44,7 @@ #include <linux/profile.h> #include <linux/seq_file.h> #include <linux/err.h> +#include <linux/kernel_stat.h> #include <asm/uaccess.h> @@ -447,10 +448,11 @@ static const ktime_t nsec_per_hz = { .tv * want to wake up a complete idle cpu just to update jiffies, so we need * something more intellegent than a mere "do this only on CPUx". */ -static void update_jiffies64(ktime_t now) +static unsigned long update_jiffies64(ktime_t now) { unsigned long seq; ktime_t delta; + unsigned long ticks = 0; /* Preevaluate to avoid lock contention */ do { @@ -459,14 +461,13 @@ static void update_jiffies64(ktime_t now } while (read_seqretry(&xtime_lock, seq)); if (delta.tv64 < nsec_per_hz.tv64) - return; + return 0; /* Reevalute with xtime_lock held */ write_seqlock(&xtime_lock); delta = ktime_sub(now, last_jiffies_update); if (delta.tv64 >= nsec_per_hz.tv64) { - unsigned long ticks = 1; delta = ktime_sub(delta, nsec_per_hz); last_jiffies_update = ktime_add(last_jiffies_update, @@ -480,11 +481,13 @@ static void update_jiffies64(ktime_t now last_jiffies_update = ktime_add_ns(last_jiffies_update, incr * ticks); - ticks++; } + ticks++; do_timer(ticks); } write_sequnlock(&xtime_lock); + + return ticks; } #ifdef CONFIG_NO_HZ @@ -500,7 +503,7 @@ static void update_jiffies64(ktime_t now void hrtimer_update_jiffies(void) { struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases); - unsigned long flags; + unsigned long flags, ticks; ktime_t now; if (!cpu_base->tick_stopped || !cpu_base->hres_active) @@ -509,7 +512,17 @@ void hrtimer_update_jiffies(void) now = ktime_get(); local_irq_save(flags); - update_jiffies64(now); + ticks = update_jiffies64(now); + if (ticks) { + /* + * We stopped the tick in idle and this function got called to + * update jiffies. Update process times would randomly account + * the time we slept to whatever the context of the next sched + * tick is. Enforce that this is accounted to idle ! + */ + account_system_time(current, HARDIRQ_OFFSET, + jiffies_to_cputime(ticks)); + } local_irq_restore(flags); } @@ -604,15 +617,6 @@ void hrtimer_restart_sched_tick(void) local_irq_disable(); update_jiffies64(now); - /* - * Update process times would randomly account the time we slept to - * whatever the context of the next sched tick is. Enforce that this - * is accounted to idle ! - */ - add_preempt_count(HARDIRQ_OFFSET); - update_process_times(0); - sub_preempt_count(HARDIRQ_OFFSET); - /* Account the idle time */ delta = ktime_sub(now, cpu_base->idle_entrytime); cpu_base->idle_sleeptime = ktime_add(cpu_base->idle_sleeptime, delta); _ Patches currently in -mm which might be from tglx@xxxxxxxxxxxxx are origin.patch genirq-convert-the-x86_64-architecture-to-irq-chips.patch genirq-convert-the-i386-architecture-to-irq-chips.patch genirq-irq-convert-the-move_irq-flag-from-a-32bit-word-to-a-single-bit.patch genirq-irq-add-moved_masked_irq.patch genirq-x86_64-irq-reenable-migrating-irqs-to-other-cpus.patch genirq-msi-simplify-msi-enable-and-disable.patch genirq-msi-make-the-msi-boolean-tests-return-either-0-or-1.patch genirq-msi-implement-helper-functions-read_msi_msg-and-write_msi_msg.patch genirq-msi-refactor-the-msi_ops.patch genirq-msi-simplify-the-msi-irq-limit-policy.patch genirq-irq-add-a-dynamic-irq-creation-api.patch genirq-ia64-irq-dynamic-irq-support.patch genirq-i386-irq-dynamic-irq-support.patch genirq-x86_64-irq-dynamic-irq-support.patch genirq-msi-make-the-msi-code-irq-based-and-not-vector-based.patch genirq-x86_64-irq-move-msi-message-composition-into-io_apicc.patch genirq-i386-irq-move-msi-message-composition-into-io_apicc.patch genirq-msi-only-build-msi-apicc-on-ia64.patch genirq-x86_64-irq-remove-the-msi-assumption-that-irq-==-vector.patch genirq-i386-irq-remove-the-msi-assumption-that-irq-==-vector.patch genirq-irq-remove-msi-hacks.patch genirq-irq-generalize-the-check-for-hardirq_bits.patch genirq-x86_64-irq-make-the-external-irq-handlers-report-their-vector-not-the-irq-number.patch genirq-x86_64-irq-make-vector_irq-per-cpu.patch genirq-x86_64-irq-make-vector_irq-per-cpu-warning-fix.patch genirq-x86_64-irq-kill-gsi_irq_sharing.patch genirq-x86_64-irq-kill-irq-compression.patch msi-simplify-msi-sanity-checks-by-adding-with-generic-irq-code.patch msi-only-use-a-single-irq_chip-for-msi-interrupts.patch msi-refactor-and-move-the-msi-irq_chip-into-the-arch-code.patch msi-move-the-ia64-code-into-arch-ia64.patch htirq-tidy-up-the-htirq-code.patch genirq-clean-up-irq-flow-type-naming.patch gtod-exponential-update_wall_time.patch gtod-persistent-clock-support-core.patch gtod-persistent-clock-support-i386.patch time-uninline-jiffiesh.patch time-fix-msecs_to_jiffies-bug.patch time-fix-timeout-overflow.patch cleanup-uninline-irq_enter-and-move-it-into-a.patch dynticks-extend-next_timer_interrupt-to-use-a.patch hrtimers-namespace-and-enum-cleanup.patch hrtimers-clean-up-locking.patch hrtimers-state-tracking.patch hrtimers-clean-up-callback-tracking.patch hrtimers-move-and-add-documentation.patch clockevents-core.patch clockevents-drivers-for-i386.patch high-res-timers-core.patch high-res-timers-core-fix.patch high-res-timers-core-fix-2.patch dynticks-core.patch dynticks-core-nmi-watchdog-fix.patch dynticks-core-nmi-watchdog-fix-2.patch dynticks-core-fix-idle-time-accounting.patch dyntick-add-nohz-stats-to-proc-stat.patch dynticks-i386-arch-code.patch high-res-timers-dynticks-enable-i386-support.patch debugging-feature-timer-stats.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html