vtime: Warn if irqs aren't disabled on system time accounting APIs
[cascardo/linux.git] / arch / s390 / kernel / vtime.c
index 4fc97b4..e84b8b6 100644 (file)
@@ -99,7 +99,7 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
        return virt_timer_forward(user + system);
 }
 
-void account_vtime(struct task_struct *prev, struct task_struct *next)
+void vtime_task_switch(struct task_struct *prev)
 {
        struct thread_info *ti;
 
@@ -107,12 +107,17 @@ void account_vtime(struct task_struct *prev, struct task_struct *next)
        ti = task_thread_info(prev);
        ti->user_timer = S390_lowcore.user_timer;
        ti->system_timer = S390_lowcore.system_timer;
-       ti = task_thread_info(next);
+       ti = task_thread_info(current);
        S390_lowcore.user_timer = ti->user_timer;
        S390_lowcore.system_timer = ti->system_timer;
 }
 
-void account_process_tick(struct task_struct *tsk, int user_tick)
+/*
+ * In s390, accounting pending user time also implies
+ * accounting system time in order to correctly compute
+ * the stolen time accounting.
+ */
+void vtime_account_user(struct task_struct *tsk)
 {
        if (do_account_vtime(tsk, HARDIRQ_OFFSET))
                virt_timer_expire();
@@ -122,11 +127,13 @@ void account_process_tick(struct task_struct *tsk, int user_tick)
  * Update process times based on virtual cpu times stored by entry.S
  * to the lowcore fields user_timer, system_timer & steal_clock.
  */
-void account_system_vtime(struct task_struct *tsk)
+void vtime_account(struct task_struct *tsk)
 {
        struct thread_info *ti = task_thread_info(tsk);
        u64 timer, system;
 
+       WARN_ON_ONCE(!irqs_disabled());
+
        timer = S390_lowcore.last_update_timer;
        S390_lowcore.last_update_timer = get_vtimer();
        S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
@@ -138,7 +145,11 @@ void account_system_vtime(struct task_struct *tsk)
 
        virt_timer_forward(system);
 }
-EXPORT_SYMBOL_GPL(account_system_vtime);
+EXPORT_SYMBOL_GPL(vtime_account);
+
+void vtime_account_system(struct task_struct *tsk)
+__attribute__((alias("vtime_account")));
+EXPORT_SYMBOL_GPL(vtime_account_system);
 
 void __kprobes vtime_stop_cpu(void)
 {
@@ -378,9 +389,8 @@ static int __cpuinit s390_nohz_notify(struct notifier_block *self,
        long cpu = (long) hcpu;
 
        idle = &per_cpu(s390_idle, cpu);
-       switch (action) {
+       switch (action & ~CPU_TASKS_FROZEN) {
        case CPU_DYING:
-       case CPU_DYING_FROZEN:
                idle->nohz_delay = 0;
        default:
                break;