Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1044271rda; Sun, 22 Oct 2023 23:55:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQfF7THllbRW80jkCG+em2vopksikT/A0abykoKcg58/VnwXyQvGONHeayMzbDs0LXWK8J X-Received: by 2002:a05:6358:6f17:b0:166:94c8:9cdd with SMTP id r23-20020a0563586f1700b0016694c89cddmr9755260rwn.23.1698044107511; Sun, 22 Oct 2023 23:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698044107; cv=none; d=google.com; s=arc-20160816; b=PE1i2MrxfYmmAQ5w6USYAHMO+XqCcCYNCkieMVpLQV415GKwe0LADTJf/+B2u9LivA i74yAznPRRefb8TXY+NtX1FQcvOhuIiFXlFtOZjTdoTwvizqu4LlbxQfV1rx8Pq/NxDc UFbJHgi+yVn4U2uCfd7u1Mk67M7IRNOmgsqroSCPIXt7fp6glJ5bJ3axWYvfnPaYV8Fm Z+yqOBA+gXaPyJEW34Y62HyQ5U6OhFvE7nvG0ReNk2h0vW1W5jEIv1iX1D+CjdFandEH yqrr/ee6ahvPJud44a0axpv3rDekezpooAWLtjXc/QleeVmTkd9SGDRgw1iijiGWIodO zcaA== 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=nFX+PDMCoVA+7brqVMUuswHJ6EXf3IGJr/5xbPYkQXE=; fh=kY5sJNvn29qhEh2SatEVpXE2cTkcQ8AnU+xu9Bnn8Ic=; b=O7b2hyhuXR6aDJi58H22aPSuiUctNFlIio7I9ZY3MF2Ul3ow4TNlHWsWUPn7dcxeBH 5EU3Zd43unqUksC5QbzggtEXYL433cO56by7/Uc/yPzKcevm8EBIVwc4QW6LWLCvxeif wN1ajsUvwi8TYyiuuPQ7M5+6vEdSRx1KKmN7i4CVDeYH9bUoDJwK4qLNWE6dSoMENijn UDVG9UiGmClRK/DD9vzd+qNLdWZqlueul5TPzoHAiU8Gim4G3uxBKM/DS6LjsFPxoPuR y30J8ZfFyK60a1bkLfKeXZMJkV5dFAEpAnAUAZiMgBjeqZA1mDI47rr05NVBpyR+CH8z qypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NvOScbCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q37-20020a631f65000000b0056a1a149034si6157546pgm.650.2023.10.22.23.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 23:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NvOScbCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C307B808EEC2; Sun, 22 Oct 2023 23:55:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233321AbjJWGyn (ORCPT + 99 others); Mon, 23 Oct 2023 02:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjJWGym (ORCPT ); Mon, 23 Oct 2023 02:54:42 -0400 Received: from out-202.mta0.migadu.com (out-202.mta0.migadu.com [IPv6:2001:41d0:1004:224b::ca]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5693D5B for ; Sun, 22 Oct 2023 23:54:39 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698044077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=nFX+PDMCoVA+7brqVMUuswHJ6EXf3IGJr/5xbPYkQXE=; b=NvOScbCsuCMPOdF2nZnctqPLQf8SLUIEc6K+vnUBztpljKv4TiRB+EWxMOHzuVoVWjfAHV ErbSxYI1XOZtQr30HoWYVjsoDwPQAhak7dC+f5iGGbMtJNN0vKBv40QSaBIkEyu/+qpmy6 kl0s0OLkI1IRfOZQzKQ0C90/w4lmxBo= From: Yajun Deng To: 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 Cc: linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] sched/rt: Account execution time for cgroup and thread group if rt entity is task Date: Mon, 23 Oct 2023 14:54:18 +0800 Message-Id: <20231023065418.1548239-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Sun, 22 Oct 2023 23:55:05 -0700 (PDT) The rt entity can be a task group. Like the fair scheduler class, we don't need to account execution time for cgroup and thread group if the rt entity isn't a task. Check the scheduler class of the task and make sure that the rt entity is a task. Signed-off-by: Yajun Deng --- kernel/sched/rt.c | 4 ---- kernel/sched/sched.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 6aaf0a3d6081..ccded5670b61 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -165,8 +165,6 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b) hrtimer_cancel(&rt_b->rt_period_timer); } -#define rt_entity_is_task(rt_se) (!(rt_se)->my_q) - static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se) { #ifdef CONFIG_SCHED_DEBUG @@ -283,8 +281,6 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) #else /* CONFIG_RT_GROUP_SCHED */ -#define rt_entity_is_task(rt_se) (1) - static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se) { return container_of(rt_se, struct task_struct, rt); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 65cad0e5729e..c338c24e495d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -779,6 +779,11 @@ static inline long se_runnable(struct sched_entity *se) } #endif +#ifdef CONFIG_RT_GROUP_SCHED +#define rt_entity_is_task(rt_se) (!(rt_se)->my_q) +#else +#define rt_entity_is_task(rt_se) (1) + #ifdef CONFIG_SMP /* * XXX we want to get rid of these helpers and use the full load resolution. @@ -3266,9 +3271,12 @@ static inline void update_current_exec_runtime(struct task_struct *curr, u64 now, u64 delta_exec) { curr->se.sum_exec_runtime += delta_exec; - account_group_exec_runtime(curr, delta_exec); - curr->se.exec_start = now; + + if (curr->sched_class == &rt_sched_class && !rt_entity_is_task(&curr->rt)) + return; + + account_group_exec_runtime(curr, delta_exec); cgroup_account_cputime(curr, delta_exec); } -- 2.25.1