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]
Message-ID: <20151208084845.GE6356@twins.programming.kicks-ass.net>
Date:	Tue, 8 Dec 2015 09:48:45 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>
Cc:	Jacob Pan <jacob.jun.pan@...ux.intel.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Linux PM <linux-pm@...r.kernel.org>,
	Rafael Wysocki <rafael.j.wysocki@...el.com>
Subject: Re: [PATCH] powercap/rapl: reduce ipi calls

On Mon, Dec 07, 2015 at 03:23:22PM -0800, Srinivas Pandruvada wrote:
> On Mon, 2015-12-07 at 15:01 -0800, Jacob Pan wrote:
> > +struct rapl_msr_action {
> > +	u32 msr;
> > +	unsigned long long value;
> > +	int shift;
> > +	u64 mask;
> > +};
> > +
> > +static void rapl_write_data_cpu(void *info)
> > +{
> > +	u64 msr_val;
> > +	struct rapl_msr_action *ra = (struct rapl_msr_action *)info;
> > +
> > +	rdmsrl_safe(ra->msr, &msr_val);
> > +	msr_val &= ~ra->mask;
> > +	msr_val |= ra->value << ra->shift;
> > +	wrmsrl_safe(ra->msr, msr_val);
> What about adding additional common interface
> wrmsrl_safe_update(), so that everyone can use this?
> 

In which case you want a return value. Also, instead of the value,shift
pair I would add another u64.

Something like:

struct msr_action {
	u32 msr;
	int ret;
	u64 mask, bits;
};

static void msr_update_function(void *info)
{
	struct msr_action *ma = info;
	int ret = 0;
	u64 val;

	ret = rdmsrl_safe(ma->msr, &val);
	if (ret)
		goto out;

	val &= ma->mask;
	val |= ma->bits;

	ret = wrmsrl_safe(ma->msr, val);

out:
	ma->ret = ret;
}

int rmwmsrl_safe_on_cpu(u32 msr, int cpu, u64 mask, u64 bits)
{
	struct msr_action ma = {
		.msr = msr,
		.mask = mask,
		.bits = bits,
	};
	int ret;

	ret = smp_call_function_single(cpu, msr_update_func, &ma, 1);
	if (!ret)
		ret = ma.ret;

	return ret;
}

--
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