public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zhao Lei <zhaolei@cn.fujitsu.com>
To: "'Peter Zijlstra'" <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, "'Tejun Heo'" <htejun@gmail.com>,
	"'Yang Dongsheng'" <yangds.fnst@cn.fujitsu.com>
Subject: RE: [PATCH v3 3/3] cpuacct: split usage into user_usage and sys_usage
Date: Thu, 17 Mar 2016 17:42:48 +0800	[thread overview]
Message-ID: <00c601d18031$5e2c2800$1a847800$@cn.fujitsu.com> (raw)
In-Reply-To: <20160317084002.GN6344@twins.programming.kicks-ass.net>

Hi, Peter Zijlstra

> -----Original Message-----
> From: Peter Zijlstra [mailto:peterz@infradead.org]
> Sent: Thursday, March 17, 2016 4:40 PM
> To: Zhao Lei <zhaolei@cn.fujitsu.com>
> Cc: linux-kernel@vger.kernel.org; Tejun Heo <htejun@gmail.com>; Yang
> Dongsheng <yangds.fnst@cn.fujitsu.com>
> Subject: Re: [PATCH v3 3/3] cpuacct: split usage into user_usage and sys_usage
> 
> 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.
> 
I agree with you that for_each_possible_cpu() is best choice for above
code.

In corrent code,

1: cpuacct.usage_percpu only include present_cpus
  If a cpu is hotplug out, it is not exist in above file.
2: cpuacct.usage only calculate present_cpus
  If a cpu is hotplug out, this value maybe decreased.
3: cpuacct.stat only calculate online cpus
  Obviously wrong.

Above 3 is easy to fix, but better to fix above 1 and 2 together,
in one word, to make ALL statics counts possible_cpu.

The problem is file output, currently,
 # cat cpuacct.usage_percpu
 689076136 1131883300
If we turn to use possible_cpu, above line will have
256 valuse, as:
# cat cpuacct.usage_percpu
 689076136 1131883300 0 0 0 0 0 0 0 0 ...

Or we can only show present_cpu and non_present_cpu with !0 value,
and we need also need output a cpuindex, as:
# cat cpuacct.usage_percpu
  [0] 689076136
  [1] 1131883300
  [3] 11111111
  [50] 22222222
#

It will tell user more accurate information,
but both solution will change current cgroup interface.

So I suggest keeping current using of for_each_present_cpu,
and only modify for_each_online_cpu.

What is your opinion?

Thanks
Zhaolei

  reply	other threads:[~2016-03-17  9:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17  4:19 [PATCH v3 0/3] cpuacct: split usage into user_usage and sys_usage Zhao Lei
2016-03-17  4:19 ` [PATCH v3 1/3] cpuacct: rename parameter in cpuusage_write for readability Zhao Lei
2016-03-17  4:19 ` [PATCH v3 2/3] Some small restruct for cpuacct Zhao Lei
2016-03-21 11:17   ` [tip:sched/urgent] sched/cpuacct: Simplify the cpuacct code tip-bot for Zhao Lei
2016-03-17  4:19 ` [PATCH v3 3/3] cpuacct: split usage into user_usage and sys_usage Zhao Lei
2016-03-17  8:40   ` Peter Zijlstra
2016-03-17  9:42     ` Zhao Lei [this message]
2016-03-17 10:12       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00c601d18031$5e2c2800$1a847800$@cn.fujitsu.com' \
    --to=zhaolei@cn.fujitsu.com \
    --cc=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=yangds.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox