From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932861AbcCQIkI (ORCPT ); Thu, 17 Mar 2016 04:40:08 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:32806 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932488AbcCQIkG (ORCPT ); Thu, 17 Mar 2016 04:40:06 -0400 Date: Thu, 17 Mar 2016 09:40:02 +0100 From: Peter Zijlstra To: Zhao Lei Cc: linux-kernel@vger.kernel.org, Tejun Heo , Yang Dongsheng Subject: Re: [PATCH v3 3/3] cpuacct: split usage into user_usage and sys_usage Message-ID: <20160317084002.GN6344@twins.programming.kicks-ass.net> References: <5a23ec991c5abf9b62df76be5b081a5fa895f35b.1458187654.git.zhaolei@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5a23ec991c5abf9b62df76be5b081a5fa895f35b.1458187654.git.zhaolei@cn.fujitsu.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2016 at 12:19:44PM +0800, Zhao Lei wrote: > +static u64 __cpuusage_read(struct cgroup_subsys_state *css, > + enum cpuacct_usage_index index) > { > struct cpuacct *ca = css_ca(css); > u64 totalcpuusage = 0; > int i; > > for_each_present_cpu(i) > + totalcpuusage += cpuacct_cpuusage_read(ca, i, index); > > return totalcpuusage; > } Ok, so while looking over this, it mostly uses for_each_present_cpu(), which is already dubious, but then cpuacct_stats_show() uses for_each_online_cpu(). Why is this? Why not always for_each_possible_cpu()? Surely, if you offline a cpu, you still want its stat to be included in your totals, otherwise your numbers will go backwards when you take a cpu offline. Could you double check the logic and maybe fix? Thanks!