All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Dave Jones <davej@redhat.com>,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, efault@gmx.de, len.brown@intel.com,
	mingo@elte.hu, 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: Tue, 14 Apr 2009 10:18:17 -0700	[thread overview]
Message-ID: <20090414101817.0c935261.akpm@linux-foundation.org> (raw)
In-Reply-To: <200904141821.37413.rusty@rustcorp.com.au>

On Tue, 14 Apr 2009 18:21:36 +0930 Rusty Russell <rusty@rustcorp.com.au> wrote:

> On Sun, 12 Apr 2009 10:16:44 am Andrew Morton wrote:
> > 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.
> 
> How's this?
> 
> Subject: cpumask: cpumask_closest()
> 
> Impact: new function
> 
> Andrew points out that acpi-cpufreq uses cpumask_any, when it really
> would prefer to use the same CPU if possible (to avoid an IPI).  In 
> general, this seems a good idea to offer.
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> CC: Andrew Morton <akpm@linux-foundation.org>
> 
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -931,6 +931,8 @@ static inline void cpumask_copy(struct c
>   */
>  #define cpumask_of(cpu) (get_cpu_mask(cpu))
>  
> +unsigned int cpumask_closest(const struct cpumask *mask);
> +
>  /**
>   * cpumask_scnprintf - print a cpumask into a string as comma-separated hex
>   * @buf: the buffer to sprintf into
> diff --git a/lib/cpumask.c b/lib/cpumask.c
> --- a/lib/cpumask.c
> +++ b/lib/cpumask.c
> @@ -170,3 +170,26 @@ void __init free_bootmem_cpumask_var(cpu
>  	free_bootmem((unsigned long)mask, cpumask_size());
>  }
>  #endif
> +
> +/**
> + * cpumask_closest - return the closest cpu in mask.
> + * @mask: the cpus to choose from.
> + *
> + * Returns >= nr_cpu_ids if no bits are set in @mask.
> + */
> +unsigned int cpumask_closest(const struct cpumask *mask)
> +{
> +	unsigned int cpu = raw_smp_processor_id();
> +
> +	/* Try for same CPU. */
> +	if (cpumask_test_cpu(cpu, mask))
> +		return cpu;
> +
> +	/* Try for same node. */
> +	cpu = cpumask_any_and(cpumask_of_node(cpu), mask);
> +	if (cpu <= nr_cpu_ids)
> +		return cpu;
> +
> +	/* Anything will do. */
> +	return cpumask_any(mask);
> +}

Should it be exported?

It looks all racy against hotplug.  What are the caller's
responsibilities here?

<greps a bit>

any_online_cpu() could use cpumask_closest(), against (*mask & cpu_online_map).

I think all cpumask_any() call sites can be migrated to
cpumask_closest() with, at worst, no benefit.


  reply	other threads:[~2009-04-14 17:27 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
2009-04-14  8:51     ` Rusty Russell
2009-04-14 17:18       ` Andrew Morton [this message]
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=20090414101817.0c935261.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.