lkml.org 
[lkml]   [2020]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/5] s390/vtime: Convert to consolidated IRQ time accounting
    Date
    s390 has its own version of IRQ time accounting because it doesn't
    account the idle time the same way the other architectures do. Only
    the actual idle sleep time is accounted as idle time, the rest of the
    idle task execution is accounted as system time.

    However converting it to the consolidated IRQ time accounting is easy:
    just keep the current behaviour and redirect generic idle time
    accounting to system time accounting.

    This removes the need to maintain an ad-hoc implementation of cputime
    dispatch decision.

    Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    ---
    arch/s390/include/asm/vtime.h | 1 -
    arch/s390/kernel/vtime.c | 54 +++++++++++++++++++++++------------
    kernel/sched/cputime.c | 2 --
    3 files changed, 35 insertions(+), 22 deletions(-)

    diff --git a/arch/s390/include/asm/vtime.h b/arch/s390/include/asm/vtime.h
    index 3622d4ebc73a..fac6a67988eb 100644
    --- a/arch/s390/include/asm/vtime.h
    +++ b/arch/s390/include/asm/vtime.h
    @@ -2,7 +2,6 @@
    #ifndef _S390_VTIME_H
    #define _S390_VTIME_H

    -#define __ARCH_HAS_VTIME_ACCOUNT
    #define __ARCH_HAS_VTIME_TASK_SWITCH

    #endif /* _S390_VTIME_H */
    diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
    index e043808a1488..ab75aab7f8cf 100644
    --- a/arch/s390/kernel/vtime.c
    +++ b/arch/s390/kernel/vtime.c
    @@ -222,36 +222,52 @@ void vtime_flush(struct task_struct *tsk)
    S390_lowcore.avg_steal_timer = avg_steal;
    }

    -/*
    - * Update process times based on virtual cpu times stored by entry.S
    - * to the lowcore fields user_timer, system_timer & steal_clock.
    - */
    -void vtime_account_kernel(struct task_struct *tsk)
    +static u64 vtime_delta(void)
    {
    - u64 timer;
    + u64 timer = S390_lowcore.last_update_timer;

    - timer = S390_lowcore.last_update_timer;
    S390_lowcore.last_update_timer = get_vtimer();
    - timer -= S390_lowcore.last_update_timer;

    - if ((tsk->flags & PF_VCPU) && (irq_count() == 0))
    - S390_lowcore.guest_timer += timer;
    - else if (hardirq_count())
    - S390_lowcore.hardirq_timer += timer;
    - else if (in_serving_softirq())
    - S390_lowcore.softirq_timer += timer;
    + return timer - S390_lowcore.last_update_timer;
    +}
    +
    +/*
    + * Update process times based on virtual cpu times stored by entry.S
    + * to the lowcore fields user_timer, system_timer & steal_clock.
    + */
    +void vtime_account_kernel(struct task_struct *tsk)
    +{
    + u64 delta = vtime_delta();
    +
    + if (tsk->flags & PF_VCPU)
    + S390_lowcore.guest_timer += delta;
    else
    - S390_lowcore.system_timer += timer;
    + S390_lowcore.system_timer += delta;

    - virt_timer_forward(timer);
    + virt_timer_forward(delta);
    }
    EXPORT_SYMBOL_GPL(vtime_account_kernel);

    -void vtime_account_irq_enter(struct task_struct *tsk)
    +void vtime_account_idle(struct task_struct *tsk)
    __attribute__((alias("vtime_account_kernel")));

    -void vtime_account_irq_exit(struct task_struct *tsk)
    -__attribute__((alias("vtime_account_kernel")));
    +void vtime_account_softirq(struct task_struct *tsk)
    +{
    + u64 delta = vtime_delta();
    +
    + S390_lowcore.softirq_timer += delta;
    +
    + virt_timer_forward(delta);
    +}
    +
    +void vtime_account_hardirq(struct task_struct *tsk)
    +{
    + u64 delta = vtime_delta();
    +
    + S390_lowcore.hardirq_timer += delta;
    +
    + virt_timer_forward(delta);
    +}

    /*
    * Sorted add to a list. List is linear searched until first bigger
    diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
    index 65efde4d0dca..3675452f6029 100644
    --- a/kernel/sched/cputime.c
    +++ b/kernel/sched/cputime.c
    @@ -425,7 +425,6 @@ void vtime_task_switch(struct task_struct *prev)
    * time spent by the CPU when it's in low power mode) must override
    * vtime_account().
    */
    -#ifndef __ARCH_HAS_VTIME_ACCOUNT
    void vtime_account_irq_enter(struct task_struct *tsk)
    {
    if (hardirq_count()) {
    @@ -449,7 +448,6 @@ void vtime_account_irq_exit(struct task_struct *tsk)
    vtime_account_softirq(tsk);
    }
    }
    -#endif /* __ARCH_HAS_VTIME_ACCOUNT */

    void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev,
    u64 *ut, u64 *st)
    --
    2.25.1
    \
     
     \ /
      Last update: 2020-12-01 01:14    [W:2.634 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site