From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753395AbdH2Pck (ORCPT ); Tue, 29 Aug 2017 11:32:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751297AbdH2Pci (ORCPT ); Tue, 29 Aug 2017 11:32:38 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1B4AE806A3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=longman@redhat.com Subject: Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting To: Tejun Heo , Peter Zijlstra Cc: lizefan@huawei.com, hannes@cmpxchg.org, mingo@redhat.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, efault@gmx.de, torvalds@linux-foundation.org, guro@fb.com References: <20170811163754.3939102-1-tj@kernel.org> <20170811163754.3939102-4-tj@kernel.org> <20170829143252.6zoes63bwfflukjy@hirez.programming.kicks-ass.net> <20170829152426.GL491396@devbig577.frc2.facebook.com> From: Waiman Long Organization: Red Hat Message-ID: <02e84780-1ad7-95e3-345e-baec3dc6db84@redhat.com> Date: Tue, 29 Aug 2017 11:32:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170829152426.GL491396@devbig577.frc2.facebook.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Aug 2017 15:32:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/29/2017 11:24 AM, Tejun Heo wrote: > Hello, Peter. > > On Tue, Aug 29, 2017 at 04:32:52PM +0200, Peter Zijlstra wrote: >> So I mostly like. On accounting it only adds to the immediate cgroup (if >> it has a parent, aka !root). >> >> On update it does a DFS of all sub-groups and propagates the deltas up >> to the requested group. > ... >> What I don't get is why you need cgroup_cpu_stat_updated(). That is, I >> see you use it to keep the keep the DFS 'stack' up-to-date, but what I >> don't see is why you'd need that. > That is to make reading stats O(number of descendants which have been > active since last read) instad of O(number of all descendants) as > there can be a lot of not-too-active cgroups in a system. Stat > reading can be frequent, so the combination can get really bad. By > keeping the updated list separate, increasing read frequency decreases > the cost of each read. > > Also, please note that a system may end up with a lot of cgroups > without the user intending to. memcg drains removed cgroups lazily > and the number of draining cgroups can reach very high numbers if the > system isn't under memory pressure. The plan is to add basic stats > for other resources too and keeping it scalable w.r.t. idle cgroups > allows using the same mechanism for all resources. I think it will be good to put the rationale behind this function as a comment in the code. Cheers, Longman