mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 04:37:57 +07:00
abcff86df2
scaled cputime is only meaningfull when the processor has SPURR and/or PURR, which means only on PPC64. Removing it on PPC32 significantly reduces the size of vtime_account_system() and vtime_account_idle() on an 8xx: Before: 00000000 l F .text 000000a8 vtime_delta 00000280 g F .text 0000010c vtime_account_system 0000038c g F .text 00000048 vtime_account_idle After: (vtime_delta gets inlined inside the two functions) 000001d8 g F .text 000000a0 vtime_account_system 00000278 g F .text 00000038 vtime_account_idle In terms of performance, we also get approximatly 7% improvement on task switch. The following small benchmark app is run with perf stat: void *thread(void *arg) { int i; for (i = 0; i < atoi((char*)arg); i++) pthread_yield(); } int main(int argc, char **argv) { pthread_t th1, th2; pthread_create(&th1, NULL, thread, argv[1]); pthread_create(&th2, NULL, thread, argv[1]); pthread_join(th1, NULL); pthread_join(th2, NULL); return 0; } Before the patch: Performance counter stats for 'chrt -f 98 ./sched 100000' (50 runs): 8228.476465 task-clock (msec) # 0.954 CPUs utilized ( +- 0.23% ) 200004 context-switches # 0.024 M/sec ( +- 0.00% ) After the patch: Performance counter stats for 'chrt -f 98 ./sched 100000' (50 runs): 7649.070444 task-clock (msec) # 0.955 CPUs utilized ( +- 0.27% ) 200004 context-switches # 0.026 M/sec ( +- 0.00% ) Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
70 lines
2.0 KiB
C
70 lines
2.0 KiB
C
/*
|
|
* Definitions for measuring cputime on powerpc machines.
|
|
*
|
|
* Copyright (C) 2006 Paul Mackerras, IBM Corp.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
* If we have CONFIG_VIRT_CPU_ACCOUNTING_NATIVE, we measure cpu time in
|
|
* the same units as the timebase. Otherwise we measure cpu time
|
|
* in jiffies using the generic definitions.
|
|
*/
|
|
|
|
#ifndef __POWERPC_CPUTIME_H
|
|
#define __POWERPC_CPUTIME_H
|
|
|
|
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/time.h>
|
|
#include <asm/div64.h>
|
|
#include <asm/time.h>
|
|
#include <asm/param.h>
|
|
|
|
typedef u64 __nocast cputime_t;
|
|
typedef u64 __nocast cputime64_t;
|
|
|
|
#define cmpxchg_cputime(ptr, old, new) cmpxchg(ptr, old, new)
|
|
|
|
#ifdef __KERNEL__
|
|
/*
|
|
* Convert cputime <-> microseconds
|
|
*/
|
|
extern u64 __cputime_usec_factor;
|
|
|
|
static inline unsigned long cputime_to_usecs(const cputime_t ct)
|
|
{
|
|
return mulhdu((__force u64) ct, __cputime_usec_factor);
|
|
}
|
|
|
|
/*
|
|
* PPC64 uses PACA which is task independent for storing accounting data while
|
|
* PPC32 uses struct thread_info, therefore at task switch the accounting data
|
|
* has to be populated in the new task
|
|
*/
|
|
#ifdef CONFIG_PPC64
|
|
#define get_accounting(tsk) (&get_paca()->accounting)
|
|
static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
|
|
#else
|
|
#define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
|
|
/*
|
|
* 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
|
|
|
|
#endif /* __KERNEL__ */
|
|
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
|
|
#endif /* __POWERPC_CPUTIME_H */
|