lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 26 Jan 2016 21:47:09 +0800
From:	Huang Rui <ray.huang@....com>
To:	Ingo Molnar <mingo@...nel.org>
CC:	Borislav Petkov <bp@...e.de>,
	Peter Zijlstra <peterz@...radead.org>,
	"Andy Lutomirski" <luto@...capital.net>,
	Thomas Gleixner <tglx@...utronix.de>,
	Robert Richter <rric@...nel.org>,
	Jacob Shin <jacob.w.shin@...il.com>,
	"John Stultz" <john.stultz@...aro.org>,
	Fr�d�ric Weisbecker <fweisbec@...il.com>,
	<linux-kernel@...r.kernel.org>, <spg_linux_kernel@....com>,
	<x86@...nel.org>, Guenter Roeck <linux@...ck-us.net>,
	Andreas Herrmann <herrmann.der.user@...glemail.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@....com>,
	Aravind Gopalakrishnan <Aravind.Gopalakrishnan@....com>,
	Borislav Petkov <bp@...en8.de>,
	"Fengguang Wu" <fengguang.wu@...el.com>,
	Aaron Lu <aaron.lu@...el.com>
Subject: Re: [PATCH v3] perf/x86/amd/power: Add AMD accumulated power
 reporting mechanism

On Tue, Jan 26, 2016 at 09:28:23AM +0100, Ingo Molnar wrote:
> 
> * Huang Rui <ray.huang@....com> wrote:
> 
> > +/*
> > + * Acc power status counters
> > + */
> > +#define AMD_POWER_PKG_ID		0
> > +#define AMD_POWER_EVENTSEL_PKG		1
> 
> > +/*
> > + * the ratio of compute unit power accumulator sample period to the
> > + * PTSC period
> > + */
> 
> > +/*
> > + * Accumulated power is to measure the sum of each compute unit's
> > + * power consumption. So it picks only one core from each compute unit
> > + * to get the power with MSR_F15H_CU_PWR_ACCUMULATOR. The cpu_mask
> > + * represents CPU bit map of all cores which are picked to measure the
> > + * power for the compute units that they belong to.
> > + */
> > +static cpumask_t cpu_mask;
> 
> > +	/*
> > +	 * calculate the power comsumption for each compute unit over
> > +	 * a time period, the unit of final value (delta) is
> > +	 * micro-Watts. Then add it into event count.
> > +	 */
> 
> Please capitalize sentences consistently - half of the comments you added start 
> lower-case.
> 

Some of lower-case starting cases are not complete sentences such as:

/*
 * the ratio of compute unit power accumulator sample period to the
 * PTSC period
 */

/* maximum accumulated power of a compute unit */

So can I check again and capitalize comment if it is complete
sentence?

> 
> > +	if (cfg == AMD_POWER_EVENTSEL_PKG)
> > +		bit = AMD_POWER_PKG_ID;
> > +	else
> > +		return -EINVAL;
> > +
> > +	event->hw.event_base = MSR_F15H_CU_PWR_ACCUMULATOR;
> > +	event->hw.config = cfg;
> > +	event->hw.idx = bit;
> > +
> > +	return ret;
> 
> so this control flow looks pretty weird. Why not:
> 
> > +	if (cfg != AMD_POWER_EVENTSEL_PKG)
> > +		return -EINVAL;
> > +
> > +	event->hw.event_base = MSR_F15H_CU_PWR_ACCUMULATOR;
> > +	event->hw.config = cfg;
> > +	event->hw.idx = AMD_POWER_PKG_ID;
> > +
> > +	return ret;
> 
> ?
> 

Looks better.

> > +static int power_cpu_init(int cpu)
> > +{
> > +	struct power_pmu *pmu = per_cpu(amd_power_pmu, cpu);
> > +
> > +	if (pmu)
> > +		return 0;
> > +
> > +	if (!cpumask_and(pmu->mask, topology_sibling_cpumask(cpu),
> > +			 &cpu_mask))
> > +		cpumask_set_cpu(cpu, &cpu_mask);
> > +
> > +	return 0;
> > +}
> 
> Hm, has this function ever been runtime tested? This function either does nothing 
> (contrary to the clear intention of twiddling the cpu_mask), or crashes on a NULL 
> pointer.
> 
> ( Also, the code has an annoying line-break. Don't pacify checkpatch by making the 
>   code harder to read. )
> 

OK, that should be "if (!pmu)", thanks to check so carefully. I tested
to make the core offline and check the event context migration with
power_cpu_exit, but might miss this scenario. I will do more testing
on runtime case. Will fix it on next version.

Thanks,
Rui

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ