From patchwork Mon Oct 9 12:22:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 150033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1828941vqo; Mon, 9 Oct 2023 05:23:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXwk53O+GTvfTfqaKrbipLJz7Odd2nXkTtUobOreLERLnN4Rl/Xi6/OiaDTZTAuxcezp9t X-Received: by 2002:a05:6a00:188a:b0:693:3d55:2bb3 with SMTP id x10-20020a056a00188a00b006933d552bb3mr14350095pfh.26.1696854222180; Mon, 09 Oct 2023 05:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854222; cv=none; d=google.com; s=arc-20160816; b=Q3p46Z6Wlmq78lWow+dz5+q7Hm4CXbyr1Kcwa+b4OUw1lVd8c7bBncAECchExq5LUw r2toWiHxEiQjrE6ZtIiVST89VtYirTZkBPdPMiQS2G674r2f3vy53D/GhGWI/DDFmFPC 3/gvZ3rFFkXRMAerbT6qdN0c0wk1upaY5kS9dZzgmGTls7wBEr6yX/4iT/5BQFuHoyDT F0+/OfxvyrVpr1SOW+iEoXxTfCvPcfeHZF67P/MRCuNSpW9SwxPAZgd1aU77dKjeTdvq YdCRWYdi9VUBIPlMTcvT5NHyQ2sLaiAKOdp88Hg9OsUaleTWWbT2aRl3Pl6Mwq1Ca6dK Rgsg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5KeMaN6CEe65Ia/B/zeGHWtr7cEhMkoaCHnrN7qH3bE=; fh=kY5sJNvn29qhEh2SatEVpXE2cTkcQ8AnU+xu9Bnn8Ic=; b=bFqHejBaJB+Lf0kq3D5p032tg3vHs02Q3tyQ1ozOQKCBX06Qp+Q16ASGkEU1SBVKbr Mm+w8YGlpkdDqT0RPNJgzmspP3SmrgKbCftYip32G2YyTQ0ZtrJKZ3KTHmUGKk0cz891 uaLNBQnBMy6TEWeHVBQ9tx/4mm+EUcsLuRDsqMYSgxO49i2goMQ72uxIrgtwPuknQ6qo g4OM8QDXc8M1Lcd0tXS4+YXebOyt/uRupr/EPMA1DC+cGNJv0VH2mbTo6x2eLhOpquUK CrlpmHXVBSB0qLq2TwQhjAT+hEbBV6vQzltpSLILYTz2RSmS1tH782J/ScfVL5sbtsMT cFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KyNPi4ZP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f11-20020a056a0022cb00b00690de92ffe3si7587225pfj.309.2023.10.09.05.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:23:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KyNPi4ZP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 805EC80BD3A5; Mon, 9 Oct 2023 05:23:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376350AbjJIMXP (ORCPT + 18 others); Mon, 9 Oct 2023 08:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376343AbjJIMXO (ORCPT ); Mon, 9 Oct 2023 08:23:14 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [91.218.175.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB83EDF for ; Mon, 9 Oct 2023 05:23:12 -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=1696854190; 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=5KeMaN6CEe65Ia/B/zeGHWtr7cEhMkoaCHnrN7qH3bE=; b=KyNPi4ZPdRkBQpIl20IRIwS+EB8A7MQgNse6+LNWkkktoKu4w46pHWKcQ5ksWzBkcfWRGN Mc6feowEsmRGQNnq4HKLyttGGKy6umm6s0y55370vDHFSdeyswl30IM76j6vxKY0gA42ih Y7oXmTMWQpQLh4MdUJhf7i/cX0KGu0I= 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 v7 1/3] sched/rt: Introduce for_each_sched_rt_entity_back() & use it Date: Mon, 9 Oct 2023 20:22:42 +0800 Message-Id: <20231009122244.2394336-2-yajun.deng@linux.dev> In-Reply-To: <20231009122244.2394336-1-yajun.deng@linux.dev> References: <20231009122244.2394336-1-yajun.deng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 05:23:39 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779280612984829874 X-GMAIL-MSGID: 1779280612984829874 Introduce for_each_sched_rt_entity_back() & use it, because it's safe to call it whether CONFIG_RT_GROUP_SCHED is enabled or disabled. No functional changes. Signed-off-by: Yajun Deng --- v7: Same with v6. v6: Independent patch. v5: Resend it. v4: Missed rt_se = root in dequeue_rt_stack(). v3: Keep parent is NULL in init_tg_rt_entry(). v2: Add WARN_ON_ONCE in init_tg_rt_entry(). v1: https://lore.kernel.org/all/20230801062714.3424299-1-yajun.deng@linux.dev/ --- 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 = rt_se->parent) +#define for_each_sched_rt_entity_back(rt_se) \ + for (; rt_se; rt_se = 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 = NULL) +#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) rt_nr_running = rt_rq_of_se(back)->rt_nr_running; - for (rt_se = back; rt_se; rt_se = rt_se->back) { + rt_se = back; + for_each_sched_rt_entity_back(rt_se) { if (on_rt_rq(rt_se)) __dequeue_rt_entity(rt_se, flags); }