public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Rafael Wysocki <rafael.j.wysocki@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	X86 Kernel <x86@kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 1/2] x86/msr: add on cpu read/modify/write function
Date: Sun, 20 Dec 2015 14:28:48 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.11.1512201421300.28591@nanos> (raw)
In-Reply-To: <1449873637-24300-2-git-send-email-jacob.jun.pan@linux.intel.com>

Jacob,

On Fri, 11 Dec 2015, Jacob Pan wrote:
> +static inline int rmwmsrl_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 mask, u64 bits)
> +{
> +	int err;
> +	u64 val;
> +
> +	err = rdmsrl_safe(msr_no, &val);
> +	if (err)
> +		goto out;
> +
> +	val &= ~mask;
> +	val |= bits;
> +
> +	err = wrmsrl_safe(msr_no, val);
> +out:
> +	return err;
> +}

....

> +static void __rmwmsrl_safe(void *info)
> +{
> +	int err;
> +	struct msr_action *ma = info;
> +	u64 val;
> +
> +	err = rdmsrl_safe(ma->msr_no, &val);
> +	if (err)
> +		goto out;
> +
> +	val &= ~ma->mask;
> +	val |= ma->bits;
> +
> +	err = wrmsrl_safe(ma->msr_no, val);
> +
> +out:
> +	ma->err = err;

So this is a copy of the above !SMP inline. What's wrong with providing:

 int rmwmsrl_safe(msr_no, clear_mask, set_mask)

in x86/lib/msr.c and make the !SMP variant of rdmsrl_safe_on_cpu() and that
variant for the SMP case a simple wrapper around it?

static void remote_rmwmsrl_safe(void *info)
{
	struct msr_action *ma = info;

	return rmwmsrl_safe(ma->msr, ma->clear_mask, ma->set_mask);
}

No gotos, no pointless code duplication. Just simple.

Thanks,

	tglx

  reply	other threads:[~2015-12-20 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 22:40 [PATCH 0/2] combine remote cpu msr access Jacob Pan
2015-12-11 22:40 ` [PATCH 1/2] x86/msr: add on cpu read/modify/write function Jacob Pan
2015-12-20 13:28   ` Thomas Gleixner [this message]
2015-12-20 15:27     ` Borislav Petkov
2016-01-13  1:14     ` Jacob Pan
2015-12-11 22:40 ` [PATCH 2/2] powercap/rapl: reduce ipi calls Jacob Pan

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=alpine.DEB.2.11.1512201421300.28591@nanos \
    --to=tglx@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=x86@kernel.org \
    /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