From patchwork Thu Aug 3 05:03:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 130328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp956327vqx; Wed, 2 Aug 2023 23:56:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlEenlzGgPCjeg4+HzPAdhqYUx+17jOqPO9XWlCBae5rHh/AAxsUfkT2TQV06Qo9BAfU8XdA X-Received: by 2002:a17:906:73dd:b0:993:d90e:3101 with SMTP id n29-20020a17090673dd00b00993d90e3101mr12406389ejl.1.1691045819537; Wed, 02 Aug 2023 23:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691045819; cv=none; d=google.com; s=arc-20160816; b=evIJQroQeJDm2uiwQvB7xlC1CzZXRC8SGtSpy6gSu/LPa2USCkzwngYBBxYF7U1EXX pDCLAZNLmFwClIgOgehlo9GKrtKtzM6uNzs2C9Ltdd0KNSJAL7ibptwaGPsqBOu5+elR RtaBLVReshb2sIvtjAFVg7nnu1MkDJFs9B1fjJ92QKhxR5W46LSphjczmpaBN9tWF+wZ 3Ciy4Wr4xaTHtJIl5J543TO9vcUB+UROHu2cJDC2XJD6weQ+ETz3aDr9sbjnNqYoVyy0 EykaYTQzfYuzSqBhXX6YTTVsFDMusAxsIVBkayu8PprFG7HMsMrMqwDKdFLxLjSf8S80 99+Q== 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=vnwuMnQktIn7+Xvq8T1vzTAeqXaEEef/2+c0OLwPoHc=; fh=/cPvN5jgrEoD9xn58vc5wPbK9UdLUW8uvZPelW/tWQE=; b=Iu5fTkoeZ3qAccX2yrji+KgN3yYhaCuj2uOLcY4ncvnvlPPsU6Hz3ve1A/BGRShkBy nDUCF/vmnBy2ve8z5D1fWEZkofx6bnynhvjwJ144vCW9i3mB0W63S5kBbA2/kusIdCzM cKRnO3giMFR3FaEQnvrzymWOFhK2QNJJ3QKfkD8WrFT6DdG34X9CNlgkw1iqapECxvtS IaOV0iKlCEWNqh8OG+iaYhq/NmKt/DyqxHPw/oLlPiWOCpBqV85dQ43iHIZ3ynfImFfL 3LlaEnSDqmAsl0neqOExe+jnKA3HQzztPhmW11LObDOuBFkWGm6a3aFVuIANsMxxq1t+ M23g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=d3GcjSMR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a170906488800b0098e16f844f5si12119837ejq.715.2023.08.02.23.56.36; Wed, 02 Aug 2023 23:56:59 -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=d3GcjSMR; 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 S231903AbjHCFDx (ORCPT + 99 others); Thu, 3 Aug 2023 01:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjHCFDv (ORCPT ); Thu, 3 Aug 2023 01:03:51 -0400 Received: from out-106.mta0.migadu.com (out-106.mta0.migadu.com [91.218.175.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A001702 for ; Wed, 2 Aug 2023 22:03:49 -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=1691039026; 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=vnwuMnQktIn7+Xvq8T1vzTAeqXaEEef/2+c0OLwPoHc=; b=d3GcjSMR190Ifk+6CEt3j9TsJMNRgJjwx2bVA9LE9Atj0zmJ8U3vOf3rBU83TfNB3EaODK zlS5V9jMcGT3PNRsqGwmRa8SlqKVksZYwl53fCVU7JTVgJZhCrlogurgeCS7XhBmiGn2d7 yehlNWwCbzzMSpQISq0f/q2b5D4n9eE= 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 , kernel test robot Subject: [PATCH v4] sched/rt: move back to RT_GROUP_SCHED and rename it child Date: Thu, 3 Aug 2023 13:03:17 +0800 Message-Id: <20230803050317.2240948-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,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773179921377194172 X-GMAIL-MSGID: 1773190061627273592 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 when parent isn't NULL in init_tg_rt_entry(). Introduce for_each_sched_rt_entity_reverse() to iterate rt_se from top to down. Signed-off-by: Yajun Deng Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202308031034.4369b15b-oliver.sang@intel.com --- V3 -> V4: Missed rt_se = root in dequeue_rt_stack(). V2 -> V3: Keep parent is NULL in init_tg_rt_entry(). V1 -> V2: Add WARN_ON_ONCE in init_tg_rt_entry(). --- 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 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..5e3edd7b8be4 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)