From patchwork Tue Oct 31 12:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 160107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp216900vqg; Tue, 31 Oct 2023 06:00:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhiKEoV69ZTVz4I1+McWx9r5Xyazq6L8nvcIor0xx/9Eir8W0rRJZW88OcxaHnaV/ap2jG X-Received: by 2002:a17:90b:4c81:b0:280:74fc:6545 with SMTP id my1-20020a17090b4c8100b0028074fc6545mr4025675pjb.24.1698757258818; Tue, 31 Oct 2023 06:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698757258; cv=none; d=google.com; s=arc-20160816; b=zoOPnmRsleF1I6KqorbiEsvN3dZ/0t+2lzTNjyIS+yOptR4F7eV6jh8F7aBYD1NaFS iMJrIePm9PQypMNepHMOoL6vaDHoZTNCQT4PnW7YhUORavK0+quZgfhl7VwJdWyYWcp5 LYwFz1WGcPlE0fhDlxje2/0T2gEt4zRtdVnCzGhu8YfPgDoELHtkEmLUmDl31dKMyScf N9tg3a+he4nBQet8/t9j81vZH5pkISth2/XkdQG9Lr/G5jgM+BjE+OzbAmPPnX2MpBfj soydZWHvEMmt2pLar24mIqVveTmY0JQI6n4WXtIKMGNDYWhw9gQ31xG1NL/rE4xB0x1L Qmzw== 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=i7mRzGepikGwf8IInKfZWrq3Ja/myVvXm98PYematwc=; fh=kY5sJNvn29qhEh2SatEVpXE2cTkcQ8AnU+xu9Bnn8Ic=; b=MHfnLW3lvgySroQBCAB4uCJgKZBs++Ex6QBQ8joirxpgXLH5ENuQ4SNcl3UvvrfMFq RjYKwvHfJQWBZaRT7NSzQNRf9tbypsWEErkvPMGZETkQIMe8S2Vv95DHdyS/PdGg72Pz JHAgBOecINKFlbIdCr6ND02xl+KUNj2SUD9MaS2RJ9tUm7uNqykLL0wOPI+vLIT7Tm7S gCTFy18aTyWz87G4cWRE8qqIZ9qcBgmHUaWp8epCBrE+WJcbqLgs1oXKiiJcRL72ksL4 Ec2N1DguOxI8aneIFR3HbSWKftOat+Px9ltG0NfbvnpYGSPKrHNplX06jEbB9IazS2EW Hw3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="TQvO/62h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id fa18-20020a17090af0d200b002804438ebcfsi924532pjb.171.2023.10.31.06.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="TQvO/62h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D1B6A80A90F0; Tue, 31 Oct 2023 06:00:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344422AbjJaNAb (ORCPT + 33 others); Tue, 31 Oct 2023 09:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344430AbjJaNA0 (ORCPT ); Tue, 31 Oct 2023 09:00:26 -0400 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [IPv6:2001:41d0:1004:224b::ac]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B6EFD for ; Tue, 31 Oct 2023 06:00:23 -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=1698757221; 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=i7mRzGepikGwf8IInKfZWrq3Ja/myVvXm98PYematwc=; b=TQvO/62h1NO17SquF88fUpY2eQXVXl/k9nBKSzhcRfe9yYNpYkurG3z+udinUJBmAvUZRp uZJ+4XY8KE2msF1PjSG2XL2hNBmSbuOY5xjrrs8VMtEedUg20kxqTq3AZPcTAdS+hSch+T xrMx9qEi3OLK0Bhv5kbLlZWi1nbKK8A= 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 v3 3/3] sched/fair: Simplify update_curr() Date: Tue, 31 Oct 2023 20:59:28 +0800 Message-Id: <20231031125928.235685-4-yajun.deng@linux.dev> In-Reply-To: <20231031125928.235685-1-yajun.deng@linux.dev> References: <20231031125928.235685-1-yajun.deng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 06:00:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781276091775934591 X-GMAIL-MSGID: 1781276091775934591 Use update_current_exec_runtime() simplify update_curr(). Signed-off-by: Yajun Deng --- v3: New patch. --- kernel/sched/fair.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2048138ce54b..ffc000e49db5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1135,6 +1135,7 @@ static void update_tg_load_avg(struct cfs_rq *cfs_rq) static void update_curr(struct cfs_rq *cfs_rq) { struct sched_entity *curr = cfs_rq->curr; + struct task_struct *curtask = rq_of(cfs_rq)->curr; u64 now = rq_clock_task(rq_of(cfs_rq)); u64 delta_exec; @@ -1145,8 +1146,6 @@ static void update_curr(struct cfs_rq *cfs_rq) if (unlikely((s64)delta_exec <= 0)) return; - curr->exec_start = now; - if (schedstat_enabled()) { struct sched_statistics *stats; @@ -1155,20 +1154,14 @@ static void update_curr(struct cfs_rq *cfs_rq) max(delta_exec, stats->exec_max)); } - curr->sum_exec_runtime += delta_exec; schedstat_add(cfs_rq->exec_clock, delta_exec); curr->vruntime += calc_delta_fair(delta_exec, curr); update_deadline(cfs_rq, curr); update_min_vruntime(cfs_rq); - if (entity_is_task(curr)) { - struct task_struct *curtask = task_of(curr); - - trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime); - cgroup_account_cputime(curtask, delta_exec); - account_group_exec_runtime(curtask, delta_exec); - } + update_current_exec_runtime(curtask, now, delta_exec, + entity_is_task(curr)); account_cfs_rq_runtime(cfs_rq, delta_exec); }