From patchwork Tue Sep 19 03:51:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 141683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3117267vqi; Mon, 18 Sep 2023 21:04:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlO+exXwZhmei/cWK7NedeTVdcgs8rYb57DphcX+O0JycTPAeVjBFSPnwMoU30ACT+c8Xu X-Received: by 2002:a54:4512:0:b0:3a7:1b28:4bc9 with SMTP id l18-20020a544512000000b003a71b284bc9mr9878141oil.54.1695096257506; Mon, 18 Sep 2023 21:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695096257; cv=none; d=google.com; s=arc-20160816; b=Gagfs7vFyI6ovPVwDAZVWnsYDF1mbZZB/JN05dT7oG2uj/1fO7PVWYoi1y+qVDH0Oc +JcYR7QN0fEN7U91p10UjFjLW4GQekD/fPUo767ZQta9Hp2Z/YPiZU175X/GszUglZaP wNlaeaKy7gO+LQwPWs3RSIsopTsBZJN4/jmcL0CfiSq/6h0HQ/vIoZLSAD/XYU5bCy6V CnLRaC5LuwzVW2A/TNh+hVm9IZrGeMXSQKkzfw//+qHv6G6uFt9qjrKa7m8n4isYj66r BJjYWUqUiX5JPTNPB18zlNLYDTwiTBAy3ZQYi2m+QD5aBfYO+xRR3B72gwG9FIZuoyXw Fq8w== 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=6bW9a+ibr9y5+Y2QH122l9/44BhHg+scHniSmiGkoo8=; fh=kY5sJNvn29qhEh2SatEVpXE2cTkcQ8AnU+xu9Bnn8Ic=; b=tK4x1TO3qwQ/iQNphJ4VIF6mEHzsnkOVUMqgmy0mXKHsrxyNdBHg69JUqUSB9+Z8zC Sk9uVTLmb3+NX2l3p2IPC1B133ccD8ozM2maZHj5oNQWUOt01xSN3PY4IEcxv2LyRyY8 Gw/Y/BYzwDLGW5LsOG3vwJwuh+sEw7RZHtauGnyuxAwerBvkQ7nQqux1bl+f8sS5M+W/ dEA2DloqabTu213AvHas7eW1ssihJHtAHitfMc2T0UFopLVDkgWwwiGFsk6XabUJ1UFb sOz0zQaFQP2wRJMwZJq0Li3XNCwlpqvs4dvIftQf7UrzfzCM08Iuw+kgvI18z+Uhm+0H ykOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pEglLYJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k62-20020a636f41000000b005653283b8a4si8816658pgc.785.2023.09.18.21.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 21:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pEglLYJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E2D97819A682; Mon, 18 Sep 2023 20:52:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbjISDvw (ORCPT + 26 others); Mon, 18 Sep 2023 23:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbjISDvu (ORCPT ); Mon, 18 Sep 2023 23:51:50 -0400 Received: from out-218.mta1.migadu.com (out-218.mta1.migadu.com [95.215.58.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840778F for ; Mon, 18 Sep 2023 20:51:44 -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=1695095502; 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=6bW9a+ibr9y5+Y2QH122l9/44BhHg+scHniSmiGkoo8=; b=pEglLYJ0IQpi3OO+QXLQtN5sjzb17xSVub0zxCKSqu9B/OiL+ZbRJ+PfLa//pAXdR41fz8 ltO9k+EHMA/Ap6Spid32SaxF3JE6l4UrueD6WRupWa0vc8ZYfRSnsYDm9q/L6G2NNZmdD0 yZCxc/bVUyW3cMo35cUvF29W+rVtPfk= 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, 19 Sep 2023 11:51:14 +0800 Message-Id: <20230919035114.2364567-1-yajun.deng@linux.dev> MIME-Version: 1.0 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 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 20:52:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777437252807147443 X-GMAIL-MSGID: 1777437252807147443 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. This would save a few bytes. Init child when parent isn't NULL in init_tg_rt_entry() and introduce for_each_sched_rt_entity_reverse() to iterate rt_se from top to down. Signed-off-by: Yajun Deng --- include/linux/sched.h | 2 +- kernel/sched/rt.c | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 7fcf1b82cfa6..cd05f4bb6a26 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 0597ba0f85ff..841f470026bb 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -230,8 +230,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, if (!parent) rt_se->rt_rq = &rq->rt; - else + else { rt_se->rt_rq = parent->my_q; + parent->child = rt_se; + } rt_se->my_q = rt_rq; rt_se->parent = parent; @@ -564,6 +566,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 +674,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 +1489,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 *root; 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) + root = rt_se; - rt_nr_running = rt_rq_of_se(back)->rt_nr_running; + rt_nr_running = rt_rq_of_se(root)->rt_nr_running; - for (rt_se = back; rt_se; rt_se = rt_se->back) { + rt_se = root; + 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(root), rt_nr_running); } static void enqueue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flags)