Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp611067rwd; Tue, 16 May 2023 05:46:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rBxRKIVDKVJbg4SaJrGOWMsuQX0+GKn25QMgpuu+S68Msh2YoZY7iLQAJURcbpPBOWfpT X-Received: by 2002:a17:902:bb8a:b0:1ad:e19f:bb66 with SMTP id m10-20020a170902bb8a00b001ade19fbb66mr12597762pls.12.1684241217196; Tue, 16 May 2023 05:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684241217; cv=none; d=google.com; s=arc-20160816; b=rUQTmwDr6qrL/Mui7cynjCJK9rpPyQbsvYvu6R7rMG+hNZX3Uk2WmQUbBE/k7BP9rX UpHZjRoUi7XJstLaGyG8EBJBP9dUXwF75G83c55e7S+40aESYWUa6AUj0cUeL8j5gGkA yyjf6/lZZ7QjSLKho19R5PJCCyQmuIX40vTR5Ao4OPMP5YtbkrvSfexA+KQ0mdUd6tGw vSYPm958YNC/ISXoMVMTi12FTBW/r3LI0pbEfBRxbmWpgu/gXegVxvGNeHBAMWtBF3q7 MBiQB6Vm7vILfJu5kN0mmuxDXUpd5XTswMZSAAjAFWapGnGHu/v9IcmeoxYQNv6Q58iB EO1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZDvSzF7eFHvldf+F8B0EAJefAcI+szYaDeqPAOVVxnA=; b=VqM2uUcAJhTgsBULA3d5Xc9xKz/7vjbuqXIYEmMULZz+N3dsWY3fBwJBBIhT8Gle4V iqMXWmQUODy7Mr5Xa2gfV8LhqczL/YymC9pP0y30efB/2vUw6abRM47FJZ9i3epYd1ot JP8GmHpykZoEL20rOf0tPltAO5UfIH99RzMXnceBF2YSUeBir2TpLn6qNmbWECvMj29b W2la0IGdXt+F4i1nZA0ofGob5to28lVJamdtqfaBHh2dcIJ8luBGM24GEG1DUeYoNtpT VnUeUgvz8e4ju1zK/hLQwJatEDN4HGFgS3dqOZsAkFZXBB1GK4sHvzXkE/DZEydCG4i9 QWFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shruggie-ro.20221208.gappssmtp.com header.s=20221208 header.b=Me5vW3mG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i18-20020a17090332d200b001a4ee96c00bsi20083233plr.357.2023.05.16.05.46.42; Tue, 16 May 2023 05:46:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shruggie-ro.20221208.gappssmtp.com header.s=20221208 header.b=Me5vW3mG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232441AbjEPMWK (ORCPT + 99 others); Tue, 16 May 2023 08:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232597AbjEPMWJ (ORCPT ); Tue, 16 May 2023 08:22:09 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B02530F1 for ; Tue, 16 May 2023 05:22:07 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-50db7ec8188so13437246a12.2 for ; Tue, 16 May 2023 05:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shruggie-ro.20221208.gappssmtp.com; s=20221208; t=1684239725; x=1686831725; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZDvSzF7eFHvldf+F8B0EAJefAcI+szYaDeqPAOVVxnA=; b=Me5vW3mGX149xX/rbimM22Ywtfg6BI7CDY4N+UNdAN/qi3aTJZZQ4TgkpFibpDSO9+ S0QWc9KSQvb/94s4HG5cAbn27P6Ttb6l/hMvmiCxznwdMtffxTv0DirXukAvH+BBzDCB KyoOuxDMGFve+fgzbXzUYzl6nqw9KZMauKqX7sGdWtzgNn5mQVCOa4M/jH1dAWRfSXnl UIbK3EhyVVEplIV1LRTGteDRQt6MGxui7nqQRjtGMDKvJt6tcQl7282xUjszByF9DJkR u/yNB5YKij23ZYGW5DtpPj5caGQQd/V6HiWRPoTehcJGwgQSfLrp6BNPlVpIZdDzGaIw UOUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684239725; x=1686831725; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZDvSzF7eFHvldf+F8B0EAJefAcI+szYaDeqPAOVVxnA=; b=FdgvS1KXgfySAo2++aLc77+aVtWAolPf7ezGQFjoOoRbSvIAgY2r32L7QSa2bgceAS NZLTooD2QcJEyCRqfCwZnhT95yQyd0F7I4/VtVkmnmNiS/VIxM0P0K+WM/ld3Zgz87Ls Ogv2dUFo6SmIZss5OVcnF0IFacJIwPvwzF2jVa/uqbnz9KevF/Z0QCFMMAXHu2avg1m5 KF20+yYRP+cAlWYh2n5Mqh1wAnIUaskezQk5VM9d2YyI5bH7em0a05wh30g32XjxkhdG aQWeGuYLA+x6DXSgPdpjWvSP0bFCekSP8Q5bKpVoSBZ99HmyFJYGdihImFIfuXM6jvBX I1kg== X-Gm-Message-State: AC+VfDy7Kvo8DUMTSd7qAOauKxWNHy64WfaepMccr+Jtn+rAW37i806f 8B5MBYZufeBEjkhW92QLjG3i44Q0k6rsnt393wM= X-Received: by 2002:a05:6402:414:b0:50b:c0ce:d55 with SMTP id q20-20020a056402041400b0050bc0ce0d55mr25801498edv.3.1684239725269; Tue, 16 May 2023 05:22:05 -0700 (PDT) Received: from neptune.lan ([188.27.128.119]) by smtp.gmail.com with ESMTPSA id d11-20020a05640208cb00b0050bd4b8ca8fsm8063115edz.14.2023.05.16.05.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:22:04 -0700 (PDT) From: Alexandru Ardelean To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, tian.xianting@h3c.com, steffen.aschbacher@stihl.de, Alexandru Ardelean Subject: [PATCH][V2] sched/rt: Print curr when RT throttling activated Date: Tue, 16 May 2023 15:22:02 +0300 Message-Id: <20230516122202.954313-1-alex@shruggie.ro> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xianting Tian We may meet the issue, that one RT thread occupied the cpu by 950ms/1s, The RT thread maybe is a business thread or other unknown thread. Currently, it only outputs the print "sched: RT throttling activated" when RT throttling happen. It is hard to know what is the RT thread, For further analysis, we need add more prints. This patch is to print current RT task when RT throttling activated, It help us to know what is the RT thread in the first time. Tested-by: Alexandru Ardelean Signed-off-by: Xianting Tian --- Initial patch submission: https://lore.kernel.org/all/f3265adc26d4416dacf157f61fa60ad6@h3c.com/T/ We've been having some issues of our own with some applications + some RT configuration == some threads endded up taking too much CPU time. This patch came in quite in handy to see in logs which thread is more problematic. We've applied this patch onto a 5.10.116 tree. It did need a bit of re-applying since some context has changed since the initial version (hence the V2 tag). Since 5.10.116 (where we used it), it applied nicely to the latest/current linux-next tree (hence the Tested-by tag). It would be nice to apply this to the mainline kernel and have this handy. kernel/sched/rt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 00e0e5074115..44b161e42733 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -995,7 +995,7 @@ static inline int rt_se_prio(struct sched_rt_entity *rt_se) return rt_task_of(rt_se)->prio; } -static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq) +static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq, struct task_struct *curr) { u64 runtime = sched_rt_runtime(rt_rq); @@ -1019,7 +1019,8 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq) */ if (likely(rt_b->rt_runtime)) { rt_rq->rt_throttled = 1; - printk_deferred_once("sched: RT throttling activated\n"); + printk_deferred_once("sched: RT throttling activated (curr: pid %d, comm %s)\n", + curr->pid, curr->comm); } else { /* * In case we did anyway, make it go away, @@ -1074,7 +1075,7 @@ static void update_curr_rt(struct rq *rq) if (sched_rt_runtime(rt_rq) != RUNTIME_INF) { raw_spin_lock(&rt_rq->rt_runtime_lock); rt_rq->rt_time += delta_exec; - exceeded = sched_rt_runtime_exceeded(rt_rq); + exceeded = sched_rt_runtime_exceeded(rt_rq, curr); if (exceeded) resched_curr(rq); raw_spin_unlock(&rt_rq->rt_runtime_lock); -- 2.40.1