powerpc32: provide VIRT_CPU_ACCOUNTING
This patch provides VIRT_CPU_ACCOUTING to PPC32 architecture. PPC32 doesn't have the PACA structure, so we use the task_info structure to store the accounting data. In order to reuse on PPC32 the PPC64 functions, all u64 data has been replaced by 'unsigned long' so that it is u32 on PPC32 and u64 on PPC64 Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Scott Wood <oss@buserror.net>
This commit is contained in:

committed by
Scott Wood

parent
1afbf61750
commit
c223c90386
24
arch/powerpc/include/asm/accounting.h
Normal file
24
arch/powerpc/include/asm/accounting.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Common time accounting prototypes and such for all ppc machines.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __POWERPC_ACCOUNTING_H
|
||||
#define __POWERPC_ACCOUNTING_H
|
||||
|
||||
/* Stuff for accurate time accounting */
|
||||
struct cpu_accounting_data {
|
||||
unsigned long user_time; /* accumulated usermode TB ticks */
|
||||
unsigned long system_time; /* accumulated system TB ticks */
|
||||
unsigned long user_time_scaled; /* accumulated usermode SPURR ticks */
|
||||
unsigned long starttime; /* TB value snapshot */
|
||||
unsigned long starttime_user; /* TB value on exit to usermode */
|
||||
unsigned long startspurr; /* SPURR value snapshot */
|
||||
unsigned long utime_sspurr; /* ->user_time when ->startspurr set */
|
||||
};
|
||||
|
||||
#endif
|
@@ -90,11 +90,10 @@ static inline void setup_cputime_one_jiffy(void)
|
||||
static inline cputime64_t jiffies64_to_cputime64(const u64 jif)
|
||||
{
|
||||
u64 ct;
|
||||
u64 sec;
|
||||
u64 sec = jif;
|
||||
|
||||
/* have to be a little careful about overflow */
|
||||
ct = jif % HZ;
|
||||
sec = jif / HZ;
|
||||
ct = do_div(sec, HZ);
|
||||
if (ct) {
|
||||
ct *= tb_ticks_per_sec;
|
||||
do_div(ct, HZ);
|
||||
@@ -230,7 +229,16 @@ static inline cputime_t clock_t_to_cputime(const unsigned long clk)
|
||||
|
||||
#define cputime64_to_clock_t(ct) cputime_to_clock_t((cputime_t)(ct))
|
||||
|
||||
/*
|
||||
* 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
|
||||
static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
|
||||
#else
|
||||
void arch_vtime_task_switch(struct task_struct *tsk);
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
|
||||
|
@@ -287,7 +287,7 @@ do_kvm_##n: \
|
||||
std r0,GPR0(r1); /* save r0 in stackframe */ \
|
||||
std r10,GPR1(r1); /* save r1 in stackframe */ \
|
||||
beq 4f; /* if from kernel mode */ \
|
||||
ACCOUNT_CPU_USER_ENTRY(r9, r10); \
|
||||
ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \
|
||||
SAVE_PPR(area, r9, r10); \
|
||||
4: EXCEPTION_PROLOG_COMMON_2(area) \
|
||||
EXCEPTION_PROLOG_COMMON_3(n) \
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
|
||||
#include <asm/kvm_book3s_asm.h>
|
||||
#endif
|
||||
#include <asm/accounting.h>
|
||||
|
||||
register struct paca_struct *local_paca asm("r13");
|
||||
|
||||
@@ -184,13 +185,7 @@ struct paca_struct {
|
||||
#endif
|
||||
|
||||
/* Stuff for accurate time accounting */
|
||||
u64 user_time; /* accumulated usermode TB ticks */
|
||||
u64 system_time; /* accumulated system TB ticks */
|
||||
u64 user_time_scaled; /* accumulated usermode SPURR ticks */
|
||||
u64 starttime; /* TB value snapshot */
|
||||
u64 starttime_user; /* TB value on exit to usermode */
|
||||
u64 startspurr; /* SPURR value snapshot */
|
||||
u64 utime_sspurr; /* ->user_time when ->startspurr set */
|
||||
struct cpu_accounting_data accounting;
|
||||
u64 stolen_time; /* TB ticks taken by hypervisor */
|
||||
u64 dtl_ridx; /* read index in dispatch log */
|
||||
struct dtl_entry *dtl_curr; /* pointer corresponding to dtl_ridx */
|
||||
|
@@ -24,27 +24,27 @@
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
|
||||
#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
|
||||
#define ACCOUNT_CPU_USER_EXIT(ra, rb)
|
||||
#define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb)
|
||||
#define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb)
|
||||
#define ACCOUNT_STOLEN_TIME
|
||||
#else
|
||||
#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
|
||||
#define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb) \
|
||||
MFTB(ra); /* get timebase */ \
|
||||
ld rb,PACA_STARTTIME_USER(r13); \
|
||||
std ra,PACA_STARTTIME(r13); \
|
||||
PPC_LL rb, ACCOUNT_STARTTIME_USER(ptr); \
|
||||
PPC_STL ra, ACCOUNT_STARTTIME(ptr); \
|
||||
subf rb,rb,ra; /* subtract start value */ \
|
||||
ld ra,PACA_USER_TIME(r13); \
|
||||
PPC_LL ra, ACCOUNT_USER_TIME(ptr); \
|
||||
add ra,ra,rb; /* add on to user time */ \
|
||||
std ra,PACA_USER_TIME(r13); \
|
||||
PPC_STL ra, ACCOUNT_USER_TIME(ptr); \
|
||||
|
||||
#define ACCOUNT_CPU_USER_EXIT(ra, rb) \
|
||||
#define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb) \
|
||||
MFTB(ra); /* get timebase */ \
|
||||
ld rb,PACA_STARTTIME(r13); \
|
||||
std ra,PACA_STARTTIME_USER(r13); \
|
||||
PPC_LL rb, ACCOUNT_STARTTIME(ptr); \
|
||||
PPC_STL ra, ACCOUNT_STARTTIME_USER(ptr); \
|
||||
subf rb,rb,ra; /* subtract start value */ \
|
||||
ld ra,PACA_SYSTEM_TIME(r13); \
|
||||
PPC_LL ra, ACCOUNT_SYSTEM_TIME(ptr); \
|
||||
add ra,ra,rb; /* add on to system time */ \
|
||||
std ra,PACA_SYSTEM_TIME(r13)
|
||||
PPC_STL ra, ACCOUNT_SYSTEM_TIME(ptr)
|
||||
|
||||
#ifdef CONFIG_PPC_SPLPAR
|
||||
#define ACCOUNT_STOLEN_TIME \
|
||||
|
@@ -1294,6 +1294,7 @@ static inline unsigned long mfvtb (void)
|
||||
asm volatile("mfspr %0, %1" : "=r" (rval) : \
|
||||
"i" (SPRN_TBRU)); rval;})
|
||||
#endif
|
||||
#define mftb() mftbl()
|
||||
#endif /* !__powerpc64__ */
|
||||
|
||||
#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <asm/processor.h>
|
||||
#include <asm/page.h>
|
||||
#include <linux/stringify.h>
|
||||
#include <asm/accounting.h>
|
||||
|
||||
/*
|
||||
* low level task data.
|
||||
@@ -45,6 +46,9 @@ struct thread_info {
|
||||
unsigned long local_flags; /* private flags for thread */
|
||||
#ifdef CONFIG_LIVEPATCH
|
||||
unsigned long *livepatch_sp;
|
||||
#endif
|
||||
#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
|
||||
struct cpu_accounting_data accounting;
|
||||
#endif
|
||||
/* low level flags - has atomic operations done on it */
|
||||
unsigned long flags ____cacheline_aligned_in_smp;
|
||||
|
Reference in New Issue
Block a user