public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Rafael Wysocki <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH] powercap/rapl: reduce ipi calls
Date: Tue, 8 Dec 2015 09:48:45 +0100	[thread overview]
Message-ID: <20151208084845.GE6356@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1449530602.3240.130.camel@spandruv-desk3.jf.intel.com>

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


      reply	other threads:[~2015-12-08  8:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 23:01 [PATCH] powercap/rapl: reduce ipi calls Jacob Pan
2015-12-07 23:23 ` Srinivas Pandruvada
2015-12-08  8:48   ` Peter Zijlstra [this message]

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=20151208084845.GE6356@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.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