Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5340617rwb; Tue, 1 Aug 2023 00:25:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHJruy66vdnESOoEQzXURXLNcGC1ge0E09ElclS+sqS+TfH47Wx3wDQOGZjzEveKsiz6EJg X-Received: by 2002:a17:907:78d0:b0:999:26d3:b815 with SMTP id kv16-20020a17090778d000b0099926d3b815mr1728008ejc.64.1690874708853; Tue, 01 Aug 2023 00:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690874708; cv=none; d=google.com; s=arc-20160816; b=DWLo0Vab/HxjFWpm8HAw6G+In6H0pvUPQTABhmdDtKw4s0YCsYhNvDlLUJJyYIh8+7 k7HnaWrL6BBValfU5IX51U0oVXfhLA1TaqXPYNvE/+wOuAK5N1rB9UKK7ScCxkWghJ+Z VWjz+wSJLskQ6/69g0/tYNAgb4xGt8cx7js/ZnfEkCmqgM0p4JoAnVI5Ly1f6g9HqZLp wrUcNLQpzFrJd4itDIdQHP6mif+U36bJz91EzuQNP4lR+1mmzLeMjrIVCkDysRRsU/KZ EOs9vDe6juZD4AWaiHEWiun7V7qefoLI4iMSZ2Aa3E9vS4j1b7+gl8Rd/arF5fCxy6ln EzvQ== 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=GjPiL+4LjXSLBCxGMeQtGBgOYicqjuvMF+wdwkDOlns=; fh=tYiG3tLjVNirZmCEAhO0ijnhlpkD5/sPPUKSOiTGBDQ=; b=MJV0BDz6B1++65HXTfCih65efyfglDzWcjv2wQSpjIZGWxbBbgOJ952VN/Ouk1om9G fTyoQ5GUCO9hlzuX+qkD1azEqdNb/+fnD+rlisLJ84oqgV65nZaDUvoeUqJzDZg6lFm3 Np+RJKtW4Jp5sGqQn1k6h673Oe8h0b9LDiwi9c2UNbMax87vGWXNMTaVOAnjkbLLQ3Rw d+YtcP+euYwTMOvihNDD3EiC8l3sa0ABxtXP83jsoQlsFOn5xEUDLYhHAnIW8is+5fDn sH+j7djZxyrlf6gycHTJvY6Uzn4Fj2hP0B9WVM0WfNwrx41+kHKh9hejHoAhX+bbH47n 2QIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=BVeQI85M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170906524d00b0099845f6579csi4301007ejm.631.2023.08.01.00.24.44; Tue, 01 Aug 2023 00:25:08 -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=@linux.dev header.s=key1 header.b=BVeQI85M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjHAG2D (ORCPT + 99 others); Tue, 1 Aug 2023 02:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231222AbjHAG1s (ORCPT ); Tue, 1 Aug 2023 02:27:48 -0400 Received: from out-95.mta0.migadu.com (out-95.mta0.migadu.com [IPv6:2001:41d0:1004:224b::5f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819231BEA for ; Mon, 31 Jul 2023 23:27:35 -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=1690871252; 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=GjPiL+4LjXSLBCxGMeQtGBgOYicqjuvMF+wdwkDOlns=; b=BVeQI85MV804PQr1qQe3DjMi+1F7rL86o2o0lwrOFiyWe49HUAwschBw2NvFJbIx0AO6LH IWMwlggQtKfBszl3tff+FfgvobC5ykPcyYp3Xet2RFFyDNBASoXJeYSsMBjOOwYvyNRKOp qIDZRM7vuYhslGuWAI6QMX3bz0VBZP0= 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: move back to RT_GROUP_SCHED and rename it child Date: Tue, 1 Aug 2023 14:27:14 +0800 Message-Id: <20230801062714.3424299-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 The member back in struct sched_rt_entity only related to RT_GROUP_SCHED, it should not place out of RT_GROUP_SCHED, move back to RT_GROUP_SCHED and rename it child. Init child in init_tg_rt_entry(). Also, remove the case parent is NULL because this case is the same as rt_se is NULL and already returned. Introduce for_each_sched_rt_entity_reverse() to iterate entries from top to down. Signed-off-by: Yajun Deng --- include/linux/sched.h | 2 +- kernel/sched/rt.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 177b3f3676ef..5635655d6c35 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -594,8 +594,8 @@ struct sched_rt_entity { unsigned short on_rq; unsigned short on_list; - struct sched_rt_entity *back; #ifdef CONFIG_RT_GROUP_SCHED + struct sched_rt_entity *child; 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 00e0e5074115..75efb1027b9f 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -228,13 +228,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, if (!rt_se) return; - if (!parent) - rt_se->rt_rq = &rq->rt; - else - rt_se->rt_rq = parent->my_q; - + rt_se->rt_rq = parent->my_q; rt_se->my_q = rt_rq; rt_se->parent = parent; + parent->child = rt_se; INIT_LIST_HEAD(&rt_se->run_list); } @@ -564,6 +561,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 = rt_se->parent) +#define for_each_sched_rt_entity_reverse(rt_se) \ + for (; rt_se; rt_se = rt_se->child) + static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se) { return rt_se->my_q; @@ -669,6 +669,9 @@ typedef struct rt_rq *rt_rq_iter_t; #define for_each_sched_rt_entity(rt_se) \ for (; rt_se; rt_se = NULL) +#define for_each_sched_rt_entity_reverse(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; @@ -1481,22 +1484,21 @@ static void __dequeue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flag */ static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int flags) { - struct sched_rt_entity *back = NULL; + struct sched_rt_entity *parent = NULL; unsigned int rt_nr_running; - for_each_sched_rt_entity(rt_se) { - rt_se->back = back; - back = rt_se; - } + for_each_sched_rt_entity(rt_se) + parent = rt_se; - rt_nr_running = rt_rq_of_se(back)->rt_nr_running; + rt_nr_running = rt_rq_of_se(parent)->rt_nr_running; - for (rt_se = back; rt_se; rt_se = rt_se->back) { + rt_se = parent; + for_each_sched_rt_entity_reverse(rt_se) { if (on_rt_rq(rt_se)) __dequeue_rt_entity(rt_se, flags); } - dequeue_top_rt_rq(rt_rq_of_se(back), rt_nr_running); + dequeue_top_rt_rq(rt_rq_of_se(parent), rt_nr_running); } static void enqueue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flags) -- 2.25.1