Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp364458rdb; Tue, 5 Dec 2023 07:32:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIy/W/tAhDnzN06nlGGLAKv07AVFDXAVs5X8SaN/DcTHEPGHT6XmHVYziUqpdAnRJfuBcr X-Received: by 2002:a05:6a00:21c9:b0:6b4:c21c:8b56 with SMTP id t9-20020a056a0021c900b006b4c21c8b56mr1315230pfj.23.1701790322397; Tue, 05 Dec 2023 07:32:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701790322; cv=none; d=google.com; s=arc-20160816; b=Hb0X6/SFyMOjK0Z17mHEZch8D7LLPY9BwlEA+hwYWr5/jcTcmRICrgXdAxU95iSKlu UIbLKcGAqAgT+3DAsaVZ0ILWmpUp6qBCm1nryM+lYQal568q5KWOUwlLp+Yhv3rw1P2w YWXxGOykZB2CRz8TYobJQqYQzP0GK/eAajbAoPTM20U66RxS495+eWe71IKvDfOUYVNT gAwtkIra76j4eZy8CyY1UuvvL4A3mA4t6/jwhMjR57MkoUfCe3N4YdGtTeJdIJ0XPdKn 2AykMntWtCMIIDVPtdU/WIy3GeXSFITcE6Y+jFPFsDHpUKwaql1viyz07fcjGofQNFaQ K73Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=hsENTBH9k3W4U1tKsViJ4yf3sg3tGJqqvcy+jJtuHIw=; fh=QiWFnm6a/DROvnTH2EO09dgI2GkNRIpNS73vu8cKsys=; b=mc728FMr1rB2LkhhjEdoXHgpf2ZAkE99e0gJ/nA357jFDzKR6/XqWSfYiUObY/Y854 xyL2DyK/HktQTwb9y0/zKWsV6fco0P8eJAtdu3516osH/LblE/18CYf6+tJUR82OQFUT UhhyjutBsA83Qq/uFhiw3fvL0VCl0UM/PQejNTlIVdnAW36XceO0/KV0jhvz7NLh/WLC mXNyk8vcE9rlJrejry/GtDh47gm5UNCboY7EInBP8+kfQ+3CQfyB00qyEkReJRUaG95x 8fJkZlGAaDmJJV0bII0bWO/x5FECsvRCqDDFtohVDrYx6YLLOz3KVK44ct7S55jBeYjq /mqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ctPBk9QZ; dkim=neutral (no key) header.i=@linutronix.de header.b=wkPYisXJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b15-20020a056a000a8f00b006cb93f13d52si9891734pfl.120.2023.12.05.07.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 07:32:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ctPBk9QZ; dkim=neutral (no key) header.i=@linutronix.de header.b=wkPYisXJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 546378051BAA; Tue, 5 Dec 2023 07:31:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346214AbjLEPbp (ORCPT + 99 others); Tue, 5 Dec 2023 10:31:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346053AbjLEPbo (ORCPT ); Tue, 5 Dec 2023 10:31:44 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DAEC83 for ; Tue, 5 Dec 2023 07:31:50 -0800 (PST) Date: Tue, 5 Dec 2023 16:31:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701790308; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hsENTBH9k3W4U1tKsViJ4yf3sg3tGJqqvcy+jJtuHIw=; b=ctPBk9QZQoJlZUg/dOdzrCYaJDHs2UeXm48QFpAPnGkO3Gz3sim0CAfVOY4sJEv9aN3MFE +LYoFpV2Dqaifl6v8hPSG6JnK1LC0vEzsiXSX7Oa8qg+rPgYDUuzMuA0KGhaYqlyBJVik1 9TBKloWqjbb2lT37khfNokaa02nk4mElcr0X4NCdXkwBg/U7O460z1WMGXIRChLcauNyqz lB2I2bjTgeK625bOQhoVjLoFfxKMme+5afbdBTCMowNwPmG438GzbrGnI9Gn2Vf4BOM06U /ZZLzMIl1bAesU4i81hLE34k/mfuErvpfl4xCLfT1kAtjfyX1bGnIcww97Blkg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701790308; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hsENTBH9k3W4U1tKsViJ4yf3sg3tGJqqvcy+jJtuHIw=; b=wkPYisXJSUVkJtRGEFZe1t5vpSZ3HMKLnj1knsnYBih5Xt6rD6NMW4Of57DpZJofKrkEwf NH8VO457eYBFjjDQ== From: Sebastian Andrzej Siewior To: Yuanhan Zhang Cc: zyhtheonly@yeah.net, tglx@linutronix.de, rostedt@goodmis.org, mingo@redhat.com, Venkatesh Pallipadi , 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 Subject: Re: [PATCH v3] sched/cputime: let ktimers align with ksoftirqd in accounting CPUTIME_SOFTIRQ Message-ID: <20231205153146.OSpCIs1G@linutronix.de> References: <20231201073240.T9bFNCkU@linutronix.de> <20231201080522.GA31309@didi-ThinkCentre-M930t-N000> <20231201161640.Z0cJLUi3@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 05 Dec 2023 07:31:59 -0800 (PST) On 2023-12-02 05:28:15 [-0500], Yuanhan Zhang wrote: > Hi, Hi, > Sebastian Andrzej Siewior =E4=BA=8E2023=E5=B9=B41= 2=E6=9C=881=E6=97=A5=E5=91=A8=E4=BA=94 11:16=E5=86=99=E9=81=93=EF=BC=9A > > > > On 2023-12-01 16:05:41 [+0800], tiozhang wrote: > > > In CONFIG_PREEMPT_RT kernel, ktimers also calls __do_softirq, > > > so when accounting CPUTIME_SOFTIRQ, ktimers need to be accounted the = same > > > as ksoftirqd. > > > > I still don't understand why this is a good thing and why want to align > > it with ksoftirqd and what breaks if we don't. >=20 > My motivation of doing this is to keep CPUTIME_SOFTIRQ in /proc/stat > remaining more accurate in PREEPT_RT kernel. >=20 > If we dont align, ktimers' cpu time is added to CPUTIME_SYSTEM when > CONFIG_IRQ_TIME_ACCOUNTING is enabled, make our stats less accurate.. So it is only SYSTEM? There is no additional SOFTIRQ that is used? > The main diff between ksoftirqd and force-threaded interrupt is that ksof= tirq > is in SOFTIRQ_OFFSET (serving softirqs) while force-threaded is in > SOFTIRQ_DISABLE_OFFSET (by using local_disable_bh). This depends. If you look at a network driver, SOFTIRQ_DISABLE_OFFSET is used during the driver routine doing almost only schedule a softirq. Then the main part happens during SOFTIRQ_OFFSET where the driver pulls the packets and passes them to the network stack. > CPUTIME_SOFTIRQ serves for time in SOFTIRQ_OFFSET (processing softirqs). > See > https://lore.kernel.org/all/1285619753-10892-1-git-send-email-venki@googl= e.com/ Let me look at this later=E2=80=A6 > So this leads to ksoftirqd is counted into CPUTIME_SOFTIRQ but irq-threads > into CPUTIME_SYSTEM. >=20 > Since ktimers is also in SOFTIRQ_OFFSET, align it with ksoftirq will > put it into CPUTIME_SOFTIRQ, making /proc/stat more accurate. But this only works if it is observed during the TICK interrupt, right? Sebastian