Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp855202imm; Tue, 3 Jul 2018 00:52:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIT3nla5TOUr6y7S13+CNLKV3q+CGW7TmcQfyDtj3BvbqNCIdgtisQ2ac1PrRlGgfHpxOeR X-Received: by 2002:a17:902:bb05:: with SMTP id l5-v6mr28867184pls.246.1530604348428; Tue, 03 Jul 2018 00:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530604348; cv=none; d=google.com; s=arc-20160816; b=SS6Mt7yNYi9v2VNG8IMnixCBvvRTE71SMlNNKqFJMdAzG4v2KIZxccb6tvYZGVT1Ig 9uMBoLIPHn8jgqoChkfHzpwJ71ETX/tnRoWLMBCCXAkmgN2NwPdPgcAWjheizcwns/KP EcCOxvFl/eO58gwSoJG/6Q2CmcUht2U+bcYUQHmMzSmIfMxkqgDv7onmcEa3BGepjQRn kPOQfsAbiSJ+40fgBI96+9ata1zh/YSakQibU7y6SKY2sgC4mFoyMQh7e1CZZ+QtOOVE RKsJCZN0tRnWLZ/NLo6AAH/y9zeqjNhy93eGGYb0wUvSFhiNq/dKUW6hDFkPpUZYT3Ny N4Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=KutvsgD5jlCnpq+2gtm4xfe6HgFn6el6AVcbdkgjaI0=; b=yRt5/tWMCX0CTGR8pVFjItdFLuukSKUnqsgJbeOw6jxHMzfidM7OZuOxvAhHIxv/K3 uU/1kBGq0KlLKRfwsqqqcDHd2a58r7eWrkSwnRwuzmI3w3POsuT8esXx+6F7HbS9c0fh ZO/0vhTS7oSIi6QvYmSGdl8GccbF00BPZUj69roswni7Mtb08gbtuF6yOJ1SNnfAsbEQ PtgnRNoTyULky1ZJoGfRnjDMIJWlWH2z/p2JoXjJBcu9LVFvfZC316q4vg+MMppN9wSV V4MpiSexV+gLkDQ2I1w7z4j3wuaXqKPw4gRKWc7cJjHn1sQZ+6snNYHMkrspeSYhisIk C5iA== 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 o32-v6si527298pld.440.2018.07.03.00.52.13; Tue, 03 Jul 2018 00:52:28 -0700 (PDT) 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 S933613AbeGCHvD (ORCPT + 99 others); Tue, 3 Jul 2018 03:51:03 -0400 Received: from terminus.zytor.com ([198.137.202.136]:55361 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932212AbeGCHvA (ORCPT ); Tue, 3 Jul 2018 03:51:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w637oc8P201864 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Jul 2018 00:50:38 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w637ocdL201861; Tue, 3 Jul 2018 00:50:38 -0700 Date: Tue, 3 Jul 2018 00:50:38 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Xunlei Pang Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, bsegall@google.com, xlpang@linux.alibaba.com, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org Reply-To: peterz@infradead.org, mingo@kernel.org, hpa@zytor.com, xlpang@linux.alibaba.com, bsegall@google.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de In-Reply-To: <20180620101834.24455-2-xlpang@linux.alibaba.com> References: <20180620101834.24455-2-xlpang@linux.alibaba.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/fair: Advance global expiration when period timer is restarted Git-Commit-ID: f1d1be8aee6c461652aea8f58bedebaa73d7f4d3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f1d1be8aee6c461652aea8f58bedebaa73d7f4d3 Gitweb: https://git.kernel.org/tip/f1d1be8aee6c461652aea8f58bedebaa73d7f4d3 Author: Xunlei Pang AuthorDate: Wed, 20 Jun 2018 18:18:34 +0800 Committer: Ingo Molnar CommitDate: Tue, 3 Jul 2018 09:17:29 +0200 sched/fair: Advance global expiration when period timer is restarted When period gets restarted after some idle time, start_cfs_bandwidth() doesn't update the expiration information, expire_cfs_rq_runtime() will see cfs_rq->runtime_expires smaller than rq clock and go to the clock drift logic, wasting needless CPU cycles on the scheduler hot path. Update the global expiration in start_cfs_bandwidth() to avoid frequent expire_cfs_rq_runtime() calls once a new period begins. Signed-off-by: Xunlei Pang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Ben Segall Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180620101834.24455-2-xlpang@linux.alibaba.com Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 791707c56886..840b92ee6f89 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5204,13 +5204,18 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b) { + u64 overrun; + lockdep_assert_held(&cfs_b->lock); - if (!cfs_b->period_active) { - cfs_b->period_active = 1; - hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); - hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED); - } + if (cfs_b->period_active) + return; + + cfs_b->period_active = 1; + overrun = hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); + cfs_b->runtime_expires += (overrun + 1) * ktime_to_ns(cfs_b->period); + cfs_b->expires_seq++; + hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED); } static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)