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

Commit 38130ec0 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'sched-cputime-for-mingo' of...

Merge tag 'sched-cputime-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks

 into sched/core

Pull more cputime cleanups from Frederic Weisbecker:

 * Get rid of underscores polluting the vtime namespace

 * Consolidate context switch and tick handling

 * Improve debuggability by detecting irq unsafe callers

Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents e783377e 1b2852b1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -103,5 +103,7 @@ static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)
#define cputime64_to_clock_t(__ct)	\
	cputime_to_clock_t((__force cputime_t)__ct)

extern void arch_vtime_task_switch(struct task_struct *tsk);

#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
#endif /* __IA64_CPUTIME_H */
+6 −20
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ static struct clocksource *itc_clocksource;

extern cputime_t cycle_to_cputime(u64 cyc);

static void vtime_account_user(struct task_struct *tsk)
void vtime_account_user(struct task_struct *tsk)
{
	cputime_t delta_utime;
	struct thread_info *ti = task_thread_info(tsk);
@@ -100,18 +100,11 @@ static void vtime_account_user(struct task_struct *tsk)
 * accumulated times to the current process, and to prepare accounting on
 * the next process.
 */
void vtime_task_switch(struct task_struct *prev)
void arch_vtime_task_switch(struct task_struct *prev)
{
	struct thread_info *pi = task_thread_info(prev);
	struct thread_info *ni = task_thread_info(current);

	if (idle_task(smp_processor_id()) != prev)
		__vtime_account_system(prev);
	else
		__vtime_account_idle(prev);

	vtime_account_user(prev);

	pi->ac_stamp = ni->ac_stamp;
	ni->ac_stime = ni->ac_utime = 0;
}
@@ -126,6 +119,8 @@ static cputime_t vtime_delta(struct task_struct *tsk)
	cputime_t delta_stime;
	__u64 now;

	WARN_ON_ONCE(!irqs_disabled());

	now = ia64_get_itc();

	delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp));
@@ -135,27 +130,18 @@ static cputime_t vtime_delta(struct task_struct *tsk)
	return delta_stime;
}

void __vtime_account_system(struct task_struct *tsk)
void vtime_account_system(struct task_struct *tsk)
{
	cputime_t delta = vtime_delta(tsk);

	account_system_time(tsk, 0, delta, delta);
}

void __vtime_account_idle(struct task_struct *tsk)
void vtime_account_idle(struct task_struct *tsk)
{
	account_idle_time(vtime_delta(tsk));
}

/*
 * Called from the timer interrupt handler to charge accumulated user time
 * to the current process.  Must be called with interrupts disabled.
 */
void account_process_tick(struct task_struct *p, int user_tick)
{
	vtime_account_user(p);
}

#endif /* CONFIG_VIRT_CPU_ACCOUNTING */

static irqreturn_t
+2 −0
Original line number Diff line number Diff line
@@ -228,6 +228,8 @@ 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))

static inline void arch_vtime_task_switch(struct task_struct *tsk) { }

#endif /* __KERNEL__ */
#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
#endif /* __POWERPC_CPUTIME_H */
+10 −14
Original line number Diff line number Diff line
@@ -297,6 +297,8 @@ static u64 vtime_delta(struct task_struct *tsk,
	u64 now, nowscaled, deltascaled;
	u64 udelta, delta, user_scaled;

	WARN_ON_ONCE(!irqs_disabled());

	now = mftb();
	nowscaled = read_spurr(now);
	get_paca()->system_time += now - get_paca()->starttime;
@@ -336,7 +338,7 @@ static u64 vtime_delta(struct task_struct *tsk,
	return delta;
}

void __vtime_account_system(struct task_struct *tsk)
void vtime_account_system(struct task_struct *tsk)
{
	u64 delta, sys_scaled, stolen;

@@ -346,7 +348,7 @@ void __vtime_account_system(struct task_struct *tsk)
		account_steal_time(stolen);
}

void __vtime_account_idle(struct task_struct *tsk)
void vtime_account_idle(struct task_struct *tsk)
{
	u64 delta, sys_scaled, stolen;

@@ -355,15 +357,15 @@ void __vtime_account_idle(struct task_struct *tsk)
}

/*
 * Transfer the user and system times accumulated in the paca
 * by the exception entry and exit code to the generic process
 * user and system time records.
 * Transfer the user time accumulated in the paca
 * by the exception entry and exit code to the generic
 * process user time records.
 * Must be called with interrupts disabled.
 * Assumes that vtime_account() has been called recently
 * (i.e. since the last entry from usermode) so that
 * Assumes that vtime_account_system/idle() has been called
 * recently (i.e. since the last entry from usermode) so that
 * get_paca()->user_time_scaled is up to date.
 */
void account_process_tick(struct task_struct *tsk, int user_tick)
void vtime_account_user(struct task_struct *tsk)
{
	cputime_t utime, utimescaled;

@@ -375,12 +377,6 @@ void account_process_tick(struct task_struct *tsk, int user_tick)
	account_user_time(tsk, utime, utimescaled);
}

void vtime_task_switch(struct task_struct *prev)
{
	vtime_account(prev);
	account_process_tick(prev, 0);
}

#else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
#define calc_cputime_factors()
#endif
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@


#define __ARCH_HAS_VTIME_ACCOUNT
#define __ARCH_HAS_VTIME_TASK_SWITCH

/* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */

Loading