Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1812506rdb; Thu, 7 Dec 2023 09:20:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtH7xfTFvqNoyeI3Od6XsQcpfvCdGLuF2SL0lpWfjW/6JuIhsFDWauTd+cMVvXIisCV3H2 X-Received: by 2002:a17:90b:305:b0:286:6cc1:2cd8 with SMTP id ay5-20020a17090b030500b002866cc12cd8mr2399420pjb.98.1701969602800; Thu, 07 Dec 2023 09:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701969602; cv=none; d=google.com; s=arc-20160816; b=bHNdZSU2h9zS4HGs/+1Vr0rrXmyqe3DEE5qeYXXsWEZAVxwX5/Nz5bskoT/eeAkAu8 BdDdBeTRqeUbCHzrUqnbYkbZ4IEWPuYag8gC+sOqTZc4cskF3aPU33X2y2oE4Qil3U8Y ARQJj9+iI54TolzG+WhTobXIifGRfkfuk+QBLVaD4tVrfrHC+fXH3z8Mhnfjmg4HzYrU dh6OALC/KVSE7w18DGuSfHM9OxRQCnKQgcUd0MOt/MWBh5GsCAl1/mpSA6hc1qAJqW1e ovc5TDbC9SCwMQwxTnaFhK0SvE7QYxmErM//C4Oh2VkQShdZcJiNe0UCdT8Os1jw9mn3 4heQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sFzsTwNY0X8LjrwdrZy2AmY/Xkfl1V4/oogMUAjar04=; fh=UBVDp5Y+Pg6WN7x68l3z4EFkIAh5wsLxp2tKfLhKct8=; b=ar5cqMOsbxIBw8YsFwpchF/zOcJHqXWxELhsInttlDfzHxmijU9T4x5BZKJpGlqs/2 WqK6V2eIKD9/9ns9xEJfLyTVvktxL3Z80u14T1wtqCSEyj+OceJXiUX+Wdf/4ZM4udj4 haEhq3JIv5k3NuloZg39jjGuNnk/5W99WsoVwW93FwScWdgIbT2zzxF5rEfV3+Sgb+vT 03w71Ew1kwwry2ahdwRLyl7N8RMhK5LWxUCbhTpCFozcs7hfMnFefrHxZduB2NMIkQ0D 0sPNbfpqwp1NJOiybivte079j5x6gjKODoGeqP2MQkBmkcPtA8Y9O8gE3kUGrhTnnuQA MqFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ywd5fwnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id pi9-20020a17090b1e4900b00286a07a20b0si152783pjb.86.2023.12.07.09.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:20:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ywd5fwnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C701F80658DB; Thu, 7 Dec 2023 09:19:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443167AbjLGRTj (ORCPT + 99 others); Thu, 7 Dec 2023 12:19:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232030AbjLGRTi (ORCPT ); Thu, 7 Dec 2023 12:19:38 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F7BA3 for ; Thu, 7 Dec 2023 09:19:44 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c9efa1ab7fso13053771fa.0 for ; Thu, 07 Dec 2023 09:19:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701969582; x=1702574382; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sFzsTwNY0X8LjrwdrZy2AmY/Xkfl1V4/oogMUAjar04=; b=Ywd5fwnQ+lQ2RomSew7SeP+MTXAsQWKwoLx4W94dp8lV8+0yfunWuy1bDvBPu6Fppe RsoZsEYYw0S1A2ki9y6y8QvLKN6tx/lE1LwycsEI7HuPNMMBhgAXWtdecMcIxMeO79T0 w3QrkZmfKYMewbKnv5IlINGSU+GkccmyKZ+rHD20f8D0m/h3bOdWrVEA7Yaxa13H0XwN gkTw6fDARnCvood4YvKxOtvyXgBYJufpViD928mTwRSLBf3qpv+IknH3DX+YCfovUXUt gzGSOSNlP8sZMUSPsivxXBOmldx4/l1t+YONGgq/kczfaSZhbSeTUwZlIzjPrYTmKwc7 DATw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701969582; x=1702574382; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sFzsTwNY0X8LjrwdrZy2AmY/Xkfl1V4/oogMUAjar04=; b=EezI1/7xdoSuS1kPi9fq18vD04a2XGp/w8f80MpCvWGLu8W/D/O2wcPEVQrlnOHtiY X5WhU8Ibo2UJFyb4KM9l3ELttxyHuS4MgpnvYy10WCBF4zremMPN6DjAxZjuov187gQB ix+Mj55OjDwraI27JxRyHUPWDuaT7Y9uL2HK4bu6LhHlNfUjghyuy2JVvFxNc1wyUwt/ fBmtyYqQOhF+ukxeQEUY2xwgUjrXKUx04W+uAyfT+tr/KH/MQISCG18UR/MwhIVLotNd odTFfdt50l8b4YLBsayMEdF64UzhNQK6AgYrEKFHW0fzmcGCoRoRIPFKPo0eOX4fGTiH JsvA== X-Gm-Message-State: AOJu0Yzyz57kjMut8JSrn4jXqmeD5+kiZfpYAPug4chA9m45GyoYL1h4 TIhcBu3VrFEhUyAPxUnwtth9xtwqnqyrZkYIZ+Q= X-Received: by 2002:a2e:ba09:0:b0:2ca:2912:bd07 with SMTP id p9-20020a2eba09000000b002ca2912bd07mr666400lja.176.1701969581894; Thu, 07 Dec 2023 09:19:41 -0800 (PST) MIME-Version: 1.0 References: <20231201073240.T9bFNCkU@linutronix.de> <20231201080522.GA31309@didi-ThinkCentre-M930t-N000> <20231201161640.Z0cJLUi3@linutronix.de> <20231205153146.OSpCIs1G@linutronix.de> <20231207103536.30ae05aa@gandalf.local.home> In-Reply-To: <20231207103536.30ae05aa@gandalf.local.home> From: Yuanhan Zhang Date: Thu, 7 Dec 2023 12:19:28 -0500 Message-ID: Subject: Re: [PATCH v3] sched/cputime: let ktimers align with ksoftirqd in accounting CPUTIME_SOFTIRQ To: Steven Rostedt Cc: Sebastian Andrzej Siewior , zyhtheonly@yeah.net, tglx@linutronix.de, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:19:54 -0800 (PST) Hi, Steven Rostedt =E4=BA=8E2023=E5=B9=B412=E6=9C=887=E6= =97=A5=E5=91=A8=E5=9B=9B 10:35=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, 7 Dec 2023 18:43:47 +0800 > Yuanhan Zhang wrote: > > > It results in if we do not handle ksoftirqd like this, we will have a > > bigger SYSTEM and less SOFTIRQ. > > And honestly that's what we want. Interrupts and softirqs that execute in > interrupts and softirq context take away from the system. That is, if the= y > are not explicitly blocked (local_irq_disable/local_bh_disable) they > interrupt the current task and take up the time of the current task. We > need to differentiate this because this context has no "task" context to > measure. > > We do not want to add ksoftirqd or threaded interrupt handlers / softirqs > to this measurement. Sure, they are handling interrupt and softirq code, > but they have their own context that can be measured like any other task. > > If we blur this with real irqs and softirqs, then we will not know what > those real irqs and softirqs are measuring. Yes you say clearly enough and it makes some sense to me! So my understanding is that in PREEMPT_RT, it is better to put ksoftirqd's = time into SYSTEM since they are just in their "task" context. If my understanding is right, how about we just exclude ksoftirqd like what I do in the last email? (something like else if (in_serving_softirq() && (IS_ENABLED(CONFIG_PREEMPT_RT) || curr !=3D this_cpu_ksoftir= qd())) If this looks okay to you, I'm happy to send a new patch for this :) > > > So my point is if we do not align ktimers, ktimers would act like > > **observation on *not-excluded ksoftirq patched* kernel** part in the > > above example, > > and this might make SOFTIRQ less than expected, /proc/stat less accurat= e. > > No it does not. When a softirq kicks off it's work to a thread (ksoftirq, > threaded softirqd, or simply a workqueue), it's no longer running in > softirq context, and should not be measured as such. > > The measurement is not about how much work the softirq is doing (otherwis= e > we need to add workqueues started by softirqs too), it's about measuring > the actual irq and softirq context. In PREEMPT_RT, we try to eliminate th= at > context as much as possible. Thanks anyway, I think I begin to learn a bit more about PREEMPT_RT... > > So seeing less is a feature not a bug! > > -- Steve