Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c223c903 authored by Christophe Leroy's avatar Christophe Leroy Committed by Scott Wood
Browse files

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: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarScott Wood <oss@buserror.net>
parent 1afbf617
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ config PPC
	select ARCH_HAS_UBSAN_SANITIZE_ALL
	select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT
	select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS
	select HAVE_VIRT_CPU_ACCOUNTING

config GENERIC_CSUM
	def_bool CPU_LITTLE_ENDIAN
+24 −0
Original line number Diff line number Diff line
/*
 * 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
+11 −3
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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)					   \
+2 −7
Original line number Diff line number Diff line
@@ -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 */
Loading