Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp851099rwe; Fri, 26 Aug 2022 16:25:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wgcyWvKqrZS4gCXFSp9pxdoybTTHn0LSIvjuGKL63tNT5CnLB58gJQUmyo0LauJ4IJGnK X-Received: by 2002:a17:903:22c1:b0:16f:3d1:f5c with SMTP id y1-20020a17090322c100b0016f03d10f5cmr5777828plg.155.1661556308195; Fri, 26 Aug 2022 16:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661556308; cv=none; d=google.com; s=arc-20160816; b=xI9RQI3+XS8TSnuaYEJlZvkmScPKvB7GTWdeR5/93LsINw9j5zfXI4TH1XSVODF+fo CiszMvGPoJHcFPPqVBEQeCL5+vbszi2dXAXY0R/rWadXLy4POfcy6TGCeX8aQ+IoL3fJ pa/yqLft2y2lUc1Xzjwj5HeHe+UO19Sje7rfffI93fBdumkGOnIpBzIGaXnXSvEJ1oz3 Q+mwhZqmFg9/F4m8Qu1vem+xXanCMTo/o0GfBEbp/N/9/305lHV2na6bz6NEYImKbLNJ SPnXQY1dtv5LWoydTjMljGX3MYi2Tprdxj+hghh2PsC89o3V2q8gbf3HDWuKcDI8EMHj T2Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=L8rcOv9bnjFEhaP3jUDMABc6AkpKsSPaO+6Q7g/NYuo=; b=OAqiY1vG7mHI/tsXHUZ7OQy9VKWyc95rywW8OhNHaAYUfVLS6pDLEmYHVYt34zXRK4 R+F+uAxO8UM3UIhvy/qsJwzXfjxo+Lc3jSmj1P040D8jpCguqHj2+TLjz69+sWtmaAHW DG5U2ppKmhOjsjJyzojGUzWhzZyjWRp79LdlLQNRX55Fi4ITSVfWV3pC8PSBlEHmpYu3 w6KuZhimBrfx7DgSAQOIOVLjQhasN11CDNb338dME5J6kWOYO/IwbHE2fDwdMMF1p7fB DOSUXfj93tBo+IkjCjyoMRzGqMdyVLt4zKPVEyYBQV2Q2nhDzq57wpf2irYR6HvMamUS DPqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=soh7whY9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="xz27I/Ui"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj11-20020a17090b4d8b00b001fb3841e074si3421903pjb.163.2022.08.26.16.24.56; Fri, 26 Aug 2022 16:25:08 -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=@linutronix.de header.s=2020 header.b=soh7whY9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="xz27I/Ui"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345397AbiHZWSs (ORCPT + 99 others); Fri, 26 Aug 2022 18:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345312AbiHZWSA (ORCPT ); Fri, 26 Aug 2022 18:18:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FFFE97F7; Fri, 26 Aug 2022 15:16:28 -0700 (PDT) Date: Fri, 26 Aug 2022 22:16:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1661552185; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L8rcOv9bnjFEhaP3jUDMABc6AkpKsSPaO+6Q7g/NYuo=; b=soh7whY9hpUNj9IdXiS5pppsD/5lKUo2kUyO6I2+k6XNCPs9LihZLBhP3acLjhanDs+OvX i1j9IGeA2hScNrT6IllOEq8sFs251IYnl/cHWuA/iq0EMIpUq1WFmhbP9yHwkFGjne06TQ pi4Cs/4rXVlTFeoAZDibDr057zZEACT7vHMpv00QaTBonI9YketJ4+gdgkRfCL0ig/VRQs 5awRosSGwOVSwnkhhzu80mTWLR2HnKpsbSJam5m2B0mSQZCPcY2u0LZDE1Y7iQoEaRQjx1 czah0akk0JScLlozE+c2Rl7Fyx0BB4+7OwMqy3/fat/LkB9yNzqWqK+ik5aLDQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1661552185; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L8rcOv9bnjFEhaP3jUDMABc6AkpKsSPaO+6Q7g/NYuo=; b=xz27I/UiJUldxqZekmKozq73WC2hv5vZYh327A6eWL9CoAwzB9JvtM/o+5bANbYcHDLWfi XohwSs+ErHsaf+DQ== From: "tip-bot2 for Shang XiaoJing" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Add update_current_exec_runtime helper Cc: Shang XiaoJing , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220824082856.15674-1-shangxiaojing@huawei.com> References: <20220824082856.15674-1-shangxiaojing@huawei.com> MIME-Version: 1.0 Message-ID: <166155218400.401.13859107788980871095.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,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 The following commit has been merged into the sched/core branch of tip: Commit-ID: 5531ecffa4b923bc7739e9ea73c552d80af602dc Gitweb: https://git.kernel.org/tip/5531ecffa4b923bc7739e9ea73c552d80af602dc Author: Shang XiaoJing AuthorDate: Wed, 24 Aug 2022 16:28:56 +08:00 Committer: Peter Zijlstra CommitterDate: Sat, 27 Aug 2022 00:05:35 +02:00 sched: Add update_current_exec_runtime helper Wrap repeated code in helper function update_current_exec_runtime for update the exec time of the current. Signed-off-by: Shang XiaoJing Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220824082856.15674-1-shangxiaojing@huawei.com --- kernel/sched/deadline.c | 6 +----- kernel/sched/rt.c | 6 +----- kernel/sched/sched.h | 10 ++++++++++ kernel/sched/stop_task.c | 11 ++++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 1d9c909..4cbdc0c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1333,11 +1333,7 @@ static void update_curr_dl(struct rq *rq) trace_sched_stat_runtime(curr, delta_exec, 0); - curr->se.sum_exec_runtime += delta_exec; - account_group_exec_runtime(curr, delta_exec); - - curr->se.exec_start = now; - cgroup_account_cputime(curr, delta_exec); + update_current_exec_runtime(curr, now, delta_exec); if (dl_entity_is_special(dl_se)) return; diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 054b671..4bc84a1 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1062,11 +1062,7 @@ static void update_curr_rt(struct rq *rq) trace_sched_stat_runtime(curr, delta_exec, 0); - curr->se.sum_exec_runtime += delta_exec; - account_group_exec_runtime(curr, delta_exec); - - curr->se.exec_start = now; - cgroup_account_cputime(curr, delta_exec); + update_current_exec_runtime(curr, now, delta_exec); if (!rt_bandwidth_enabled()) return; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 74130a6..da17be6 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3158,4 +3158,14 @@ extern int sched_dynamic_mode(const char *str); extern void sched_dynamic_update(int mode); #endif +static inline void update_current_exec_runtime(struct task_struct *curr, + u64 now, u64 delta_exec) +{ + curr->se.sum_exec_runtime += delta_exec; + account_group_exec_runtime(curr, delta_exec); + + curr->se.exec_start = now; + cgroup_account_cputime(curr, delta_exec); +} + #endif /* _KERNEL_SCHED_SCHED_H */ diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c index d04073a..8559059 100644 --- a/kernel/sched/stop_task.c +++ b/kernel/sched/stop_task.c @@ -71,20 +71,17 @@ static void yield_task_stop(struct rq *rq) static void put_prev_task_stop(struct rq *rq, struct task_struct *prev) { struct task_struct *curr = rq->curr; - u64 delta_exec; + u64 now, delta_exec; - delta_exec = rq_clock_task(rq) - curr->se.exec_start; + now = rq_clock_task(rq); + delta_exec = now - curr->se.exec_start; if (unlikely((s64)delta_exec < 0)) delta_exec = 0; schedstat_set(curr->stats.exec_max, max(curr->stats.exec_max, delta_exec)); - curr->se.sum_exec_runtime += delta_exec; - account_group_exec_runtime(curr, delta_exec); - - curr->se.exec_start = rq_clock_task(rq); - cgroup_account_cputime(curr, delta_exec); + update_current_exec_runtime(curr, now, delta_exec); } /*