Received: by 10.223.176.5 with SMTP id f5csp2056258wra; Sun, 4 Feb 2018 19:28:24 -0800 (PST) X-Google-Smtp-Source: AH8x224glW63l3ksmvebq7H4vNJCQUsPxWgU8ev7ncK2bYc8XL0lnO3D/C75zoeWVX3S1wdbOWgg X-Received: by 2002:a17:902:720b:: with SMTP id ba11-v6mr11386836plb.371.1517801304555; Sun, 04 Feb 2018 19:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517801304; cv=none; d=google.com; s=arc-20160816; b=e1rGObUMDTv/BMZo1Qra/uDzS1z0R2bdyXQ3FzZOT7+UTtnKpugDrheZxzfL84c2sn OeZIWwzo1+345laClAEcppn20Rj1XW3+6WXy/3Y8dM+0QBqKIBMKIlqN+Dfb8bSppzIw s5GxNl87ara9uVUkBGfcD1vGtlHEaEYhFCE1+qDQiSC05aATskG7RITPX0HrEGxHphVs wo0t10N/kLebOic1qkJxL9iiCYfjDt+IsbXKgJjkGU+EyAYsYtpXMqvRCEZ5xfgKmfSh zfoWbCkLpcdHFo0P+ns5MxJMHlRnn/Dmj2oYfI/JsAO0YtPbKzNcmst0Kqi85yJzYZDL HYCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=tOOLkBKdoP89sKLMtldbvb7FZn0WJJ1xInNbcEesRtU=; b=GgrOqru1+BbjJf/N6bW5wEK958ixhRA+fJcHVFjOcgdFTo02HUa+mb+uqG+j8t8aV9 IgXn6d3H/3w41KhMHrJQnrHRSz3yCkfOjU1xxUDvHR+5ho0xSZc8l+ccpIhQl+dkTzf0 AYf9ImslUN/za0cmStEM8qpicv7bZD1qRKHbMEdcajEjEjLqWC9LfablAHLkGdxeUq92 aQeL17k7LP5nKpKQI5VdT/jOiOsVL3hgDJaNkb7ZbtS7jH4aP2yyh/8d+P2+vUcpmUjh 0i/BWvW1kaYNUqjJ7AMEnc6KZ48H/tyg4onJu3k1VtE5HWIqm8uWnRCuD1ybRYqMqiID opEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si4967444pgn.527.2018.02.04.19.27.44; Sun, 04 Feb 2018 19:28:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbeBEDVB (ORCPT + 99 others); Sun, 4 Feb 2018 22:21:01 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:57606 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751724AbeBEDUz (ORCPT ); Sun, 4 Feb 2018 22:20:55 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 1819885428886F483F2E; Mon, 5 Feb 2018 11:20:53 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w153Ki2X074073; Mon, 5 Feb 2018 11:20:44 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from localhost.localdomain ([10.75.10.200]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018020511204549-3630180 ; Mon, 5 Feb 2018 11:20:45 +0800 From: Wen Yang To: mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org, jiang.biao2@zte.com.cn, zhong.weidong@zte.com.cn, wen.yang99@zte.com.cn Subject: [PATCH] sched/rt: Make update_curr_rt() more accurate Date: Mon, 5 Feb 2018 11:18:41 +0800 Message-Id: <1517800721-42092-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-02-05 11:20:45, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-02-05 11:20:44, Serialize complete at 2018-02-05 11:20:44 X-MAIL: mse01.zte.com.cn w153Ki2X074073 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rq->clock_task may be updated between the two calls of rq_clock_task() in update_curr_rt(). Calling rq_clock_task() only once makes it more accurate and efficient, taking update_curr() as reference. Signed-off-by: Wen Yang Reviewed-by: Jiang Biao --- kernel/sched/rt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 4056c19..d6d2a65 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -950,12 +950,13 @@ static void update_curr_rt(struct rq *rq) { struct task_struct *curr = rq->curr; struct sched_rt_entity *rt_se = &curr->rt; + u64 now = rq_clock_task(rq); u64 delta_exec; if (curr->sched_class != &rt_sched_class) return; - delta_exec = rq_clock_task(rq) - curr->se.exec_start; + delta_exec = now - curr->se.exec_start; if (unlikely((s64)delta_exec <= 0)) return; @@ -968,7 +969,7 @@ static void update_curr_rt(struct rq *rq) curr->se.sum_exec_runtime += delta_exec; account_group_exec_runtime(curr, delta_exec); - curr->se.exec_start = rq_clock_task(rq); + curr->se.exec_start = now; cgroup_account_cputime(curr, delta_exec); sched_rt_avg_update(rq, delta_exec); -- 1.9.1