Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1610411

Re: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access functions

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access functions
Date 2017-03-28 10:40 +0200
Message-ID <tpUPw-4W7-5@gated-at.bofh.it> (permalink)
References <tpHSi-42B-17@gated-at.bofh.it> <tpHSi-42B-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 27 Mar 2017, kan.liang@intel.com wrote:

> From: Kan Liang <Kan.liang@intel.com>
> 
> To flip a MSR bit on many CPUs or specific CPU, currently it has to do
> read-modify-write operation on the MSR through rd/wrmsr_on_cpu(s).
> It actually sends two IPIs to the given CPU.

The IPIs are the least of the problems, really. The real problem is that

       rdmsr_on_cpu()
       wrmsr_on_cpu()

is not atomic. That's what wants to be solved. The reduction of IPIs just a
side effect.

>  #else  /*  CONFIG_SMP  */
> +static inline int msr_set_bit_on_cpu(unsigned int cpu, u32 msr, u8 bit)
> +{
> +	return msr_set_bit(msr, bit);
> +}
> +
> +static inline int msr_clear_bit_on_cpu(unsigned int cpu, u32 msr, u8 bit)
> +{
> +	return msr_clear_bit(msr, bit);
> +}
> +
> +static inline void msr_set_bit_on_cpus(const struct cpumask *mask, u32 msr, u8 bit)
> +{
> +	msr_set_bit(msr, bit);
> +}
> +
> +static inline void msr_clear_bit_on_cpus(const struct cpumask *mask, u32 msr, u8 bit)
> +{
> +	msr_clear_bit(msr, bit);
> +}

This is utter crap because it's fundamentaly different from the SMP
version.

msr_set/clear_bit() are not protected by anyhting. And in your call site
this is invoked from fully preemptible context. What protects against
context switch and interrupts fiddling with DEBUGMSR?

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V3 0/2] measure SMI cost (kernel) kan.liang@intel.com - 2017-03-27 20:50 +0200
  [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access functions kan.liang@intel.com - 2017-03-27 20:50 +0200
    Re: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access  functions Thomas Gleixner <tglx@linutronix.de> - 2017-03-28 10:40 +0200
      Re: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access  functions Thomas Gleixner <tglx@linutronix.de> - 2017-03-28 19:30 +0200
        RE: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus  access functions "Liang, Kan" <kan.liang@intel.com> - 2017-03-28 19:50 +0200
          RE: [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access  functions Thomas Gleixner <tglx@linutronix.de> - 2017-03-28 20:40 +0200

csiph-web