Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/vtime: Get rid of generic vtime_task_switch() implementation

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

authored by

Alexander Gordeev and committed by
Ingo Molnar
89d6910c 37f36cab

+22 -26
-13
arch/powerpc/include/asm/cputime.h
··· 32 32 #ifdef CONFIG_PPC64 33 33 #define get_accounting(tsk) (&get_paca()->accounting) 34 34 #define raw_get_accounting(tsk) (&local_paca->accounting) 35 - static inline void arch_vtime_task_switch(struct task_struct *tsk) { } 36 35 37 36 #else 38 37 #define get_accounting(tsk) (&task_thread_info(tsk)->accounting) 39 38 #define raw_get_accounting(tsk) get_accounting(tsk) 40 - /* 41 - * Called from the context switch with interrupts disabled, to charge all 42 - * accumulated times to the current process, and to prepare accounting on 43 - * the next process. 44 - */ 45 - static inline void arch_vtime_task_switch(struct task_struct *prev) 46 - { 47 - struct cpu_accounting_data *acct = get_accounting(current); 48 - struct cpu_accounting_data *acct0 = get_accounting(prev); 49 - 50 - acct->starttime = acct0->starttime; 51 - } 52 39 #endif 53 40 54 41 /*
+22
arch/powerpc/kernel/time.c
··· 354 354 acct->hardirq_time = 0; 355 355 acct->softirq_time = 0; 356 356 } 357 + 358 + /* 359 + * Called from the context switch with interrupts disabled, to charge all 360 + * accumulated times to the current process, and to prepare accounting on 361 + * the next process. 362 + */ 363 + void vtime_task_switch(struct task_struct *prev) 364 + { 365 + if (is_idle_task(prev)) 366 + vtime_account_idle(prev); 367 + else 368 + vtime_account_kernel(prev); 369 + 370 + vtime_flush(prev); 371 + 372 + if (!IS_ENABLED(CONFIG_PPC64)) { 373 + struct cpu_accounting_data *acct = get_accounting(current); 374 + struct cpu_accounting_data *acct0 = get_accounting(prev); 375 + 376 + acct->starttime = acct0->starttime; 377 + } 378 + } 357 379 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ 358 380 359 381 void __no_kcsan __delay(unsigned long loops)
-13
kernel/sched/cputime.c
··· 424 424 */ 425 425 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE 426 426 427 - # ifndef __ARCH_HAS_VTIME_TASK_SWITCH 428 - void vtime_task_switch(struct task_struct *prev) 429 - { 430 - if (is_idle_task(prev)) 431 - vtime_account_idle(prev); 432 - else 433 - vtime_account_kernel(prev); 434 - 435 - vtime_flush(prev); 436 - arch_vtime_task_switch(prev); 437 - } 438 - # endif 439 - 440 427 void vtime_account_irq(struct task_struct *tsk, unsigned int offset) 441 428 { 442 429 unsigned int pc = irq_count() - offset;