Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp207329pxb; Wed, 20 Jan 2021 05:14:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKO6fSthLm+yzx5c02N+1wbB/uhGAQ9viUsr7dTqpVY/9QYUkKzy1I/kz4CWFRZY9VYe8b X-Received: by 2002:a17:906:5585:: with SMTP id y5mr1772178ejp.486.1611148441695; Wed, 20 Jan 2021 05:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611148441; cv=none; d=google.com; s=arc-20160816; b=026vIZID+bWPpUfSYi5k4EidOUtTL54BTFiA8t8sCOP29JhTZjQtJAhY50FA2i5yGb o8KkQPPpDAS8BfMZrDMENqe7vXEsNHsoWFkYesIJvCzOblc3S+FkTGMudXYQK23sCvPq oUC3w6raCzovib/DJSV0RXN0mD84+nAJurMGgZSi2y6Tn0gmRa2ZJwQTMooi989iBISC VCt57sfo6A7mW6mh/9ZWbzmUaRSW0L58emcbn1RL2/H42X2c22oG0eBtd0xrC+vHbkKt CX39SxcbAqgCS4AGEVsR5DW3K6kO8iDKJM4n5GbjNDvkyYVY9VlcQebZAFaa16hznAoP C6gw== 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; bh=QWtUxmB1uwI3ErYmWO2naQ89WIz8nD3S4kb+HB+Y/+Y=; b=RzxyFGbK2dLi9rd4d7Garxq5er1oomqx+feUdat/joU0M5ZjSj8gnTqoRuwIk1hvaI G1JJG5lEO39eoqvmPGCUdK0whDxLo/N41ma3bW5uzq3eQbr2zhb4Zpy1dyPluVy7fLxI GAGgao54xu6LwO38j8mZ9rAX/MP7Y6YqIoUN9eEUJEXAKX+yYstcBcC9abTv5ZpRHEP1 +8ERhw6uXLU4uHaBtz4DBsWcp8IdsxwUjIFVI8XrGNUmZ+uwbKcyAXyV7qpt+b+cd9do FAFwuKerjFzuu+aJhRnnPmGmZU1WLTuXHP5GmogNfFNUN//kcgQgoALFUB341lK/CAd0 EYsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr20si674790ejc.23.2021.01.20.05.13.36; Wed, 20 Jan 2021 05:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731941AbhATNKe (ORCPT + 99 others); Wed, 20 Jan 2021 08:10:34 -0500 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:54766 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733307AbhATM2j (ORCPT ); Wed, 20 Jan 2021 07:28:39 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=changhuaixin@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0UMLCqvO_1611145670; Received: from localhost(mailfrom:changhuaixin@linux.alibaba.com fp:SMTPD_---0UMLCqvO_1611145670) by smtp.aliyun-inc.com(127.0.0.1); Wed, 20 Jan 2021 20:27:50 +0800 From: Huaixin Chang To: changhuaixin@linux.alibaba.com Cc: bsegall@google.com, dietmar.eggemann@arm.com, juri.lelli@redhat.com, khlebnikov@yandex-team.ru, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, pauld@redhead.com, peterz@infradead.org, pjt@google.com, rostedt@goodmis.org, shanpeic@linux.alibaba.com, vincent.guittot@linaro.org, xiyou.wangcong@gmail.com Subject: [PATCH 3/4] sched/fair: Add cfs bandwidth burst statistics Date: Wed, 20 Jan 2021 20:27:14 +0800 Message-Id: <20210120122715.29493-4-changhuaixin@linux.alibaba.com> X-Mailer: git-send-email 2.14.4.44.g2045bb6 In-Reply-To: <20210120122715.29493-1-changhuaixin@linux.alibaba.com> References: <20201217074620.58338-1-changhuaixin@linux.alibaba.com> <20210120122715.29493-1-changhuaixin@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce statistics exports for the burstable cfs bandwidth controller. The following exports are included: current_bw: current runtime in global pool nr_burst: number of periods bandwidth burst occurs burst_time: cumulative wall-time that any cpus has used above quota in respective periods Signed-off-by: Huaixin Chang Signed-off-by: Shanpei Chen --- kernel/sched/core.c | 6 ++++++ kernel/sched/fair.c | 12 +++++++++++- kernel/sched/sched.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index fecf0f05ef0c..80ca763ca492 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7986,6 +7986,8 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota, cfs_b->runtime = min(max_cfs_runtime, cfs_b->runtime); } + cfs_b->previous_runtime = cfs_b->runtime; + /* Restart the period timer (if active) to handle new period expiry: */ if (runtime_enabled) start_cfs_bandwidth(cfs_b, 1); @@ -8234,6 +8236,10 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v) seq_printf(sf, "wait_sum %llu\n", ws); } + seq_printf(sf, "current_bw %llu\n", cfs_b->runtime); + seq_printf(sf, "nr_burst %d\n", cfs_b->nr_burst); + seq_printf(sf, "burst_time %llu\n", cfs_b->burst_time); + return 0; } #endif /* CONFIG_CFS_BANDWIDTH */ diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 38a726f77783..e431b2fff01d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4600,7 +4600,7 @@ static inline u64 sched_cfs_bandwidth_slice(void) */ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b, u64 overrun) { - u64 refill; + u64 refill, runtime; if (cfs_b->quota != RUNTIME_INF) { @@ -4609,10 +4609,20 @@ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b, u64 overrun) return; } + if (cfs_b->previous_runtime > cfs_b->runtime) { + runtime = cfs_b->previous_runtime - cfs_b->runtime; + if (runtime > cfs_b->quota) { + cfs_b->burst_time += runtime - cfs_b->quota; + cfs_b->nr_burst++; + } + } + overrun = min(overrun, cfs_b->max_overrun); refill = cfs_b->quota * overrun; cfs_b->runtime += refill; cfs_b->runtime = min(cfs_b->runtime, cfs_b->buffer); + + cfs_b->previous_runtime = cfs_b->runtime; } } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index ff8b5382485d..4adb984e5197 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -367,6 +367,7 @@ struct cfs_bandwidth { u64 burst; u64 buffer; u64 max_overrun; + u64 previous_runtime; s64 hierarchical_quota; u8 idle; @@ -379,7 +380,9 @@ struct cfs_bandwidth { /* Statistics: */ int nr_periods; int nr_throttled; + int nr_burst; u64 throttled_time; + u64 burst_time; #endif }; -- 2.14.4.44.g2045bb6