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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150831145924.GL18673@twins.programming.kicks-ass.net>
Date:	Mon, 31 Aug 2015 16:59:24 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Huang Rui <ray.huang@....com>
Cc:	Borislav Petkov <bp@...e.de>, Jean Delvare <jdelvare@...e.de>,
	Guenter Roeck <linux@...ck-us.net>,
	Andy Lutomirski <luto@...capital.net>,
	Andreas Herrmann <herrmann.der.user@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...nel.org>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	Len Brown <lenb@...nel.org>,
	John Stultz <john.stultz@...aro.org>,
	Frédéric Weisbecker <fweisbec@...il.com>,
	lm-sensors@...sensors.org, linux-kernel@...r.kernel.org,
	x86@...nel.org,
	Andreas Herrmann <herrmann.der.user@...glemail.com>,
	Aravind Gopalakrishnan <Aravind.Gopalakrishnan@....com>,
	Borislav Petkov <bp@...en8.de>,
	Fengguang Wu <fengguang.wu@...el.com>,
	Aaron Lu <aaron.lu@...el.com>, Tony Li <tony.li@....com>
Subject: Re: [PATCH 12/15] hwmon, fam15h_power: introduce a cpu accumulated
 power reporting algorithm

On Mon, Aug 31, 2015 at 03:25:35PM +0200, Peter Zijlstra wrote:
> On Thu, Aug 27, 2015 at 04:07:43PM +0800, Huang Rui wrote:
> > +static ssize_t show_power_acc(struct device *dev,
> > +			      struct device_attribute *attr, char *buf)
> > +{
> > +	int cpu, cu, cu_num, cores_per_cu;
> > +	u64 curr_cu_acc_power[MAX_CUS],
> > +	    curr_ptsc[MAX_CUS], jdelta[MAX_CUS];
> > +	u64 tdelta, avg_acc;
> > +	struct fam15h_power_data *data = dev_get_drvdata(dev);
> > +
> > +	cores_per_cu = amd_get_cores_per_cu();
> > +	cu_num = boot_cpu_data.x86_max_cores / cores_per_cu;
> > +
> > +	for (cpu = 0, avg_acc = 0; cpu < cu_num * cores_per_cu; cpu += cores_per_cu) {
> > +		cu = cpu / cores_per_cu;
> > +		if (rdmsrl_safe_on_cpu(cpu, MSR_F15H_PTSC, &curr_ptsc[cu])) {
> > +			pr_err("Failed to read PTSC counter MSR on core%d\n",
> > +			       cpu);
> > +			return 0;
> > +		}
> > +
> > +		if (rdmsrl_safe_on_cpu(cpu, MSR_F15H_CU_PWR_ACCUMULATOR,
> > +				       &curr_cu_acc_power[cu])) {
> > +			pr_err("Failed to read compute unit power accumulator MSR on core%d\n",
> > +			       cpu);
> > +			return 0;
> > +		}
> > +
> > +		if (curr_cu_acc_power[cu] < data->cu_acc_power[cu]) {
> > +			jdelta[cu] = data->max_cu_acc_power + curr_cu_acc_power[cu];
> > +			jdelta[cu] -= data->cu_acc_power[cu];
> > +		} else {
> > +			jdelta[cu] = curr_cu_acc_power[cu] - data->cu_acc_power[cu];
> > +		}
> > +		tdelta = curr_ptsc[cu] - data->cpu_sw_pwr_ptsc[cu];
> > +		jdelta[cu] *= data->cpu_pwr_sample_ratio * 1000;
> > +		do_div(jdelta[cu], tdelta);
> > +
> > +		mutex_lock(&data->acc_pwr_mutex);
> > +		data->cu_acc_power[cu] = curr_cu_acc_power[cu];
> > +		data->cpu_sw_pwr_ptsc[cu] = curr_ptsc[cu];
> > +		mutex_unlock(&data->acc_pwr_mutex);
> > +
> > +		/* the unit is microWatt */
> > +		avg_acc += jdelta[cu];
> > +	}
> > +
> > +	return sprintf(buf, "%u\n", (unsigned int) avg_acc);
> > +}
> > +static DEVICE_ATTR(power1_acc, S_IRUGO, show_power_acc, NULL);
> 
> This is a world readable file that sprays IPIs across the entire system,
> how is that a good idea?

FWIW this driver is also hotplug challenged. Not to mention it relies on
cpu number layout in unhealthy ways.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ