From nobody Sat Jan 3 02:07:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00BF8E92720 for ; Thu, 5 Oct 2023 16:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234387AbjJEQl2 (ORCPT ); Thu, 5 Oct 2023 12:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbjJEQjz (ORCPT ); Thu, 5 Oct 2023 12:39:55 -0400 Received: from out-199.mta1.migadu.com (out-199.mta1.migadu.com [IPv6:2001:41d0:203:375::c7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 795683C12 for ; Thu, 5 Oct 2023 09:23:48 -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=1696523026; 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: in-reply-to:in-reply-to:references:references; bh=VZoYSvv9GvN5UHY+p4M//aUHzUNjo8VNCPzwQbM0o+g=; b=df+BZIZp5gHbC2gFVu1urFRrQbixm+oQ8XGJpBLy22KE76hM96wBIBF65ACJdGioBWNUHH KJs0hEEvqnGkODXvq32oy4IFH+E1KU6Rx3MlmM/b7GyScsGRjbUqiK5vbvX//8l24v8E2e 8UTHaunkIzBGFncdDYoP7vyLkUJy0yU= 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 1/2] sched/rt: Introduce for_each_sched_rt_entity_back() & use it Date: Fri, 6 Oct 2023 00:23:16 +0800 Message-Id: <20231005162317.3343678-2-yajun.deng@linux.dev> In-Reply-To: <20231005162317.3343678-1-yajun.deng@linux.dev> References: <20231005162317.3343678-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The member back in struct sched_rt_entity only related to RT_GROUP_SCHED, it should not place out of RT_GROUP_SCHED. Introduce for_each_sched_rt_entity_back() & use it, it safe move back to under the CONFIG_RT_GROUP_SCHED in next patch. No functional changes. Signed-off-by: Yajun Deng --- kernel/sched/rt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 88fc98601413..642edbd24ffb 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -520,6 +520,9 @@ static inline struct task_group *next_task_group(struct= task_group *tg) #define for_each_sched_rt_entity(rt_se) \ for (; rt_se; rt_se =3D rt_se->parent) =20 +#define for_each_sched_rt_entity_back(rt_se) \ + for (; rt_se; rt_se =3D rt_se->back) + static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se) { return rt_se->my_q; @@ -625,6 +628,9 @@ typedef struct rt_rq *rt_rq_iter_t; #define for_each_sched_rt_entity(rt_se) \ for (; rt_se; rt_se =3D NULL) =20 +#define for_each_sched_rt_entity_back(rt_se) \ + for_each_sched_rt_entity(rt_se) + static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se) { return NULL; @@ -1445,7 +1451,8 @@ static void dequeue_rt_stack(struct sched_rt_entity *= rt_se, unsigned int flags) =20 rt_nr_running =3D rt_rq_of_se(back)->rt_nr_running; =20 - for (rt_se =3D back; rt_se; rt_se =3D rt_se->back) { + rt_se =3D back; + for_each_sched_rt_entity_back(rt_se) { if (on_rt_rq(rt_se)) __dequeue_rt_entity(rt_se, flags); } --=20 2.25.1 From nobody Sat Jan 3 02:07:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA63BE9271D for ; Thu, 5 Oct 2023 16:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234246AbjJEQlN (ORCPT ); Thu, 5 Oct 2023 12:41:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235333AbjJEQj2 (ORCPT ); Thu, 5 Oct 2023 12:39:28 -0400 Received: from out-200.mta1.migadu.com (out-200.mta1.migadu.com [95.215.58.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 102B5423E for ; Thu, 5 Oct 2023 09:23:56 -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=1696523034; 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: in-reply-to:in-reply-to:references:references; bh=zmy3zotbQnnCKFfAnZbO+ZCxlJAV6ZCKqlKvYGPQcy8=; b=uWRFSMTpGCh/IZ4iyBdzbqhocEbshB6NFx99HW+hW/gm+4qaBNsz0rz6z/VRftvSFDBJN4 GbADw37GROFpcUjH7WRyft3BbeYpDlxBNKllHNvbErj4W5XEh1QXiZ2TGj4eFy3cuz/vJ7 Ins8jYuTOTrhvR+yn1fQ09yCB2JDHMM= 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 2/2] sched/rt: Move sched_rt_entity::back to under the CONFIG_RT_GROUP_SCHED block Date: Fri, 6 Oct 2023 00:23:17 +0800 Message-Id: <20231005162317.3343678-3-yajun.deng@linux.dev> In-Reply-To: <20231005162317.3343678-1-yajun.deng@linux.dev> References: <20231005162317.3343678-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The member back in struct sched_rt_entity only related to RT_GROUP_SCHED, So move sched_rt_entity::back to under the CONFIG_RT_GROUP_SCHED block. It will save a few bytes. Also, init child when parent isn't NULL in init_tg_rt_entry(). Signed-off-by: Yajun Deng --- include/linux/sched.h | 2 +- kernel/sched/rt.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 292c31697248..d0fe56603e60 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -597,8 +597,8 @@ struct sched_rt_entity { unsigned short on_rq; unsigned short on_list; =20 - struct sched_rt_entity *back; #ifdef CONFIG_RT_GROUP_SCHED + struct sched_rt_entity *back; struct sched_rt_entity *parent; /* rq on which this entity is (to be) queued: */ struct rt_rq *rt_rq; diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 642edbd24ffb..7b3105b875f1 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -233,8 +233,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt= _rq *rt_rq, =20 if (!parent) rt_se->rt_rq =3D &rq->rt; - else + else { rt_se->rt_rq =3D parent->my_q; + parent->back =3D rt_se; + } =20 rt_se->my_q =3D rt_rq; rt_se->parent =3D parent; @@ -1441,23 +1443,21 @@ static void __dequeue_rt_entity(struct sched_rt_ent= ity *rt_se, unsigned int flag */ static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int f= lags) { - struct sched_rt_entity *back =3D NULL; + struct sched_rt_entity *root =3D NULL; unsigned int rt_nr_running; =20 - for_each_sched_rt_entity(rt_se) { - rt_se->back =3D back; - back =3D rt_se; - } + for_each_sched_rt_entity(rt_se) + root =3D rt_se; =20 - rt_nr_running =3D rt_rq_of_se(back)->rt_nr_running; + rt_nr_running =3D rt_rq_of_se(root)->rt_nr_running; =20 - rt_se =3D back; + rt_se =3D root; for_each_sched_rt_entity_back(rt_se) { if (on_rt_rq(rt_se)) __dequeue_rt_entity(rt_se, flags); } =20 - dequeue_top_rt_rq(rt_rq_of_se(back), rt_nr_running); + dequeue_top_rt_rq(rt_rq_of_se(root), rt_nr_running); } =20 static void enqueue_rt_entity(struct sched_rt_entity *rt_se, unsigned int = flags) --=20 2.25.1