sched/cputime: Rename vtime_account_system() to vtime_account_kernel()
vtime_account_system() decides if we need to account the time to the system (__vtime_account_system()) or to the guest (vtime_account_guest()). So this function is a misnomer as we are on a higher level than "system". All we know when we call that function is that we are accounting kernel cputime. Whether it belongs to guest or system time is a lower level detail. Rename this function to vtime_account_kernel(). This will clarify things and avoid too many underscored vtime_account_system() versions. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wanpeng Li <wanpengli@tencent.com> Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Link: https://lkml.kernel.org/r/20191003161745.28464-2-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
68e7a4d66b
commit
f83eeb1a01
@ -132,7 +132,7 @@ static __u64 vtime_delta(struct task_struct *tsk)
|
|||||||
return delta_stime;
|
return delta_stime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtime_account_system(struct task_struct *tsk)
|
void vtime_account_kernel(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
struct thread_info *ti = task_thread_info(tsk);
|
struct thread_info *ti = task_thread_info(tsk);
|
||||||
__u64 stime = vtime_delta(tsk);
|
__u64 stime = vtime_delta(tsk);
|
||||||
@ -146,7 +146,7 @@ void vtime_account_system(struct task_struct *tsk)
|
|||||||
else
|
else
|
||||||
ti->stime += stime;
|
ti->stime += stime;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vtime_account_system);
|
EXPORT_SYMBOL_GPL(vtime_account_kernel);
|
||||||
|
|
||||||
void vtime_account_idle(struct task_struct *tsk)
|
void vtime_account_idle(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
|
@ -338,7 +338,7 @@ static unsigned long vtime_delta(struct task_struct *tsk,
|
|||||||
return stime;
|
return stime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtime_account_system(struct task_struct *tsk)
|
void vtime_account_kernel(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
unsigned long stime, stime_scaled, steal_time;
|
unsigned long stime, stime_scaled, steal_time;
|
||||||
struct cpu_accounting_data *acct = get_accounting(tsk);
|
struct cpu_accounting_data *acct = get_accounting(tsk);
|
||||||
@ -366,7 +366,7 @@ void vtime_account_system(struct task_struct *tsk)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vtime_account_system);
|
EXPORT_SYMBOL_GPL(vtime_account_kernel);
|
||||||
|
|
||||||
void vtime_account_idle(struct task_struct *tsk)
|
void vtime_account_idle(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
@ -395,7 +395,7 @@ static void vtime_flush_scaled(struct task_struct *tsk,
|
|||||||
/*
|
/*
|
||||||
* Account the whole cputime accumulated in the paca
|
* Account the whole cputime accumulated in the paca
|
||||||
* Must be called with interrupts disabled.
|
* Must be called with interrupts disabled.
|
||||||
* Assumes that vtime_account_system/idle() has been called
|
* Assumes that vtime_account_kernel/idle() has been called
|
||||||
* recently (i.e. since the last entry from usermode) so that
|
* recently (i.e. since the last entry from usermode) so that
|
||||||
* get_paca()->user_time_scaled is up to date.
|
* get_paca()->user_time_scaled is up to date.
|
||||||
*/
|
*/
|
||||||
|
@ -247,9 +247,9 @@ void vtime_account_irq_enter(struct task_struct *tsk)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
|
EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
|
||||||
|
|
||||||
void vtime_account_system(struct task_struct *tsk)
|
void vtime_account_kernel(struct task_struct *tsk)
|
||||||
__attribute__((alias("vtime_account_irq_enter")));
|
__attribute__((alias("vtime_account_irq_enter")));
|
||||||
EXPORT_SYMBOL_GPL(vtime_account_system);
|
EXPORT_SYMBOL_GPL(vtime_account_kernel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sorted add to a list. List is linear searched until first bigger
|
* Sorted add to a list. List is linear searched until first bigger
|
||||||
|
@ -141,7 +141,7 @@ static inline void guest_enter_irqoff(void)
|
|||||||
* to assume that it's the stime pending cputime
|
* to assume that it's the stime pending cputime
|
||||||
* to flush.
|
* to flush.
|
||||||
*/
|
*/
|
||||||
vtime_account_system(current);
|
vtime_account_kernel(current);
|
||||||
current->flags |= PF_VCPU;
|
current->flags |= PF_VCPU;
|
||||||
rcu_virt_note_context_switch(smp_processor_id());
|
rcu_virt_note_context_switch(smp_processor_id());
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ static inline void guest_enter_irqoff(void)
|
|||||||
static inline void guest_exit_irqoff(void)
|
static inline void guest_exit_irqoff(void)
|
||||||
{
|
{
|
||||||
/* Flush the guest cputime we spent on the guest */
|
/* Flush the guest cputime we spent on the guest */
|
||||||
vtime_account_system(current);
|
vtime_account_kernel(current);
|
||||||
current->flags &= ~PF_VCPU;
|
current->flags &= ~PF_VCPU;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */
|
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */
|
||||||
|
@ -57,13 +57,13 @@ static inline void vtime_task_switch(struct task_struct *prev)
|
|||||||
}
|
}
|
||||||
#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
|
#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
|
||||||
|
|
||||||
extern void vtime_account_system(struct task_struct *tsk);
|
extern void vtime_account_kernel(struct task_struct *tsk);
|
||||||
extern void vtime_account_idle(struct task_struct *tsk);
|
extern void vtime_account_idle(struct task_struct *tsk);
|
||||||
|
|
||||||
#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
|
#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
|
||||||
|
|
||||||
static inline void vtime_task_switch(struct task_struct *prev) { }
|
static inline void vtime_task_switch(struct task_struct *prev) { }
|
||||||
static inline void vtime_account_system(struct task_struct *tsk) { }
|
static inline void vtime_account_kernel(struct task_struct *tsk) { }
|
||||||
#endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
|
#endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
|
||||||
|
|
||||||
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
||||||
@ -86,7 +86,7 @@ extern void vtime_account_irq_enter(struct task_struct *tsk);
|
|||||||
static inline void vtime_account_irq_exit(struct task_struct *tsk)
|
static inline void vtime_account_irq_exit(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
/* On hard|softirq exit we always account to hard|softirq cputime */
|
/* On hard|softirq exit we always account to hard|softirq cputime */
|
||||||
vtime_account_system(tsk);
|
vtime_account_kernel(tsk);
|
||||||
}
|
}
|
||||||
extern void vtime_flush(struct task_struct *tsk);
|
extern void vtime_flush(struct task_struct *tsk);
|
||||||
#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
|
#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
|
||||||
|
@ -412,7 +412,7 @@ void vtime_common_task_switch(struct task_struct *prev)
|
|||||||
if (is_idle_task(prev))
|
if (is_idle_task(prev))
|
||||||
vtime_account_idle(prev);
|
vtime_account_idle(prev);
|
||||||
else
|
else
|
||||||
vtime_account_system(prev);
|
vtime_account_kernel(prev);
|
||||||
|
|
||||||
vtime_flush(prev);
|
vtime_flush(prev);
|
||||||
arch_vtime_task_switch(prev);
|
arch_vtime_task_switch(prev);
|
||||||
@ -425,7 +425,7 @@ void vtime_common_task_switch(struct task_struct *prev)
|
|||||||
/*
|
/*
|
||||||
* Archs that account the whole time spent in the idle task
|
* Archs that account the whole time spent in the idle task
|
||||||
* (outside irq) as idle time can rely on this and just implement
|
* (outside irq) as idle time can rely on this and just implement
|
||||||
* vtime_account_system() and vtime_account_idle(). Archs that
|
* vtime_account_kernel() and vtime_account_idle(). Archs that
|
||||||
* have other meaning of the idle time (s390 only includes the
|
* have other meaning of the idle time (s390 only includes the
|
||||||
* time spent by the CPU when it's in low power mode) must override
|
* time spent by the CPU when it's in low power mode) must override
|
||||||
* vtime_account().
|
* vtime_account().
|
||||||
@ -436,7 +436,7 @@ void vtime_account_irq_enter(struct task_struct *tsk)
|
|||||||
if (!in_interrupt() && is_idle_task(tsk))
|
if (!in_interrupt() && is_idle_task(tsk))
|
||||||
vtime_account_idle(tsk);
|
vtime_account_idle(tsk);
|
||||||
else
|
else
|
||||||
vtime_account_system(tsk);
|
vtime_account_kernel(tsk);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
|
EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
|
||||||
#endif /* __ARCH_HAS_VTIME_ACCOUNT */
|
#endif /* __ARCH_HAS_VTIME_ACCOUNT */
|
||||||
@ -711,8 +711,8 @@ static u64 get_vtime_delta(struct vtime *vtime)
|
|||||||
return delta - other;
|
return delta - other;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __vtime_account_system(struct task_struct *tsk,
|
static void vtime_account_system(struct task_struct *tsk,
|
||||||
struct vtime *vtime)
|
struct vtime *vtime)
|
||||||
{
|
{
|
||||||
vtime->stime += get_vtime_delta(vtime);
|
vtime->stime += get_vtime_delta(vtime);
|
||||||
if (vtime->stime >= TICK_NSEC) {
|
if (vtime->stime >= TICK_NSEC) {
|
||||||
@ -731,7 +731,7 @@ static void vtime_account_guest(struct task_struct *tsk,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtime_account_system(struct task_struct *tsk)
|
void vtime_account_kernel(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
struct vtime *vtime = &tsk->vtime;
|
struct vtime *vtime = &tsk->vtime;
|
||||||
|
|
||||||
@ -743,7 +743,7 @@ void vtime_account_system(struct task_struct *tsk)
|
|||||||
if (tsk->flags & PF_VCPU)
|
if (tsk->flags & PF_VCPU)
|
||||||
vtime_account_guest(tsk, vtime);
|
vtime_account_guest(tsk, vtime);
|
||||||
else
|
else
|
||||||
__vtime_account_system(tsk, vtime);
|
vtime_account_system(tsk, vtime);
|
||||||
write_seqcount_end(&vtime->seqcount);
|
write_seqcount_end(&vtime->seqcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +752,7 @@ void vtime_user_enter(struct task_struct *tsk)
|
|||||||
struct vtime *vtime = &tsk->vtime;
|
struct vtime *vtime = &tsk->vtime;
|
||||||
|
|
||||||
write_seqcount_begin(&vtime->seqcount);
|
write_seqcount_begin(&vtime->seqcount);
|
||||||
__vtime_account_system(tsk, vtime);
|
vtime_account_system(tsk, vtime);
|
||||||
vtime->state = VTIME_USER;
|
vtime->state = VTIME_USER;
|
||||||
write_seqcount_end(&vtime->seqcount);
|
write_seqcount_end(&vtime->seqcount);
|
||||||
}
|
}
|
||||||
@ -782,7 +782,7 @@ void vtime_guest_enter(struct task_struct *tsk)
|
|||||||
* that can thus safely catch up with a tickless delta.
|
* that can thus safely catch up with a tickless delta.
|
||||||
*/
|
*/
|
||||||
write_seqcount_begin(&vtime->seqcount);
|
write_seqcount_begin(&vtime->seqcount);
|
||||||
__vtime_account_system(tsk, vtime);
|
vtime_account_system(tsk, vtime);
|
||||||
tsk->flags |= PF_VCPU;
|
tsk->flags |= PF_VCPU;
|
||||||
write_seqcount_end(&vtime->seqcount);
|
write_seqcount_end(&vtime->seqcount);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user