Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp427186pxb; Thu, 9 Sep 2021 04:20:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpd1X768eGe2090VKEhRIoTPFHGNS6MWgTn5dTFMwKlaVOF1UZIVp4HnDm6HhrsrStopQL X-Received: by 2002:a05:6402:524e:: with SMTP id t14mr2658831edd.66.1631186414893; Thu, 09 Sep 2021 04:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631186414; cv=none; d=google.com; s=arc-20160816; b=z+QIG848CGA7T8DL7g9H31PM3IXQfTaRK4auH3FMk2bwu3Yd/WbcxIwMBU2ofk44N8 J6TPDAM73yMUtDHPT11vw4U8x9r7ntzpE3s2mXyEuvpKgoQ3dtIyWsFL8Me5nATlQxKR 3HpRHRKU1RnohoBggYzfVdTHkXaVimgo4VyshiEi1VOM0VSvOQhlleaMYXaIxvmllPcz KQ1ZHXJVCfOjrn/ZeIBw3mzR3tpIs9KM4Kpdm/M4ZkTaT3aUBMl5IDRgRULoP0p0kf9R Ugf8x87Aox23ZGyqV87YEWeKLtk6rlOHkJGpVLmlnK5qwadTzZK07tjwLxfeTbTQzBFB TXAA== 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=c9LxyIzT7tbuE9vPDKoSKeP6OATfuYQLOjfEXQqOtGM=; b=R8aEW0uYQ9gRKfJRhGysbcLw7ObJ0vnFBR/KJTineQ+KFpsHEkEL/mgYbaUTRzvWZy UkGYhTcG54kmkWZtUpGw26I5N3YJUU/d+r3B3kkTFhir1z6CqwbwBsFvxVTOjs2vFGCM f73Pd/KQ3tgXQkD68jdIPhZVz9xllQ2g682F4i8bjkUmLCY+nWI2p94ax7qP0ZUhf2PX Z8SfQE9BZ3CKYJkHJ/v9t0GPFk05RSRJPf3IuFofhDLotIYSYgWWp2ny74BCQTI+RL0h MYwfVYvl7d/j5IroMXsTyIoLdBBAWElcTWa2Itz/i8hZajhYu4lLidWh/1QeFT8IXUh3 SQ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UgjlAaLT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="5/HdnwIU"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si1396466ejb.219.2021.09.09.04.19.51; Thu, 09 Sep 2021 04:20:14 -0700 (PDT) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UgjlAaLT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="5/HdnwIU"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235248AbhIILTh (ORCPT + 99 others); Thu, 9 Sep 2021 07:19:37 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58502 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbhIILTh (ORCPT ); Thu, 9 Sep 2021 07:19:37 -0400 Date: Thu, 09 Sep 2021 11:18:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1631186306; 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=c9LxyIzT7tbuE9vPDKoSKeP6OATfuYQLOjfEXQqOtGM=; b=UgjlAaLTc5LqdeuENifE4uic9vfRcjmNtAVrfpNwTnJczSR6sGYanwwGvkJgkkvR4lJ9pI Z2pResiM2v+ZOT/D63Lzv4U6+Xz8RJfllH5TzpZelwpchtgkhylv1+3hRpX5RTsCeGWW5p zyu8A87kp+qKufQD1krVe6Nd88tqPSEyZZpcTWWkm8J5UpfhRllVTDuvjngnug7kyhwCJj SGtgKuavbHdqkaNOxWQK3+X2Z0FYOuaQdVJR971DTBIe6o2FdlKjN9qiEOFsyfJ+iSJ1in xOQ3UFh7v62ra0epWSW3gVWDfiKpcV2+6Y1bCAQTmZXEpp29zqgg6RXs+RWo5Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1631186306; 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=c9LxyIzT7tbuE9vPDKoSKeP6OATfuYQLOjfEXQqOtGM=; b=5/HdnwIURWHjfScaRNspGpl7yI59aBRb5SVnL4cDPh27Vlral8xcMmoKd9aW7fjAAVhqnJ oOT0+uWPG6nTuoBw== From: "tip-bot2 for Huaixin Chang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Add cfs bandwidth burst statistics Cc: Shanpei Chen , Tianchen Ding , Huaixin Chang , "Peter Zijlstra (Intel)" , Daniel Jordan , Tejun Heo , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210830032215.16302-2-changhuaixin@linux.alibaba.com> References: <20210830032215.16302-2-changhuaixin@linux.alibaba.com> MIME-Version: 1.0 Message-ID: <163118630598.25758.15834865249735555102.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 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: 9525616d056e29f7900796cb0c19b38ad274b0eb Gitweb: https://git.kernel.org/tip/9525616d056e29f7900796cb0c19b38ad274b0eb Author: Huaixin Chang AuthorDate: Mon, 30 Aug 2021 11:22:14 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 09 Sep 2021 11:27:32 +02:00 sched/fair: Add cfs bandwidth burst statistics Two new statistics are introduced to show the internal of burst feature and explain why burst helps or not. nr_bursts: number of periods bandwidth burst occurs burst_time: cumulative wall-time (in nanoseconds) that any cpus has used above quota in respective periods Co-developed-by: Shanpei Chen Signed-off-by: Shanpei Chen Co-developed-by: Tianchen Ding Signed-off-by: Tianchen Ding Signed-off-by: Huaixin Chang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Daniel Jordan Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20210830032215.16302-2-changhuaixin@linux.alibaba.com --- kernel/sched/core.c | 13 ++++++++++--- kernel/sched/fair.c | 9 +++++++++ kernel/sched/sched.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 953ff36..2877138 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10244,6 +10244,9 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v) seq_printf(sf, "wait_sum %llu\n", ws); } + seq_printf(sf, "nr_bursts %d\n", cfs_b->nr_burst); + seq_printf(sf, "burst_time %llu\n", cfs_b->burst_time); + return 0; } #endif /* CONFIG_CFS_BANDWIDTH */ @@ -10359,16 +10362,20 @@ static int cpu_extra_stat_show(struct seq_file *sf, { struct task_group *tg = css_tg(css); struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; - u64 throttled_usec; + u64 throttled_usec, burst_usec; throttled_usec = cfs_b->throttled_time; do_div(throttled_usec, NSEC_PER_USEC); + burst_usec = cfs_b->burst_time; + do_div(burst_usec, NSEC_PER_USEC); seq_printf(sf, "nr_periods %d\n" "nr_throttled %d\n" - "throttled_usec %llu\n", + "throttled_usec %llu\n" + "nr_bursts %d\n" + "burst_usec %llu\n", cfs_b->nr_periods, cfs_b->nr_throttled, - throttled_usec); + throttled_usec, cfs_b->nr_burst, burst_usec); } #endif return 0; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b27ed8b..3594884 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4686,11 +4686,20 @@ static inline u64 sched_cfs_bandwidth_slice(void) */ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b) { + s64 runtime; + if (unlikely(cfs_b->quota == RUNTIME_INF)) return; cfs_b->runtime += cfs_b->quota; + runtime = cfs_b->runtime_snap - cfs_b->runtime; + if (runtime > 0) { + cfs_b->burst_time += runtime; + cfs_b->nr_burst++; + } + cfs_b->runtime = min(cfs_b->runtime, cfs_b->quota + cfs_b->burst); + cfs_b->runtime_snap = cfs_b->runtime; } static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 6b2d8b7..094ea86 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -369,6 +369,7 @@ struct cfs_bandwidth { u64 quota; u64 runtime; u64 burst; + u64 runtime_snap; s64 hierarchical_quota; u8 idle; @@ -381,7 +382,9 @@ struct cfs_bandwidth { /* Statistics: */ int nr_periods; int nr_throttled; + int nr_burst; u64 throttled_time; + u64 burst_time; #endif };