Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1295598 > unrolled thread
| Started by | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| First post | 2015-12-20 14:40 +0100 |
| Last post | 2015-12-20 16:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 1/2] x86/msr: add on cpu read/modify/write function Thomas Gleixner <tglx@linutronix.de> - 2015-12-20 14:40 +0100
Re: [PATCH 1/2] x86/msr: add on cpu read/modify/write function Borislav Petkov <bp@alien8.de> - 2015-12-20 16:30 +0100
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-12-20 14:40 +0100 |
| Subject | Re: [PATCH 1/2] x86/msr: add on cpu read/modify/write function |
| Message-ID | <qHMno-1aw-15@gated-at.bofh.it> |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2015-12-20 16:30 +0100 |
| Message-ID | <qHO5Q-2iv-17@gated-at.bofh.it> |
| In reply to | #1295598 |
On Sun, Dec 20, 2015 at 02:28:48PM +0100, Thomas Gleixner wrote:
> 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.
TBH, I find this new "rmwmsrl" interface (the name is unreadable, btw)
silly:
It provides a plain read-modify-write on a MSR and nothing more but
patch 2 immediately shows that this interface is insufficient for the
other cases, i.e. package_power_limit_irq_save() for example, where you
need to do something more like check bits or error handling.
So there we do smp_call_function_single() with a function which does the
MSR accesses and whatever else is needed.
So why add the former interface in the first place?
Having driver-specific functions do whatever it is required and then
using a single IPI to run them is much cleaner than adding that
unfortunate function which doesn't really suffice.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web