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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 EDB26C64E7A for ; Tue, 1 Dec 2020 13:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96B2520770 for ; Tue, 1 Dec 2020 13:35:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4K4egpat"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oidPvyDT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391123AbgLANfb (ORCPT ); Tue, 1 Dec 2020 08:35:31 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55556 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387723AbgLANfb (ORCPT ); Tue, 1 Dec 2020 08:35:31 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1606829690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qd+SEc9hp97PwahsT1I+aQoYgPiQshE5SVUuDff6QAY=; b=4K4egpat7x6FFRLS3MxurqgpG7jrMD/HV3t3+/NFf0k0hkmt2TfeNHE4TbAModNTHgB4dm 8Fc05SAKaCvhjfh0aY1q/fitC6rUPSSJwC9BIrhjs5W6PKgNggRxY5X6Z5v0vXg/SSClJ5 jj18CaL9+P7+FLidyYuRUAcQLKpDAM3toklVggv2oP5SiEH6pFz1PuRgt+JqdR5Rt4NH8l vxpl+PXfPEOWvcgdMdd+YXUeAbd3BWaJsHLFqr52Ltgv4xerkYkgyaGbn/UxWVgcydz3Tq vJjzCRHROCiudbDHScGYdAJKVKAQ+R7gWkPV89Fxn8HlUuTSonHv92i/40OTFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1606829690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qd+SEc9hp97PwahsT1I+aQoYgPiQshE5SVUuDff6QAY=; b=oidPvyDTpGCvjtth3sCNchXifzxG8IFZQj9dEvwZSNOYf7Ihil4Idl0a6QD91kIESK8o3/ GKVrBAzKppAzuSBQ== To: Frederic Weisbecker Cc: Peter Zijlstra , LKML , Tony Luck , Vasily Gorbik , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Christian Borntraeger , Fenghua Yu , Heiko Carstens Subject: Re: [PATCH 4/5] irqtime: Move irqtime entry accounting after irq offset incrementation In-Reply-To: <20201201114026.GB72897@lothringen> References: <20201201001226.65107-1-frederic@kernel.org> <20201201001226.65107-5-frederic@kernel.org> <20201201092011.GS2414@hirez.programming.kicks-ass.net> <87im9lhibd.fsf@nanos.tec.linutronix.de> <20201201114026.GB72897@lothringen> Date: Tue, 01 Dec 2020 14:34:49 +0100 Message-ID: <87blfdhcp2.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01 2020 at 12:40, Frederic Weisbecker wrote: > On Tue, Dec 01, 2020 at 12:33:26PM +0100, Thomas Gleixner wrote: >> > /* >> > * We do not account for softirq time from ksoftirqd here. >> > * We want to continue accounting softirq time to ksoftirqd thread >> > * in that case, so as not to confuse scheduler with a special task >> > * that do not consume any time, but still wants to run. >> > */ >> > if (pc & HARDIRQ_MASK) >> > irqtime_account_delta(irqtime, delta, CPUTIME_IRQ); >> > else if ((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd()) >> > irqtime_account_delta(irqtime, delta, CPUTIME_SOFTIRQ); >> > } >> >> Why not making all of this explicit instead of these conditionals? > > Hmm, I'm not sure I get what you suggest? Instead of playing games with preeempt count and offsets and checking for ksoftirqd, can't you just have: account_hardirqtime() account_softirqtime() and call them from the right spots. See the below for illustration (it's obviously incomplete). Thanks, tglx --- --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -377,6 +377,7 @@ static inline void invoke_softirq(void) return; if (!force_irqthreads) { + account_softirq_enter_time(current); #ifdef CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK /* * We can safely execute softirq on the current stack if @@ -391,6 +392,7 @@ static inline void invoke_softirq(void) * to prevent from any overrun. */ do_softirq_own_stack(); + account_softirq_exit_time(current); #endif } else { wakeup_softirqd(); @@ -417,7 +419,7 @@ static inline void __irq_exit_rcu(void) #else lockdep_assert_irqs_disabled(); #endif - account_irq_exit_time(current); + account_hardirq_exit_time(current); preempt_count_sub(HARDIRQ_OFFSET); if (!in_interrupt() && local_softirq_pending()) invoke_softirq();