Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp859547imm; Wed, 25 Jul 2018 07:24:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf9ZXvgp/BGwnj15/VRK+wf87qRtOUib9XW6UQ3DhGx+W4juazShEdfNanOcyZD5fuytuBB X-Received: by 2002:a65:5141:: with SMTP id g1-v6mr20579797pgq.418.1532528683454; Wed, 25 Jul 2018 07:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532528683; cv=none; d=google.com; s=arc-20160816; b=c2YSTEDhEY8d2AP76w26/D1/CDCn68q+bPEwdX/ApHEWgdAwj0BXIfThgq4b7zGKhm 554vVhFV9cqZPErrBfM84/MvigAgLq0LZGPo8ZfkOsLEp6Z6hb78RWK87VJlrpgwfgMl MmRzA9VB6bk4FExejkCr3gEWv8DJOWsxr5pLr8BKLoJ+0UKRlctAhwbDizMKguH7eE2y pyMI6qO29MAFc4fDGyNdhriO9WB8PLr+vvDpc3Mnqh8hDg4u7iR/MAu+iLSoDNHfSIMS 0Eyaw7MBlgWBxmG7R2ojE1q5OAfDj/Q56aitWwUMVIvCmfTPPu9ALM4Py4lhaegLf+/U fDEg== 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=MVLWVmZHypW613EoGnpOm8taE/HlXk2uq3o8rUqRkU0=; b=q8O3WaF43/fbY6GAmDvSVyaif6u0mk/7n6igdAT0u6jn/cuER+VMYLOUu8Z3sepkCy nG2kw830HuJrvn3zjwySTEbh+xMZRm2ThhuOyN19Ac1H2/t2t7Lp7sY3ClfQ57aXjtZE wVnr+adU9TkDaBJtq6ulfFDdfsWGxH3ErcUomJVb8m+SPYNdXNP9y6vuplA24KZ67tiB plYHQJkFmAK9Y6GiWqDGhXmhLk6r7dT6QirP6JQ0DV+sJS8Ols/FaI5BwOUnBww+u6/0 3kMmOPbT5W03/9Dysnl7MUbJVXtAOGmtHKidmh9WwFbyvO/EqF3+lXPwIsZuPBx3NLvm hyHQ== 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 3-v6si14046199pgm.37.2018.07.25.07.24.28; Wed, 25 Jul 2018 07:24:43 -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 S1729077AbeGYPfc (ORCPT + 99 others); Wed, 25 Jul 2018 11:35:32 -0400 Received: from terminus.zytor.com ([198.137.202.136]:44929 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbeGYPfc (ORCPT ); Wed, 25 Jul 2018 11:35:32 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6PENFqk400317 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 Jul 2018 07:23:15 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6PENFab400314; Wed, 25 Jul 2018 07:23:15 -0700 Date: Wed, 25 Jul 2018 07:23:15 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Yun Wang Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, yun.wang@linux.alibaba.com, torvalds@linux-foundation.org Reply-To: hpa@zytor.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, yun.wang@linux.alibaba.com, peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/debug: Show the sum wait time of a task group Git-Commit-ID: 3d6c50c27bd6418dceb51642540ecfcb8ca708c2 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=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no 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: 3d6c50c27bd6418dceb51642540ecfcb8ca708c2 Gitweb: https://git.kernel.org/tip/3d6c50c27bd6418dceb51642540ecfcb8ca708c2 Author: Yun Wang AuthorDate: Wed, 4 Jul 2018 11:27:27 +0800 Committer: Ingo Molnar CommitDate: Wed, 25 Jul 2018 11:41:05 +0200 sched/debug: Show the sum wait time of a task group Although we can rely on cpuacct to present the CPU usage of task groups, it is hard to tell how intense the competition is between these groups on CPU resources. Monitoring the wait time or sched_debug of each process could be very expensive, and there is no good way to accurately represent the conflict with these info, we need the wait time on group dimension. Thus we introduce group's wait_sum to represent the resource conflict between task groups, which is simply the sum of the wait time of the group's cfs_rq. The 'cpu.stat' is modified to show the statistic, like: nr_periods 0 nr_throttled 0 throttled_time 0 wait_sum 2035098795584 Now we can monitor the changes of wait_sum to tell how much a a task group is suffering in the fight of CPU resources. For example: (wait_sum - last_wait_sum) * 100 / (nr_cpu * period_ns) == X% means the task group paid X percentage of period on waiting for the CPU. Signed-off-by: Michael Wang Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/ff7dae3b-e5f9-7157-1caa-ff02c6b23dc1@linux.alibaba.com Signed-off-by: Ingo Molnar --- kernel/sched/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index fc177c06e490..2bc391a574e6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6748,6 +6748,16 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v) seq_printf(sf, "nr_throttled %d\n", cfs_b->nr_throttled); seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time); + if (schedstat_enabled() && tg != &root_task_group) { + u64 ws = 0; + int i; + + for_each_possible_cpu(i) + ws += schedstat_val(tg->se[i]->statistics.wait_sum); + + seq_printf(sf, "wait_sum %llu\n", ws); + } + return 0; } #endif /* CONFIG_CFS_BANDWIDTH */