Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp897817rwd; Thu, 8 Jun 2023 09:09:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZTCX4n7IAX6jrRPNmMq5+YLFN4vRcn4EggGnnJBiFxIOsxbJMciHWwEjaX8SwPDQfLcJ0 X-Received: by 2002:a05:6a20:94cc:b0:110:f65a:13db with SMTP id ht12-20020a056a2094cc00b00110f65a13dbmr4496601pzb.15.1686240546293; Thu, 08 Jun 2023 09:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686240546; cv=none; d=google.com; s=arc-20160816; b=Ov0iweDwYyvXFZgD2imMkqCR/57wfuywWgCvDWzlY2rWfS91FlhDHmQvy0MUXLmLS3 qupW2WRYaC4C0dLHMV+BKe91Pu04pB2MwmaerO/EnQ5anHWn4jDIYbjdU78kdJ4O6o7K Kpxz0r7wt0/pKHZzvnBr9FfpoCD5OFn7fQJjnTY7OUOJxfJkj0UkhgyZRUUfPaXT+Ex5 haXuLOAp5U1cZZ1W5a7wF6N5/PauA6xEEv/NSytLPz65tCm3WnY5izrQlk2fH3jVNvRx aPOLkKSjhwlw4z2DxhH9FdcssurkVOpE6H/dPG+1SHDAaGzu0MnTqExND9vma045eYVw sMdw== 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=f8NmgcbNjqc7YAnFv/+Mw9KMVErxZATqU6JmF3OLPws=; b=KTpGzq5Q64si4xSG3Ag0J8NuuoszJZ1xG8ZI8G69j+NYSfL9/iNW6pVG2E4otkwKNx wsdCg/Z3XMkuIzrU1CGuxm1QSt13UGpFsF1RvPKqYXOVokbtmYtOJIdWgXaJu6pGBm2H T/uGZuk4eBceXOIe0oQw4rj8ggPwfv+ucOTN1hlzPIYKwN7yj2/kbXIjq1BNDCPxKN52 4s6dlMpeL4SCoADuQXOOsMahi15WP2r5YbVZJHtTy4wRxlEeJRIfH/6ZbYv4yxyHKUBc STAh5R+xFhJWzZ2S31Chb9nkhsVVIXG/5w2Xzw8lKM4PpuKzDB3ebOoHM18Y2OFKuYmR v/dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BhiX8l8x; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x27-20020aa79a5b000000b0064553929dbdsi948812pfj.394.2023.06.08.09.08.51; Thu, 08 Jun 2023 09:09:06 -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=@kernel.org header.s=k20201202 header.b=BhiX8l8x; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237512AbjFHP7K (ORCPT + 99 others); Thu, 8 Jun 2023 11:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237141AbjFHP6l (ORCPT ); Thu, 8 Jun 2023 11:58:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 247D2E57 for ; Thu, 8 Jun 2023 08:58:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ABC4E64EC5 for ; Thu, 8 Jun 2023 15:58:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F821C4339B; Thu, 8 Jun 2023 15:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686239919; bh=hZr0IFnTxWMviMRdkn01XGuFZNJYi9czfgwV8AAhCIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhiX8l8xRhpmhLR1xlVVX6jYb98Vl/3OF39Laq3v/ZvN+0bhYmuPZqXbUkHvoSGuX Zsh6dttXsdWQ23uITRcwXoC3Uw1eeU2NpS/qoYRNCyUQJjUkkP6xPmgbIA01yeoS+b BQ6Up46wBqs2r+dFfPYYAnxzXf04d+yvaI29ZZ2VZBvwdQtKJgxHcGFOM9qVBtVH1x b6NIdce73xXchVxz81yoyYPGAJK13FZ89TS0FdaK+wuESDf8F7kKYlXHwvidIiUipK tFH0YgjMWgCh4qDFDcRaQGbt5JyPYhJveO+ZNHrkyDk9ya4e4+GJOtl3/C1Lm4ro0+ 4mT/b9hDoUqIg== From: Daniel Bristot de Oliveira To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, Luca Abeni , Tommaso Cucinotta , Thomas Gleixner , Joel Fernandes , Vineeth Pillai , Shuah Khan , Daniel Bristot de Oliveira Subject: [RFC PATCH V3 2/6] sched/deadline: Collect sched_dl_entity initialization Date: Thu, 8 Jun 2023 17:58:14 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 From: Peter Zijlstra Create a single function that initializes a sched_dl_entity. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Daniel Bristot de Oliveira --- kernel/sched/core.c | 5 +---- kernel/sched/deadline.c | 22 +++++++++++++++------- kernel/sched/sched.h | 5 +---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ac38225e6d09..e34b02cbe41f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4511,10 +4511,7 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p) memset(&p->stats, 0, sizeof(p->stats)); #endif - RB_CLEAR_NODE(&p->dl.rb_node); - init_dl_task_timer(&p->dl); - init_dl_inactive_task_timer(&p->dl); - __dl_clear_params(p); + init_dl_entity(&p->dl); INIT_LIST_HEAD(&p->rt.run_list); p->rt.timeout = 0; diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 030e7c11607f..22e5e64812c9 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -333,6 +333,8 @@ static void dl_change_utilization(struct task_struct *p, u64 new_bw) __add_rq_bw(new_bw, &rq->dl); } +static void __dl_clear_params(struct sched_dl_entity *dl_se); + /* * The utilization of a task cannot be immediately removed from * the rq active utilization (running_bw) when the task blocks. @@ -432,7 +434,7 @@ static void task_non_contending(struct task_struct *p) raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); raw_spin_unlock(&dl_b->lock); - __dl_clear_params(p); + __dl_clear_params(dl_se); } return; @@ -1205,7 +1207,7 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer) return HRTIMER_NORESTART; } -void init_dl_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer = &dl_se->dl_timer; @@ -1415,7 +1417,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer) raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); raw_spin_unlock(&dl_b->lock); - __dl_clear_params(p); + __dl_clear_params(dl_se); goto unlock; } @@ -1431,7 +1433,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer) return HRTIMER_NORESTART; } -void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer = &dl_se->inactive_timer; @@ -2974,10 +2976,8 @@ bool __checkparam_dl(const struct sched_attr *attr) /* * This function clears the sched_dl_entity static params. */ -void __dl_clear_params(struct task_struct *p) +static void __dl_clear_params(struct sched_dl_entity *dl_se) { - struct sched_dl_entity *dl_se = &p->dl; - dl_se->dl_runtime = 0; dl_se->dl_deadline = 0; dl_se->dl_period = 0; @@ -2995,6 +2995,14 @@ void __dl_clear_params(struct task_struct *p) #endif } +void init_dl_entity(struct sched_dl_entity *dl_se) +{ + RB_CLEAR_NODE(&dl_se->rb_node); + init_dl_task_timer(dl_se); + init_dl_inactive_task_timer(dl_se); + __dl_clear_params(dl_se); +} + bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr) { struct sched_dl_entity *dl_se = &p->dl; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index da0cec2fc63a..fa6512070fa7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -284,8 +284,6 @@ struct rt_bandwidth { unsigned int rt_period_active; }; -void __dl_clear_params(struct task_struct *p); - static inline int dl_bandwidth_enabled(void) { return sysctl_sched_rt_runtime >= 0; @@ -2390,8 +2388,7 @@ extern struct rt_bandwidth def_rt_bandwidth; extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime); extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq); -extern void init_dl_task_timer(struct sched_dl_entity *dl_se); -extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se); +extern void init_dl_entity(struct sched_dl_entity *dl_se); #define BW_SHIFT 20 #define BW_UNIT (1 << BW_SHIFT) -- 2.40.1