All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dave Jones <davej@redhat.com>
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, efault@gmx.de, len.brown@intel.com,
	mingo@elte.hu, rusty@rustcorp.com.au, tglx@linutronix.de,
	venkatesh.pallipadi@intel.com, yakui.zhao@intel.com,
	yanmin_zhang@linux.intel.com
Subject: Re: [patch for 2.6.30 2/2] arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c: avoid cross-CPU interrupts
Date: Sat, 11 Apr 2009 17:46:44 -0700	[thread overview]
Message-ID: <20090411174644.ea6f63c6.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090412000605.GA23869@redhat.com>

On Sat, 11 Apr 2009 20:06:05 -0400 Dave Jones <davej@redhat.com> wrote:

> On Fri, Apr 10, 2009 at 11:17:18PM -0700, Andrew Morton wrote:
>  > From: Andrew Morton <akpm@linux-foundation.org>
>  > 
>  > In drv_read(), check to see whether we can run the rdmsr() on the current
>  > CPU.  If so, do that.  So smp_call_function_single() can avoid the IPI.
> 
> Wouldn't it be a better to make smp_call_function_single do this check
> itself, so all callers benefit from this optimisation?
> 
> *looks*
> 
> Wait, won't this already be caught by this code in smp_call_function_single() ?
> 
> 286         this_cpu = get_cpu();
> ...
> 291         if (cpu == this_cpu) {
> 292                 local_irq_save(flags);
> 293                 func(info);
> 294                 local_irq_restore(flags);
> 295         } else {
> 
> 
> 

The problem is that the caller (acpi-cpufreq) is doing

	cpu = cpumask_any(mask);
	smp_call_function_single(cpu);

and cpumask_any(mask) does cpumask_first(mask).  Which might be a
different CPU, even though this thread of control is running on a CPU
which is present in `mask'.

- We could fix this by making cpumask_any(mask) return this-cpu if
  this-cpu is present `mask'.

- We could fix this by changing smp_call_function_single() to take a
  mask, rather than a particular CPU.  Then of course it preferentially
  chooses this-cpu if possible.

  Or write a new smp_call_function_any(mask, ...);

I suspect that changing cpumask_any() to preferentially return this-cpu
will always give us the behaviour that we prefer, but I haven't looked
into it.



  reply	other threads:[~2009-04-12  0:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-11  6:17 [patch for 2.6.30 2/2] arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c: avoid cross-CPU interrupts akpm
2009-04-11  6:37 ` Jaswinder Singh Rajput
2009-04-12  0:06 ` Dave Jones
2009-04-12  0:46   ` Andrew Morton [this message]
2009-04-14  8:51     ` Rusty Russell
2009-04-14 17:18       ` Andrew Morton
2009-04-15  6:35         ` Rusty Russell
2009-04-20  3:22           ` Len Brown
2009-04-20  2:57 ` Len Brown
2009-04-20  3:20   ` Andrew Morton

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=20090411174644.ea6f63c6.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=efault@gmx.de \
    --cc=len.brown@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=venkatesh.pallipadi@intel.com \
    --cc=yakui.zhao@intel.com \
    --cc=yanmin_zhang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.