[PATCH 25/25] sched/vtime: Clarify vtime_task_switch() argument layout

2018-11-13 Thread Frederic Weisbecker
This function deals with the previous and next tasks during a context
switch. But only the previous is passed as an argument, the next task
being deduced from current. Make the code clearer by passing both
previous and next as arguments.

Signed-off-by: Frederic Weisbecker 
Cc: Yauheni Kaliuta 
Cc: Thomas Gleixner 
Cc: Rik van Riel 
Cc: Peter Zijlstra 
Cc: Wanpeng Li 
Cc: Ingo Molnar 
---
 arch/ia64/include/asm/cputime.h|  3 ++-
 arch/ia64/kernel/time.c|  5 +++--
 arch/powerpc/include/asm/cputime.h |  8 +---
 arch/s390/kernel/vtime.c   | 13 +++--
 include/linux/vtime.h  | 17 +++--
 kernel/sched/core.c|  2 +-
 kernel/sched/cputime.c | 18 ++
 7 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index 3d665c0..0bc90a1 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -19,7 +19,8 @@
 #define __IA64_CPUTIME_H
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-extern void arch_vtime_task_switch(struct task_struct *tsk);
+extern void arch_vtime_task_switch(struct task_struct *prev,
+  struct task_struct *next);
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
 
 #endif /* __IA64_CPUTIME_H */
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 46a9798..908bd4f 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -105,10 +105,11 @@ void vtime_flush(struct task_struct *tsk)
  * accumulated times to the current process, and to prepare accounting on
  * the next process.
  */
-void arch_vtime_task_switch(struct task_struct *prev)
+void arch_vtime_task_switch(struct task_struct *prev,
+   struct task_struct *next)
 {
struct thread_info *pi = task_thread_info(prev);
-   struct thread_info *ni = task_thread_info(current);
+   struct thread_info *ni = task_thread_info(next);
 
ni->ac_stamp = pi->ac_stamp;
ni->ac_stime = ni->ac_utime = 0;
diff --git a/arch/powerpc/include/asm/cputime.h 
b/arch/powerpc/include/asm/cputime.h
index ae73dc8..9d68040 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -47,7 +47,8 @@ static inline unsigned long cputime_to_usecs(const cputime_t 
ct)
  */
 #ifdef CONFIG_PPC64
 #define get_accounting(tsk)(_paca()->accounting)
-static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
+static inline void arch_vtime_task_switch(struct task_struct *prev,
+ struct task_struct *next) { }
 #else
 #define get_accounting(tsk)(_thread_info(tsk)->accounting)
 /*
@@ -55,9 +56,10 @@ static inline void arch_vtime_task_switch(struct task_struct 
*tsk) { }
  * accumulated times to the current process, and to prepare accounting on
  * the next process.
  */
-static inline void arch_vtime_task_switch(struct task_struct *prev)
+static inline void arch_vtime_task_switch(struct task_struct *prev,
+ struct task_struct *next)
 {
-   struct cpu_accounting_data *acct = get_accounting(current);
+   struct cpu_accounting_data *acct = get_accounting(next);
struct cpu_accounting_data *acct0 = get_accounting(prev);
 
acct->starttime = acct0->starttime;
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index b6b888d..fcfeb63 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -191,7 +191,8 @@ static int do_account_vtime(struct task_struct *tsk)
return virt_timer_forward(user + guest + system + hardirq + softirq);
 }
 
-void vtime_task_switch(struct task_struct *prev)
+void vtime_task_switch(struct task_struct *prev,
+  struct task_struct *next)
 {
do_account_vtime(prev);
prev->thread.user_timer = S390_lowcore.user_timer;
@@ -199,11 +200,11 @@ void vtime_task_switch(struct task_struct *prev)
prev->thread.system_timer = S390_lowcore.system_timer;
prev->thread.hardirq_timer = S390_lowcore.hardirq_timer;
prev->thread.softirq_timer = S390_lowcore.softirq_timer;
-   S390_lowcore.user_timer = current->thread.user_timer;
-   S390_lowcore.guest_timer = current->thread.guest_timer;
-   S390_lowcore.system_timer = current->thread.system_timer;
-   S390_lowcore.hardirq_timer = current->thread.hardirq_timer;
-   S390_lowcore.softirq_timer = current->thread.softirq_timer;
+   S390_lowcore.user_timer = next->thread.user_timer;
+   S390_lowcore.guest_timer = next->thread.guest_timer;
+   S390_lowcore.system_timer = next->thread.system_timer;
+   S390_lowcore.hardirq_timer = next->thread.hardirq_timer;
+   S390_lowcore.softirq_timer = next->thread.softirq_timer;
 }
 
 /*
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index b4566d5..188eace 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h

[PATCH 25/25] sched/vtime: Clarify vtime_task_switch() argument layout

2018-11-13 Thread Frederic Weisbecker
This function deals with the previous and next tasks during a context
switch. But only the previous is passed as an argument, the next task
being deduced from current. Make the code clearer by passing both
previous and next as arguments.

Signed-off-by: Frederic Weisbecker 
Cc: Yauheni Kaliuta 
Cc: Thomas Gleixner 
Cc: Rik van Riel 
Cc: Peter Zijlstra 
Cc: Wanpeng Li 
Cc: Ingo Molnar 
---
 arch/ia64/include/asm/cputime.h|  3 ++-
 arch/ia64/kernel/time.c|  5 +++--
 arch/powerpc/include/asm/cputime.h |  8 +---
 arch/s390/kernel/vtime.c   | 13 +++--
 include/linux/vtime.h  | 17 +++--
 kernel/sched/core.c|  2 +-
 kernel/sched/cputime.c | 18 ++
 7 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index 3d665c0..0bc90a1 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -19,7 +19,8 @@
 #define __IA64_CPUTIME_H
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-extern void arch_vtime_task_switch(struct task_struct *tsk);
+extern void arch_vtime_task_switch(struct task_struct *prev,
+  struct task_struct *next);
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
 
 #endif /* __IA64_CPUTIME_H */
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 46a9798..908bd4f 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -105,10 +105,11 @@ void vtime_flush(struct task_struct *tsk)
  * accumulated times to the current process, and to prepare accounting on
  * the next process.
  */
-void arch_vtime_task_switch(struct task_struct *prev)
+void arch_vtime_task_switch(struct task_struct *prev,
+   struct task_struct *next)
 {
struct thread_info *pi = task_thread_info(prev);
-   struct thread_info *ni = task_thread_info(current);
+   struct thread_info *ni = task_thread_info(next);
 
ni->ac_stamp = pi->ac_stamp;
ni->ac_stime = ni->ac_utime = 0;
diff --git a/arch/powerpc/include/asm/cputime.h 
b/arch/powerpc/include/asm/cputime.h
index ae73dc8..9d68040 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -47,7 +47,8 @@ static inline unsigned long cputime_to_usecs(const cputime_t 
ct)
  */
 #ifdef CONFIG_PPC64
 #define get_accounting(tsk)(_paca()->accounting)
-static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
+static inline void arch_vtime_task_switch(struct task_struct *prev,
+ struct task_struct *next) { }
 #else
 #define get_accounting(tsk)(_thread_info(tsk)->accounting)
 /*
@@ -55,9 +56,10 @@ static inline void arch_vtime_task_switch(struct task_struct 
*tsk) { }
  * accumulated times to the current process, and to prepare accounting on
  * the next process.
  */
-static inline void arch_vtime_task_switch(struct task_struct *prev)
+static inline void arch_vtime_task_switch(struct task_struct *prev,
+ struct task_struct *next)
 {
-   struct cpu_accounting_data *acct = get_accounting(current);
+   struct cpu_accounting_data *acct = get_accounting(next);
struct cpu_accounting_data *acct0 = get_accounting(prev);
 
acct->starttime = acct0->starttime;
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index b6b888d..fcfeb63 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -191,7 +191,8 @@ static int do_account_vtime(struct task_struct *tsk)
return virt_timer_forward(user + guest + system + hardirq + softirq);
 }
 
-void vtime_task_switch(struct task_struct *prev)
+void vtime_task_switch(struct task_struct *prev,
+  struct task_struct *next)
 {
do_account_vtime(prev);
prev->thread.user_timer = S390_lowcore.user_timer;
@@ -199,11 +200,11 @@ void vtime_task_switch(struct task_struct *prev)
prev->thread.system_timer = S390_lowcore.system_timer;
prev->thread.hardirq_timer = S390_lowcore.hardirq_timer;
prev->thread.softirq_timer = S390_lowcore.softirq_timer;
-   S390_lowcore.user_timer = current->thread.user_timer;
-   S390_lowcore.guest_timer = current->thread.guest_timer;
-   S390_lowcore.system_timer = current->thread.system_timer;
-   S390_lowcore.hardirq_timer = current->thread.hardirq_timer;
-   S390_lowcore.softirq_timer = current->thread.softirq_timer;
+   S390_lowcore.user_timer = next->thread.user_timer;
+   S390_lowcore.guest_timer = next->thread.guest_timer;
+   S390_lowcore.system_timer = next->thread.system_timer;
+   S390_lowcore.hardirq_timer = next->thread.hardirq_timer;
+   S390_lowcore.softirq_timer = next->thread.softirq_timer;
 }
 
 /*
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index b4566d5..188eace 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h