From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbdH2P7d (ORCPT ); Tue, 29 Aug 2017 11:59:33 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:47992 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751867AbdH2P7c (ORCPT ); Tue, 29 Aug 2017 11:59:32 -0400 Date: Tue, 29 Aug 2017 17:59:13 +0200 From: Peter Zijlstra To: Tejun Heo Cc: lizefan@huawei.com, hannes@cmpxchg.org, mingo@redhat.com, longman@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 Subject: Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting Message-ID: <20170829155913.4u2giegzujqidkog@hirez.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170829152426.GL491396@devbig577.frc2.facebook.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 29, 2017 at 08:24:27AM -0700, 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. Hmm, and when its never read, we only do the O(depth) thing _once_, right?