Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp631722imm; Mon, 2 Jul 2018 19:12:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvRP1TGGT5ErupooJ3dbvV+2jwa3zzlJPaj2h1D2EHPrdPEx3gMfwdfqseXg765ivRcT+q X-Received: by 2002:a65:5b8e:: with SMTP id i14-v6mr19732533pgr.242.1530583964811; Mon, 02 Jul 2018 19:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530583964; cv=none; d=google.com; s=arc-20160816; b=Tq8cy7VeHS5MBgvc1FPfw2txBUsDwCJtNfQjYYFoPqjZVwdqGmk2Hn5uAx8U9AplJk lUA7gj+wxlzPSj9i//rwhtI87ualNWl7iOttLU+Xdnfjy2ygIY1w1tbQ0h0t2geUKgW3 WmtVsHOaOeauYWOWdhNWVeCt6cVLpHg2FHgDfbxTixDfoM7Puk1Nh56QzuNPkTBg1D2w y8as5CQyGCq4ypE3So9ViA75Uuwbht/+Z7EyRPYGjF+HSF9L1fVFDRP9PYGaRwpaxq2I c+uvQ9HKgVtHYK5L8h5h4WF4rXtIUTpvdCfqIN1g99VI4XXomGHq3F4S+TqZi2SmJK4+ 9U7g== 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:from:references:cc:to:subject:arc-authentication-results; bh=in6y56BrkEnoHyFH9sTcB0d6CFjc/RsIEjrflrYdJUA=; b=Z0qpfcNsGwetfYJoz0cxeI61opHGvwAYI3XoZ0YyzmcVkkSW9YfPAuD+bGEQ9JIbYw EOGxhFurZWY1nfdpAW2wXg/cwV8a7TSmns3AsQogWLZfxtYlOIxNb+OqyjIXu+LTmiZ8 QxLAblqwt9HRRTyprViZTfd2w/oXIBdZiMXfruOHVamrvk90sY+LHbR5Erm9s6V9AHQI XCdS38ulaQTU6tx9XgheOoiu9iWTs8WrdBnqZrX7FYrsH9fj2avIc/M/kw8yQSLJUfai 83v6mGVvBkc/yQd7oPuKxGBs3HUmOWSYvV0HMtPQHYpOXs0qgAXVDj2FbVOiNHdMdbV6 mZ7A== 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 u9-v6si6200pfg.62.2018.07.02.19.12.30; Mon, 02 Jul 2018 19:12:44 -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 S932339AbeGCCKY (ORCPT + 99 others); Mon, 2 Jul 2018 22:10:24 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:60971 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932216AbeGCCKX (ORCPT ); Mon, 2 Jul 2018 22:10:23 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R351e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0T3scaTw_1530583805; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0T3scaTw_1530583805) by smtp.aliyun-inc.com(127.0.0.1); Tue, 03 Jul 2018 10:10:05 +0800 Subject: Re: [RFC PATCH] tg: count the sum wait time of an task group To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org References: <5c4c978d-e8fb-4bcb-b942-3c6d3dcfc13e@linux.alibaba.com> <20180702120356.GJ2494@hirez.programming.kicks-ass.net> From: =?UTF-8?B?546L6LSH?= Message-ID: <21628e16-5d34-d7f6-8c10-ff354b4e7b35@linux.alibaba.com> Date: Tue, 3 Jul 2018 10:10:05 +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: <20180702120356.GJ2494@hirez.programming.kicks-ass.net> 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 Hi, Peter On 2018/7/2 δΈ‹εˆ8:03, Peter Zijlstra wrote: > On Mon, Jul 02, 2018 at 03:29:39PM +0800, ηŽ‹θ΄‡ wrote: >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 1866e64..ef82ceb 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -862,6 +862,7 @@ static void update_curr_fair(struct rq *rq) >> static inline void >> update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) >> { >> + struct task_group *tg; >> struct task_struct *p; >> u64 delta; >> >> @@ -882,6 +883,9 @@ static void update_curr_fair(struct rq *rq) >> return; >> } >> trace_sched_stat_wait(p, delta); >> + } else { >> + tg = group_cfs_rq(se)->tg; >> + __schedstat_add(tg->wait_sum, delta); >> } > > You're joking right? This patch is both broken and utterly insane. > > You're wanting to update an effectively global variable for every > schedule action (and its broken because it is without any serialization > or atomics). Thanks for the reply and sorry for the thoughtless, I'll rewrite the code to make it per-cpu variable, then assemble the results on show. Regards, Michael Wang > > NAK >