From patchwork Sat Nov 4 10:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bristot de Oliveira X-Patchwork-Id: 161568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1580869vqu; Sat, 4 Nov 2023 04:01:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3clyi8nFfjNhCgkD52RdVF6b+B53pa3sevYsvKXi9E9obooHMe8ZpUEbjHNZISIgIIR4n X-Received: by 2002:a05:6602:340e:b0:7a9:4a6e:66a2 with SMTP id n14-20020a056602340e00b007a94a6e66a2mr31612501ioz.16.1699095677991; Sat, 04 Nov 2023 04:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699095677; cv=none; d=google.com; s=arc-20160816; b=S4xeEjJIwJsxvrKkgMBaH4RHoXa8qKZHfYCPMczXZK+065KElLYmFWm/BlFrDW031A lU6qDXGxc/KBkvUn61guC+tTh/V2d8KgWZc6LdOyYNwim8ipN9aqrHgVVMVb7u+IBRVo np3499TIlgFcBAWbi+Oi+r2qzkVIdev9lXdnnoraKddwQIlZitG0pEGLeuD6otUFaoJn O8lHy6v4xa8HDkIRk8C8plV9PwXSQbB3y3YU99zvkDZLM5j1xUDUietteuiZX/diKdk0 S2aOKlQNQlJSMvBtkrDWbG4SqIsMm4T9oIs1TwRxd9m7ZmSUtp8mQpPf7SSF8TxhdYuf 1SDg== 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=Dfs2XRPeKsTWDY51BaFMUWmP+4pTQh8S0ZCI8/F2mAM=; fh=hclUZirF6ioy5RJ9ji4zprhkXEWhJA3xztaBC4vzfLk=; b=boYU3K/Y3LtKm7Q0CEuD9YngXeaWZmxCsRzN8MaEsQMhJYKwMreAM57tjRnfqEOglI kqW1t/y9b+U376E84o54G1W3rpIJ7gvJlt74m9Da9bEVgCIGN93QpZKSu5ulLJfBi74L 9u5ziwp+zk0xIEV3an6GBYV7Iv78nhreJfdRLzsyJ7dRdQdTDKHFZh96F4BM/r31EFIJ L5XF6eww4n3y49F6jiwdtrTJKMe19CH5ZMZGBXMMnhalArlWZDkTlGRSxXYJ2kU30i+A njJ6BnvlPvVqDLHVRfM4xhQ8Ac2xIkWj1zif87DTxxmvbOROu6IPr4I0eh6Kyx1OtML6 TkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ph805Tps; 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=kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e21-20020a056638021500b00430a3e4a141si938500jaq.105.2023.11.04.04.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 04:01: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=@kernel.org header.s=k20201202 header.b=ph805Tps; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2B8E0807D93F; Sat, 4 Nov 2023 04:00:22 -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 S232463AbjKDLAJ (ORCPT + 35 others); Sat, 4 Nov 2023 07:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232351AbjKDK7v (ORCPT ); Sat, 4 Nov 2023 06:59:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E43F10F7 for ; Sat, 4 Nov 2023 03:59:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2541C433CB; Sat, 4 Nov 2023 10:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699095581; bh=MDvdVHguLiwpNS3H7vcRQ+zWxJrkMCtJsjHIN2wo64Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ph805TpsTvJ/jJ0OQwVNG5ehTEytS9Q3ZOmM1q0SF23ZX4QeD8laH7PB896zYS33G 8gx1MOiolibtU76jNCAiuR6bPKmOv3B3bl0q5NQqUBudwfpedNKHs9RbuJdZgjFZvR QSIBBQckVEyOnUMNi0Z8xIx3qkQne5vxPniejx+xRr8HL3rync1BrCtzQljQvisd74 FWb9BXrc/O0NeL0m4sosuk2DhVNhaawfm4IWDvwCk86Sdfm69MHkuaN36suMLMjlLR wW4tMh8eHJ/GFju+XY8RWwf5iQLHkAKMrSnrZfc9xbslYQYsARFVKNgtnZO+JaaMNF H5/xeUAIDNbSQ== 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 , bristot@kernel.org, Phil Auld Subject: [PATCH v5 2/7] sched/deadline: Collect sched_dl_entity initialization Date: Sat, 4 Nov 2023 11:59:19 +0100 Message-Id: <51acc695eecf0a1a2f78f9a044e11ffd9b316bcf.1699095159.git.bristot@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 04:00:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781630949818347616 X-GMAIL-MSGID: 1781630949818347616 From: Peter Zijlstra Create a single function that initializes a sched_dl_entity. Reviewed-by: Phil Auld Reviewed-by: Valentin Schneider 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 3d7e2d702699..257369d30303 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4509,10 +4509,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 de79719c63c0..e80bb884262d 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -335,6 +335,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. @@ -434,7 +436,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; @@ -1183,7 +1185,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; @@ -1389,7 +1391,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; } @@ -1405,7 +1407,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; @@ -2957,10 +2959,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; @@ -2978,6 +2978,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 3e0e4fc8734b..4f5f5a2778a9 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -273,8 +273,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; @@ -2427,8 +2425,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)