Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp100211lqb; Tue, 4 Jun 2024 06:22:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUren8Ltg+R4AsznoupKkrsvrg0rLwEbpOk188Jhb4Gz9rdG2pplEpew4mb709/hDMtP55QxOVPBFxt/qJqphGtg3sFEPhIvcPj+h0hfg== X-Google-Smtp-Source: AGHT+IFuSlxDOWV0RzMKo6+HkSAXGPrE9JbnmImgbs2uBkFwzwO2AM6C2OSmc2s5xfKZr4gnkhth X-Received: by 2002:a05:6214:5d11:b0:6ae:33e3:e166 with SMTP id 6a1803df08f44-6aff72773f0mr37615036d6.13.1717507336261; Tue, 04 Jun 2024 06:22:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717507336; cv=pass; d=google.com; s=arc-20160816; b=oPkvGPiOtxJH0+CCqwXTvqYk20QuTW2f81pYAQeC9jg2PY0gS0TJGwhLyEiCti5qTC LmCfdcDbzyIqQScSr6QfJpzLPuo+/eqs9l4C80hbYZGRK3kgVTwCl2f3rp2zkswoS9TE xTOvaWEdwnwCKl+fix/fv2j3Q8W/um0bwGgbNI5w7B13pUZIknzpoQw7BX6dRJEdbQHH LYkQubuJijkDbLnub+0b/u+/Njamz8N6Vh/P5N1htSzXbdkSAml9FWMXxZviz5CNHogI SgaOJ6m1EZIvgPsrKeAIL5DPCTiiTuSyXCGGvovG3f8R53sOjty2h7i/7pJ+zPskI29y 1gJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=g9aBwkoXTCwk3LlJU7bkkuyIBuFqTYyNOCpzaVnnTT4=; fh=duoQCvjKx31JXbYGFTVYkA1tG2f7qT6P4Uewznqug2w=; b=Pb+5UTdig6eSS8NYL4FfLVhXdE/dx8/QI0FpvKnxe6OfVZJouWEvrKAUzhK8UONmNe 8jaaH6rdu//0LeQSKyBsiA4kHvMNJO8Ak8iXFcMm4Bztd6sv/L2ZOMMOcQj4ZEWVqMQA MCwzSS81RArlwABanp64r8H33qgn9YhtCeqGlyWf4DFGfwPA7zNjhCFoqz5Tlh1HUxmd EmmXfLSmlhn4L/Lw+Irt16/gkSnhn8myy6Ht1k9BU9nFYgv12R+nUxC2HvGgPaskW329 TDYn6aluPiPZKgqUc2stz14WX73vPg/CYCucTm9wo9JCH7Tpo+s3xwJIhNkCFK+DG00e 2ipw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200697-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a733c00si109207306d6.41.2024.06.04.06.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 06:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200697-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 027A51C20AED for ; Tue, 4 Jun 2024 13:22:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7B251465A8; Tue, 4 Jun 2024 13:22:10 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32F5714658A for ; Tue, 4 Jun 2024 13:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717507330; cv=none; b=KKUmBe/SJuAoi1B9mjTq05ItjF+t2NbUTCRfiolD6Dcs+nejA/1hqEZDTsQkySdG+LIOcCgkFHg2hNgPfOwtFnpFWOFYtJixIVg6DrCHERtXmdSjsRBzlQOblm+wz/RFH84F/f5I36iTi0Rh06chKPW33V56Ahag+RwbW0vYp/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717507330; c=relaxed/simple; bh=8F/EhiLs2so7RVQUHfEcWAz1308jhOqznNqQJ8dKJgw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ir0yYTQoW7Zupsbp/CYbP119h/8HiPdRdzDxC6sYlVpPdJMklgzZV1N3uFW+w8iWw1iaoHkGw2tw1QdjfnZWijEaf5EvY5DHzxP74sXtM9PtPcPnMR+QWKbsWwn5KE47G06UhHu2GuJYsRayA8KnheMIgZYgHuSZjI0M0s8L44M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F8D1C2BBFC; Tue, 4 Jun 2024 13:22:06 +0000 (UTC) Date: Tue, 4 Jun 2024 09:22:03 -0400 From: Steven Rostedt To: Yajun Deng Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] sched/rt: Use 'back' only if CONFIG_RT_GROUP_SCHED is enabled Message-ID: <20240604092203.7c31b7b5@gandalf.local.home> In-Reply-To: <20240603125002.3086-2-yajun.deng@linux.dev> References: <20240603125002.3086-1-yajun.deng@linux.dev> <20240603125002.3086-2-yajun.deng@linux.dev> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Jun 2024 20:50:01 +0800 Yajun Deng wrote: > The 'back' member in struct sched_rt_entity only related to > CONFIG_RT_GROUP_SCHED, so there is no need to init it in dequeue_rt_stack. > > Init the 'back' member in init_tg_rt_entry and use it only if > CONFIG_RT_GROUP_SCHED is enabled. > > Signed-off-by: Yajun Deng > --- > kernel/sched/rt.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index 63e49c8ffc4d..44bb9087cfe5 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -232,8 +232,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->back = rt_se; > + } If one block of an if/else requires brackets, then both do. > > rt_se->my_q = rt_rq; > rt_se->parent = parent; > @@ -1428,16 +1430,19 @@ static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int flags) > struct sched_rt_entity *back = NULL; > unsigned int rt_nr_running; > > - for_each_sched_rt_entity(rt_se) { > - rt_se->back = back; > + for_each_sched_rt_entity(rt_se) > back = rt_se; > - } > > rt_nr_running = rt_rq_of_se(back)->rt_nr_running; > > - for (rt_se = back; rt_se; rt_se = rt_se->back) { > + for (rt_se = back; rt_se; ) { > if (on_rt_rq(rt_se)) > __dequeue_rt_entity(rt_se, flags); > +#ifdef CONFIG_RT_GROUP_SCHED > + rt_se = rt_se->back; > +#else > + rt_se = NULL; > +#endif Perhaps make a helper function to get rid of the #ifdef in the code here. for (rt_se = back, rt_se; rt_se = rt_se_back(rt_se)) { Where rt_se_back() above can be defined in the #ifdef blocks for CONFIG_RT_GROUP_SCHED as either: static struct sched_rt_entity *rt_se_back(struct sched_rt_entity *se) { return se->back; } Or static inline struct sched_rt_entity *rt_se_back(struct sched_rt_entity *se) { return NULL; } -- Steve > } > > dequeue_top_rt_rq(rt_rq_of_se(back), rt_nr_running);