Re: [PATCH v6 2/2] perf/x86/amd/power: Add AMD accumulated power reporting mechanism

From: Huang Rui
Date: Thu Mar 03 2016 - 22:12:35 EST


On Thu, Mar 03, 2016 at 06:57:53PM +0100, Thomas Gleixner wrote:
> On Fri, 4 Mar 2016, Huang Rui wrote:
> > On Thu, Mar 03, 2016 at 04:26:46PM +0100, Thomas Gleixner wrote:
> > > Why? You do a full for_each_online_cpu(i) loop after that, which does
> > > exactly the same thing, right?
> > >
> >
> > But looks like power_cpu_init cannot handle it if we don't take any
> > action here.
> >
> > e. g.
> > cpu_mask: 0000 and online mask: 1111 -> power_cpu_init(0) -> cpu_mask is still: 0000
> >
> > topology_sibling_cpumask(0): 0011
> > target: 1 (i. e. we cannot do cpumask_set_cpu(0, &cpu_mask))
>
> Fair enough, but then you don't need the power_cpu_init() call at all.
>
> But your loop does not cover anything beyond the first socket. So you need a
> separate init function which does:
>
> for_each_online_cpu(cpu) {
> target = cpumask_first(topology_sibling_cpumask(cpu));
> if (!cpumask_test_cpu(target, cpumask))
> cpumask_set_cpu(target, cpumask);
> }
>

Looks good. Thanks Thomas. Will update it.

Rui