Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp858244rdh; Thu, 23 Nov 2023 22:38:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6wSfgq/sbjOWZfsQnDRqH+KXcfK7Izi8CQYkIJYn9AVfy/poTjlu7c7kWHG6dk7SolghE X-Received: by 2002:a17:902:ea03:b0:1cf:59df:23e with SMTP id s3-20020a170902ea0300b001cf59df023emr1912579plg.12.1700807904487; Thu, 23 Nov 2023 22:38:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700807904; cv=none; d=google.com; s=arc-20160816; b=N15KRXpMBt3HWzwCBqzJwWHZV0mO78sXo+RriTuVcwXCfyRgF7G9cddkVQIChwQGxi 4bWIHFa0rfCDFrQ2I6f9hQDMbQIYb4CLJRafKI2lmQcwV2+p/NA1yy9lrsYy9yGoi0E9 Kx5SfMZ7pUKvD1NjHOgaV401Xe1h4ZCHs7ed7W0kmV7W+6l5NRjQi+qx7p0yvVRnFFkR 4uNHOH7OCn4MuhpgUKOhIavZYyg9Pj/Aus9JMciVKmEvLuXAb+i75Kj22gI89nY7X3X0 G/r4WsxN8b/VE8UwEdfsVpoI5DF4s/+8Xuo/b7FjTZVv6iVzr3/3hgR0vDVaod9pDYsB u3ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :mail-followup-to:message-id:subject:cc:to:from:date; bh=aG+kTYPmPQAviRi8Hxwo8bTpzsbZvRNqsFdMiQp5wzY=; fh=uXBp9heUwR68xnOwG4S40A8HAdDYWJMCROb9t+9sw4U=; b=PJs7my2haJCf1F3jJly06pltnSVtmIIH5STRGkKdzoWBiLWryohR831tLwn1mbZjf4 tOFhAC5VJuRKhpKngA2l5FntSSM+rQUSYHfobXYp1hTDNvQgaQIDWHiEkNYJXTWN4Bj9 OP5VAmyfmMMeK6BL0zijiJZtGEC0/yWgSWKX7+afAUjEVqwITi5cziYruj/DMNRL7DE3 oUUrGdhAPxUljATysGN14mu33rwtD0VoU7U8xguBS9vTEBFQOofikTvFfXNWdcNsYB61 mF7KeI+dr9328YZGA8Il1eT3vgFnvc47plMKThFLZQI9a4F5/AR+E8eBIDqIdyJOj1Y+ 6Vxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 6-20020a170902ee4600b001cf77931eb1si2700052plo.4.2023.11.23.22.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:38:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 47D79806155B; Thu, 23 Nov 2023 22:38:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbjKXGiD (ORCPT + 99 others); Fri, 24 Nov 2023 01:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjKXGiC (ORCPT ); Fri, 24 Nov 2023 01:38:02 -0500 X-Greylist: delayed 181 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 23 Nov 2023 22:38:07 PST Received: from mx10.didiglobal.com (mx10.didiglobal.com [111.202.70.125]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6B3B1B0 for ; Thu, 23 Nov 2023 22:38:07 -0800 (PST) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx10.didiglobal.com (MailData Gateway V2.8.8) with ESMTPS id 23A48192934F33; Fri, 24 Nov 2023 14:35:00 +0800 (CST) Received: from didi-ThinkCentre-M930t-N000 (10.79.64.101) by ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 24 Nov 2023 14:34:59 +0800 Date: Fri, 24 Nov 2023 14:34:50 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: tiozhang To: , , , , , , CC: , , , , , , , , , Subject: [PATCH] sched/cputime: exclude ktimer threads in irqtime_account_irq Message-ID: <20231124063450.GA18089@didi-ThinkCentre-M930t-N000> Mail-Followup-To: bigeasy@linutronix.de, tglx@linutronix.de, rostedt@goodmis.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, zyhtheonly@gmail.com, zyhtheonly@yeah.net MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.79.64.101] X-ClientProxiedBy: ZJY01-PUBMBX-01.didichuxing.com (10.79.64.32) To ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:38:22 -0800 (PST) In CONFIG_PREEMPT_RT kernel, ktimer threads need to be excluded as well as ksoftirqd when accounting CPUTIME_SOFTIRQ in irqtime_account_irq. Also add this_cpu_ktimers to keep consistency with this_cpu_ksoftirqd. Signed-off-by: tiozhang --- include/linux/interrupt.h | 5 +++++ kernel/sched/cputime.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a5091ac97fc6..a88646acaf3f 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -621,6 +621,11 @@ static inline unsigned int local_pending_timers(void) return __this_cpu_read(pending_timer_softirq); } +static inline struct task_struct *this_cpu_ktimers(void) +{ + return this_cpu_read(timersd); +} + #else static inline void raise_timer_softirq(void) { diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index af7952f12e6c..0fac0109d151 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -73,7 +73,12 @@ void irqtime_account_irq(struct task_struct *curr, unsigned int offset) */ if (pc & HARDIRQ_MASK) irqtime_account_delta(irqtime, delta, CPUTIME_IRQ); +#ifdef CONFIG_PREEMPT_RT + else if ((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd() + && curr != this_cpu_ktimers()) +#else else if ((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd()) +#endif irqtime_account_delta(irqtime, delta, CPUTIME_SOFTIRQ); } -- 2.17.1