From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E97C71156 for ; Tue, 1 Dec 2020 00:13:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FC7A20706 for ; Tue, 1 Dec 2020 00:13:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="h9TkREFR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388909AbgLAAN0 (ORCPT ); Mon, 30 Nov 2020 19:13:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:52518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388125AbgLAANZ (ORCPT ); Mon, 30 Nov 2020 19:13:25 -0500 Received: from localhost.localdomain (mtl93-h04-176-174-252-224.dsl.sta.abo.bbox.fr [176.174.252.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 503A52085B; Tue, 1 Dec 2020 00:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606781565; bh=GgVbpevT/n60i/P4ZCWit8Z8Kx3mPuJwp/x/1HOiuzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h9TkREFRvrvxIuXAtm2MZCjZTcictgjDpmSVT7b+Krv8cqblBJFC+yIsDX61iJtmq yBfyt387UFwwNn6aBRjhIDaF7njU9lLoTYqz01AAzsJQ6nrn4HeZ8+7aA1rCFZ6hQ+ ME3ahPRupwP9kdy12Y91wWEP5epfs9wBXqXKVpoA= From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker , Tony Luck , Peter Zijlstra , Vasily Gorbik , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Christian Borntraeger , Fenghua Yu , Heiko Carstens Subject: [PATCH 3/5] s390/vtime: Convert to consolidated IRQ time accounting Date: Tue, 1 Dec 2020 01:12:24 +0100 Message-Id: <20201201001226.65107-4-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201201001226.65107-1-frederic@kernel.org> References: <20201201001226.65107-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Peter Zijlstra Cc: Tony Luck Cc: Fenghua Yu Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger --- 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