From: Ingo Molnar Date: Tue, 5 Feb 2013 12:10:33 +0000 (+0100) Subject: Merge tag 'full-dynticks-cputime-for-mingo' of git://git.kernel.org/pub/scm/linux... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b2c77a57e4a0a7877e357dead7ee8acc19944f3e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge tag 'full-dynticks-cputime-for-mingo' of git://git./linux/kernel/git/frederic/linux-dynticks into sched/core Pull full-dynticks (user-space execution is undisturbed and receives no timer IRQs) preparation changes that convert the cputime accounting code to be full-dynticks ready, from Frederic Weisbecker: "This implements the cputime accounting on full dynticks CPUs. Typical cputime stats infrastructure relies on the timer tick and its periodic polling on the CPU to account the amount of time spent by the CPUs and the tasks per high level domains such as userspace, kernelspace, guest, ... Now we are preparing to implement full dynticks capability on Linux for Real Time and HPC users who want full CPU isolation. This feature requires a cputime accounting that doesn't depend on the timer tick. To implement it, this new cputime infrastructure plugs into kernel/user/guest boundaries to take snapshots of cputime and flush these to the stats when needed. This performs pretty much like CONFIG_VIRT_CPU_ACCOUNTING except that context location and cputime snaphots are synchronized between write and read side such that the latter can safely retrieve the pending tickless cputime of a task and add it to its latest cputime snapshot to return the correct result to the user." Signed-off-by: Frederic Weisbecker Signed-off-by: Ingo Molnar --- b2c77a57e4a0a7877e357dead7ee8acc19944f3e diff --cc kernel/sched/cputime.c index 825a956ccdb6,082e05d915b4..ccff2752725a --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@@ -493,23 -492,36 +492,36 @@@ void vtime_task_switch(struct task_stru * vtime_account(). */ #ifndef __ARCH_HAS_VTIME_ACCOUNT - void vtime_account(struct task_struct *tsk) + void vtime_account_irq_enter(struct task_struct *tsk) { - if (in_interrupt() || !is_idle_task(tsk)) - vtime_account_system(tsk); - else - vtime_account_idle(tsk); + if (!vtime_accounting_enabled()) + return; + + if (!in_interrupt()) { + /* + * If we interrupted user, context_tracking_in_user() + * is 1 because the context tracking don't hook + * on irq entry/exit. This way we know if + * we need to flush user time on kernel entry. + */ + if (context_tracking_in_user()) { + vtime_account_user(tsk); + return; + } + + if (is_idle_task(tsk)) { + vtime_account_idle(tsk); + return; + } + } + vtime_account_system(tsk); } - EXPORT_SYMBOL_GPL(vtime_account); + EXPORT_SYMBOL_GPL(vtime_account_irq_enter); #endif /* __ARCH_HAS_VTIME_ACCOUNT */ - #else - - #ifndef nsecs_to_cputime - # define nsecs_to_cputime(__nsecs) nsecs_to_jiffies(__nsecs) - #endif + #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ -static cputime_t scale_utime(cputime_t utime, cputime_t rtime, cputime_t total) +static cputime_t scale_stime(cputime_t stime, cputime_t rtime, cputime_t total) { u64 temp = (__force u64) rtime;