Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp316728imm; Mon, 9 Jul 2018 02:13:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe97K/V8XsE9JSHOmX4acGln0W3m658Z5UzzsDbHu4SXNVZMd7brYrA+CQkJqug0hwaPykC X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr19603395plf.109.1531127626886; Mon, 09 Jul 2018 02:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531127626; cv=none; d=google.com; s=arc-20160816; b=YuQaWq+EvLDweZ6tNug/ZrZvINUnEVZeDsCh1HKF8qpt33o74NcR4SNTBIkmQy4QGS mV1aWeO5wUh9p/+rWnRQ1JqOHVg/vUMGA+GQiCoVIXE+cjQXoySPSD7PNeCrBalD9HAZ ld5C3oPIhyvlPVxF9WtNiLibPuJWRNPFv2q2BFsuvks1jSykwn8S29j6TZp0pZZR/tjq 97KXJvbzlT9eeg7H9sEnwdF4cHc4atRSpl+TsRdIkmbRfJRuKi8AFrAw/FhPixFq4n+s SmVGfGltcJ3Y793IYLj+5Zo8AXfdelPOaEG/FK5n5rXcd1ynL5v6TTfnm5tERY9Irx1a Xmjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:arc-authentication-results; bh=jvbGNoiI6pfLK2Wj0rEvYDgmbOmaaZMaBT1Eq2cL6f4=; b=VQ3mRmVR6fKUgqXIzv2EnmH3QTKm/e/l9QcLaMoxVYh+9AIPCKruMUzNhhGRfD77er oKbCAPnB3hmjrYRMlM4H5hfD1gimY13ume6HlfEX2yqE8v546FEUs/qAiAdhAx1TDMEy dFZ1HvlSMNbEhaxcZXKpdNHBE899i5PHMvmtB5BAAF5lsOEEecXeQNyJxpCJMXiE0UXB VnZMtCntWNNv9MS3oE09R16JW4UB+cO5ZYhIbF9/Zj0/uXdkDfc4Zo5BxYxYon+zQGlo JcpdYiyBkCQstxlnGN30c0uIW3HCpbb2nJrm+1KDYTIpxKI2WD6n4/+WmymchEacwsY0 QrqA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b39-v6si14011067plb.249.2018.07.09.02.13.30; Mon, 09 Jul 2018 02:13:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754419AbeGIJMt (ORCPT + 99 others); Mon, 9 Jul 2018 05:12:49 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:32794 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbeGIJMs (ORCPT ); Mon, 9 Jul 2018 05:12:48 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R861e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0T4HBdjG_1531127553; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0T4HBdjG_1531127553) by smtp.aliyun-inc.com(127.0.0.1); Mon, 09 Jul 2018 17:12:34 +0800 Subject: Re: [PATCH v2] tg: show the sum wait time of an task group From: =?UTF-8?B?546L6LSH?= To: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org References: <5c4c978d-e8fb-4bcb-b942-3c6d3dcfc13e@linux.alibaba.com> Message-ID: <81d051ee-c428-5360-b459-a4902904d237@linux.alibaba.com> Date: Mon, 9 Jul 2018 17:12:33 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/7/4 上午11:27, 王贇 wrote: > Although we can rely on cpuacct to present the cpu usage of task > group, it is hard to tell how intense the competition is between > these groups on cpu resources. > > Monitoring the wait time of each process or sched_debug could cost > too much, and there is no good way to accurately represent the > conflict with these info, we need the wait time on group dimension. > > Thus we introduced group's wait_sum represent the conflict between > task groups, which is simply sum the wait time of 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 changing on wait_sum to tell how suffering > a task group is 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. Hi, Peter How do you think about this proposal? There are situation that tasks in some group suffered much more than others, will be good to have some way to easily locate them. Regards, Michael Wang > > Signed-off-by: Michael Wang > --- > > Since v1: >   Use schedstat_val to avoid compile error >   Check and skip root_task_group > >  kernel/sched/core.c | 8 ++++++++ >  1 file changed, 8 insertions(+) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 78d8fac..80ab995 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -6781,6 +6781,8 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota) > >  static int cpu_cfs_stat_show(struct seq_file *sf, void *v) >  { > +    int i; > +    u64 ws = 0; >      struct task_group *tg = css_tg(seq_css(sf)); >      struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; > > @@ -6788,6 +6790,12 @@ 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) { > +        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 */