sched/vtime: Get rid of generic vtime_task_switch() implementation
authorAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 10 Apr 2024 15:09:45 +0000 (17:09 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 17 Apr 2024 11:37:20 +0000 (13:37 +0200)
The generic vtime_task_switch() implementation gets built only
if __ARCH_HAS_VTIME_TASK_SWITCH is not defined, but requires an
architecture to implement arch_vtime_task_switch() callback at
the same time, which is confusing.

Further, arch_vtime_task_switch() is implemented for 32-bit PowerPC
architecture only and vtime_task_switch() generic variant is rather
superfluous.

Simplify the whole vtime_task_switch() wiring by moving the existing
generic implementation to PowerPC.

Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2cb6e3caada93623f6d4f78ad938ac6cd0e2fda8.1712760275.git.agordeev@linux.ibm.com
arch/powerpc/include/asm/cputime.h
arch/powerpc/kernel/time.c
kernel/sched/cputime.c

index 4961fb38e4385f3d5dc2c497d4acdfdeb0b9e1ae..aff858ca99c05dd64c8d3d7dc717b37e115766bb 100644 (file)
 #ifdef CONFIG_PPC64
 #define get_accounting(tsk)    (&get_paca()->accounting)
 #define raw_get_accounting(tsk)        (&local_paca->accounting)
-static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
 
 #else
 #define get_accounting(tsk)    (&task_thread_info(tsk)->accounting)
 #define raw_get_accounting(tsk)        get_accounting(tsk)
-/*
- * Called from the context switch with interrupts disabled, to charge all
- * 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)
-{
-       struct cpu_accounting_data *acct = get_accounting(current);
-       struct cpu_accounting_data *acct0 = get_accounting(prev);
-
-       acct->starttime = acct0->starttime;
-}
 #endif
 
 /*
index df20cf201f74d7938e62ec0d76f5e27f3c2f0817..c0fdc6d94feee7b11759dc906d231d50076ba94d 100644 (file)
@@ -354,6 +354,28 @@ void vtime_flush(struct task_struct *tsk)
        acct->hardirq_time = 0;
        acct->softirq_time = 0;
 }
+
+/*
+ * Called from the context switch with interrupts disabled, to charge all
+ * accumulated times to the current process, and to prepare accounting on
+ * the next process.
+ */
+void vtime_task_switch(struct task_struct *prev)
+{
+       if (is_idle_task(prev))
+               vtime_account_idle(prev);
+       else
+               vtime_account_kernel(prev);
+
+       vtime_flush(prev);
+
+       if (!IS_ENABLED(CONFIG_PPC64)) {
+               struct cpu_accounting_data *acct = get_accounting(current);
+               struct cpu_accounting_data *acct0 = get_accounting(prev);
+
+               acct->starttime = acct0->starttime;
+       }
+}
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
 
 void __no_kcsan __delay(unsigned long loops)
index af7952f12e6cf19ac9b953fbbf54df823372f497..aa48b2ec879df156d716a14efec60a69f8b51a32 100644 (file)
@@ -424,19 +424,6 @@ static inline void irqtime_account_process_tick(struct task_struct *p, int user_
  */
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
 
-# ifndef __ARCH_HAS_VTIME_TASK_SWITCH
-void vtime_task_switch(struct task_struct *prev)
-{
-       if (is_idle_task(prev))
-               vtime_account_idle(prev);
-       else
-               vtime_account_kernel(prev);
-
-       vtime_flush(prev);
-       arch_vtime_task_switch(prev);
-}
-# endif
-
 void vtime_account_irq(struct task_struct *tsk, unsigned int offset)
 {
        unsigned int pc = irq_count() - offset;