Skip to content

Commit 89d6910

Browse files
Alexander GordeevIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Acked-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/2cb6e3caada93623f6d4f78ad938ac6cd0e2fda8.1712760275.git.agordeev@linux.ibm.com
1 parent 37f36ca commit 89d6910

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

arch/powerpc/include/asm/cputime.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,10 @@
3232
#ifdef CONFIG_PPC64
3333
#define get_accounting(tsk) (&get_paca()->accounting)
3434
#define raw_get_accounting(tsk) (&local_paca->accounting)
35-
static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
3635

3736
#else
3837
#define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
3938
#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-
}
5239
#endif
5340

5441
/*

arch/powerpc/kernel/time.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,28 @@ void vtime_flush(struct task_struct *tsk)
354354
acct->hardirq_time = 0;
355355
acct->softirq_time = 0;
356356
}
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+
}
357379
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
358380

359381
void __no_kcsan __delay(unsigned long loops)

kernel/sched/cputime.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,6 @@ static inline void irqtime_account_process_tick(struct task_struct *p, int user_
424424
*/
425425
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
426426

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-
440427
void vtime_account_irq(struct task_struct *tsk, unsigned int offset)
441428
{
442429
unsigned int pc = irq_count() - offset;

0 commit comments

Comments
 (0)