linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/8] Reduce cross CPU IPI interference
@ 2012-01-08 16:26 Gilad Ben-Yossef
  2012-01-08 16:32 ` Gilad Ben-Yossef
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Gilad Ben-Yossef @ 2012-01-08 16:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Gilad Ben-Yossef, Christoph Lameter, Chris Metcalf,
	Peter Zijlstra, Frederic Weisbecker, linux-mm, Pekka Enberg,
	Matt Mackall, Sasha Levin, Rik van Riel, Andi Kleen, Mel Gorman,
	Andrew Morton, Alexander Viro, Avi Kivity, Michal Nazarewicz,
	Kosaki Motohiro

We have lots of infrastructure in place to partition a multi-core systems
such that we have a group of CPUs that are dedicated to specific task:
cgroups, scheduler and interrupt affinity and cpuisol boot parameter.
Still, kernel code will some time interrupt all CPUs in the system via IPIs
for various needs. These IPIs are useful and cannot be avoided altogether,
but in certain cases it is possible to interrupt only specific CPUs that
have useful work to do and not the entire system.

This patch set, inspired by discussions with Peter Zijlstra and Frederic
Weisbecker when testing the nohz task patch set, is a first stab at trying
to explore doing this by locating the places where such global IPI calls
are being made and turning a global IPI into an IPI for a specific group
of CPUs.  The purpose of the patch set is to get feedback if this is the
right way to go for dealing with this issue and indeed, if the issue is
even worth dealing with at all. Based on the feedback from this patch set
I plan to offer further patches that address similar issue in other code
paths.

The patch creates an on_each_cpu_mask and on_each_cpu_conf infrastructure 
API (the former derived from existing arch specific versions in Tile and 
Arm) and and uses them to turn several global IPI invocation to per CPU 
group invocations.

This 6th iteration includes the following changes:

- In case of cpumask allocation failure, have on_each_cpu_cond
  send an IPI to each needed CPU seperately via 
  smp_call_function_single so no cpumask var is needed, as 
  suggested by Andrew Morton.
- Document why on_each_cpu_mask need to check the mask even on
  UP in a code comment, as suggested by Andrew Morton.
- Various typo cleanup in patch descriptions

The patch set also available from the ipi_noise_v6 branch at
git://github.com/gby/linux.git

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: Christoph Lameter <cl@linux.com>
CC: Chris Metcalf <cmetcalf@tilera.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: linux-mm@kvack.org
CC: Pekka Enberg <penberg@kernel.org>
CC: Matt Mackall <mpm@selenic.com>
CC: Sasha Levin <levinsasha928@gmail.com>
CC: Rik van Riel <riel@redhat.com>
CC: Andi Kleen <andi@firstfloor.org>
CC: Mel Gorman <mel@csn.ul.ie>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
CC: Avi Kivity <avi@redhat.com>
CC: Michal Nazarewicz <mina86@mina86.org>
CC: Kosaki Motohiro <kosaki.motohiro@gmail.com>

Gilad Ben-Yossef (8):
  smp: Introduce a generic on_each_cpu_mask function
  arm: move arm over to generic on_each_cpu_mask
  tile: move tile to use generic on_each_cpu_mask
  smp: add func to IPI cpus based on parameter func
  slub: only IPI CPUs that have per cpu obj to flush
  fs: only send IPI to invalidate LRU BH when needed
  mm: only IPI CPUs to drain local pages if they exist
  mm: add vmstat counters for tracking PCP drains

 arch/arm/kernel/smp_tlb.c     |   20 +++----------
 arch/tile/include/asm/smp.h   |    7 -----
 arch/tile/kernel/smp.c        |   19 -------------
 fs/buffer.c                   |   15 ++++++++++-
 include/linux/smp.h           |   38 ++++++++++++++++++++++++++
 include/linux/vm_event_item.h |    1 +
 kernel/smp.c                  |   58 +++++++++++++++++++++++++++++++++++++++++
 mm/page_alloc.c               |   31 +++++++++++++++++++++-
 mm/slub.c                     |   10 ++++++-
 mm/vmstat.c                   |    2 +
 10 files changed, 157 insertions(+), 44 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v6 0/8] Reduce cross CPU IPI interference
  2012-01-08 16:26 [PATCH v6 0/8] Reduce cross CPU IPI interference Gilad Ben-Yossef
@ 2012-01-08 16:32 ` Gilad Ben-Yossef
  2012-01-09  9:30 ` Peter Zijlstra
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Gilad Ben-Yossef @ 2012-01-08 16:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Gilad Ben-Yossef, Christoph Lameter, Chris Metcalf,
	Peter Zijlstra, Frederic Weisbecker, linux-mm, Pekka Enberg,
	Matt Mackall, Sasha Levin, Rik van Riel, Andi Kleen, Mel Gorman,
	Andrew Morton, Alexander Viro, Avi Kivity, Michal Nazarewicz,
	Kosaki Motohiro

<SNIP>
> CC: Michal Nazarewicz <mina86@mina86.org>
> CC: Kosaki Motohiro <kosaki.motohiro@gmail.com>
>

Damn... I've messed up Michael email address. Sorry about that.
Resending the right address now :-(

Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker
gilad@benyossef.com
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"Unfortunately, cache misses are an equal opportunity pain provider."
-- Mike Galbraith, LKML

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v6 0/8] Reduce cross CPU IPI interference
  2012-01-08 16:26 [PATCH v6 0/8] Reduce cross CPU IPI interference Gilad Ben-Yossef
  2012-01-08 16:32 ` Gilad Ben-Yossef
@ 2012-01-09  9:30 ` Peter Zijlstra
  2012-01-09 17:57 ` Chris Metcalf
  2012-01-11  7:04 ` Milton Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2012-01-09  9:30 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: linux-kernel, Christoph Lameter, Chris Metcalf,
	Frederic Weisbecker, linux-mm, Pekka Enberg, Matt Mackall,
	Sasha Levin, Rik van Riel, Andi Kleen, Mel Gorman, Andrew Morton,
	Alexander Viro, Avi Kivity, Michal Nazarewicz, Kosaki Motohiro

On Sun, 2012-01-08 at 18:26 +0200, Gilad Ben-Yossef wrote:
> Still, kernel code will some time interrupt all CPUs in the system via IPIs
> for various needs. These IPIs are useful and cannot be avoided altogether,
> but in certain cases it is possible to interrupt only specific CPUs that
> have useful work to do and not the entire system. 

1-7

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v6 0/8] Reduce cross CPU IPI interference
  2012-01-08 16:26 [PATCH v6 0/8] Reduce cross CPU IPI interference Gilad Ben-Yossef
  2012-01-08 16:32 ` Gilad Ben-Yossef
  2012-01-09  9:30 ` Peter Zijlstra
@ 2012-01-09 17:57 ` Chris Metcalf
  2012-01-11  7:04 ` Milton Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Chris Metcalf @ 2012-01-09 17:57 UTC (permalink / raw)
  To: Gilad Ben-Yossef
  Cc: linux-kernel, Christoph Lameter, Peter Zijlstra,
	Frederic Weisbecker, linux-mm, Pekka Enberg, Matt Mackall,
	Sasha Levin, Rik van Riel, Andi Kleen, Mel Gorman, Andrew Morton,
	Alexander Viro, Avi Kivity, Michal Nazarewicz, Kosaki Motohiro

On 1/8/2012 11:26 AM, Gilad Ben-Yossef wrote:
> We have lots of infrastructure in place to partition a multi-core systems
> such that we have a group of CPUs that are dedicated to specific task:
> cgroups, scheduler and interrupt affinity and cpuisol boot parameter.
> Still, kernel code will some time interrupt all CPUs in the system via IPIs
> for various needs. These IPIs are useful and cannot be avoided altogether,
> but in certain cases it is possible to interrupt only specific CPUs that
> have useful work to do and not the entire system.
>
> This patch set, inspired by discussions with Peter Zijlstra and Frederic
> Weisbecker when testing the nohz task patch set, is a first stab at trying
> to explore doing this by locating the places where such global IPI calls
> are being made and turning a global IPI into an IPI for a specific group
> of CPUs.  The purpose of the patch set is to get feedback if this is the
> right way to go for dealing with this issue and indeed, if the issue is
> even worth dealing with at all. Based on the feedback from this patch set
> I plan to offer further patches that address similar issue in other code
> paths.
>
> The patch creates an on_each_cpu_mask and on_each_cpu_conf infrastructure 
> API (the former derived from existing arch specific versions in Tile and 
> Arm) and and uses them to turn several global IPI invocation to per CPU 
> group invocations.

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

(To be fair, mostly this acks the proposed infrastructure, and moving the
functions out of the tile architecture and into the generic code; I not
expert enough at slub or the invalidate_bh_lrus path to ack those changes,
other than to say I like how they look.)

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v6 0/8] Reduce cross CPU IPI interference
  2012-01-08 16:26 [PATCH v6 0/8] Reduce cross CPU IPI interference Gilad Ben-Yossef
                   ` (2 preceding siblings ...)
  2012-01-09 17:57 ` Chris Metcalf
@ 2012-01-11  7:04 ` Milton Miller
  2012-01-11  8:28   ` Gilad Ben-Yossef
  3 siblings, 1 reply; 6+ messages in thread
From: Milton Miller @ 2012-01-11  7:04 UTC (permalink / raw)
  To: Gilad Ben-Yossef, linux-kernel
  Cc: Christoph Lameter, Chris Metcalf, Peter Zijlstra,
	Frederic Weisbecker, Russell King, linux-mm, Pekka Enberg,
	Matt Mackall, Rik van Riel, Andi Kleen, Sasha Levin, Mel Gorman,
	Andrew Morton, Alexander Viro, linux-fsdevel, Avi Kivity,
	Michal Nazarewicz, Kosaki Motohiro

Hi Gilad.   A few minor corrections for several of the patch logs, but some
meater discussions on several of the patches.

Overall I like the series and hope you see it through.

On Sun Jan 08 2012 about 11:27:52 EST, Gilad Ben-Yossef wrote:

> 
> We have lots of infrastructure in place to partition a multi-core systems

partition multi-core systems

> such that we have a group of CPUs that are dedicated to specific task:
> cgroups, scheduler and interrupt affinity and cpuisol boot parameter.

interrupt affinity, and isolcpus= boot parameter

> Still, kernel code will some time interrupt all CPUs in the system via IPIs

will at times

> for various needs. These IPIs are useful and cannot be avoided altogether,
> but in certain cases it is possible to interrupt only specific CPUs that
> have useful work to do and not the entire system.
> 
> This patch set, inspired by discussions with Peter Zijlstra and Frederic
> Weisbecker when testing the nohz task patch set, is a first stab at trying
> to explore doing this by locating the places where such global IPI calls
> are being made and turning a global IPI into an IPI for a specific group

turning the global IPI

> of CPUs. The purpose of the patch set is to get feedback if this is the
> right way to go for dealing with this issue and indeed, if the issue is
> even worth dealing with at all. Based on the feedback from this patch set
> I plan to offer further patches that address similar issue in other code
> paths.
> 
> The patch creates an on_each_cpu_mask and on_each_cpu_conf infrastructure

on_each_cpu_cond

> API (the former derived from existing arch specific versions in Tile and
> Arm) and and uses them to turn several global IPI invocation to per CPU
> group invocations.
> 
> This 6th iteration includes the following changes:
> 
> - In case of cpumask allocation failure, have on_each_cpu_cond
>   send an IPI to each needed CPU seperately via
>   smp_call_function_single so no cpumask var is needed, as
>   suggested by Andrew Morton.
> - Document why on_each_cpu_mask need to check the mask even on
>   UP in a code comment, as suggested by Andrew Morton.
> - Various typo cleanup in patch descriptions
> 

milton
MAIL FROM: <miltonm@bga.com>
RCPT TO: <miltonm@bga.com>
RCPT TO: <gilad@benyossef.com>
RCPT TO: <linux-kernel@vger.kernel.org>
RCPT TO: <cl@linux.com>
RCPT TO: <cmetcalf@tilera.com>
RCPT TO: <a.p.zijlstra@chello.nl>
RCPT TO: <fweisbec@gmail.com>
RCPT TO: <linux@arm.linux.org.uk>
RCPT TO: <linux-mm@kvack.org>
RCPT TO: <penberg@kernel.org>
RCPT TO: <mpm@selenic.com>
RCPT TO: <riel@redhat.com>
RCPT TO: <andi@firstfloor.org>
RCPT TO: <levinsasha928@gmail.com>
RCPT TO: <mel@csn.ul.ie>
RCPT TO: <akpm@linux-foundation.org>
RCPT TO: <viro@zeniv.linux.org.uk>
RCPT TO: <linux-fsdevel@vger.kernel.org>
RCPT TO: <avi@redhat.com>
RCPT TO: <mina86@mina86.org>
RCPT TO: <kosaki.motohiro@gmail.com>
DATA
From: Milton Miller <miltonm@bga.com>
Bcc: Milton Miller <miltonm@bga.com>
Subject: Re: [PATCH v6 1/8] smp: Introduce a generic on_each_cpu_mask function
In-Reply-To: <1326040026-7285-2-git-send-email-gilad@benyossef.com>
References: <1326040026-7285-2-git-send-email-gilad@benyossef.com>
To: Gilad Ben-Yossef <gilad@benyossef.com>,
	<linux-kernel@vger.kernel.org>
Cc:    Christoph Lameter <cl@linux.com>,
    Chris Metcalf <cmetcalf@tilera.com>,
    Peter Zijlstra <a.p.zijlstra@chello.nl>,
    Frederic Weisbecker <fweisbec@gmail.com>,
    Russell King <linux@arm.linux.org.uk>,
    <linux-mm@kvack.org>,
    Pekka Enberg <penberg@kernel.org>,
    Matt Mackall <mpm@selenic.com>,
    Rik van Riel <riel@redhat.com>,
    Andi Kleen <andi@firstfloor.org>,
    Sasha Levin <levinsasha928@gmail.com>,
    Mel Gorman <mel@csn.ul.ie>,
    Andrew Morton <akpm@linux-foundation.org>,
    Alexander Viro <viro@zeniv.linux.org.uk>,
    <linux-fsdevel@vger.kernel.org>,
    Avi Kivity <avi@redhat.com>,
    Michal Nazarewicz <mina86@mina86.org>,
    Kosaki Motohiro <kosaki.motohiro@gmail.com>


On Sun, 8 Jan 2012 about 18:26:59 +0200, Gilad Ben-Yossef wrote:
>
> on_each_cpu_mask calls a function on processors specified by
> cpumask, which may or may not include the local processor.
> 
> All the limitation specified in smp_call_function_many apply.

limitations

Except they don't, see below

> 
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> Reviewed-by: Christoph Lameter <cl@linux.com>
..
> ---
>  include/linux/smp.h |   22 ++++++++++++++++++++++
>  kernel/smp.c        |   20 ++++++++++++++++++++
>  2 files changed, 42 insertions(+), 0 deletions(-)
> diff --git a/include/linux/smp.h b/include/linux/smp.h
> index 8cc38d3..a3a14d9 100644
> --- a/include/linux/smp.h
> +++ b/include/linux/smp.h
> @@ -102,6 +102,13 @@ static inline void call_function_init(void) { }
>  int on_each_cpu(smp_call_func_t func, void *info, int wait);
>  
>  /*
> + * Call a function on processors specified by mask, which might include
> + * the local one.
> + */
> +void on_each_cpu_mask(const struct cpumask *mask, void (*func)(void *),
> +		void *info, bool wait);
> +

func should be smp_call_func_t

> +/*
>   * Mark the boot cpu "online" so that it can call console drivers in
>   * printk() and can access its per-cpu storage.
>   */
> @@ -132,6 +139,21 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info)
>  		local_irq_enable();		\
>  		0;				\
>  	})
> +/*
> + * Note we still need to test the mask even for UP
> + * because we actually can get an empty mask from
> + * code that on SMP might call us without the local
> + * CPU in the mask.
> + */
> +#define on_each_cpu_mask(mask, func, info, wait) \
> +	do {						\
> +		if (cpumask_test_cpu(0, (mask))) {	\
> +			local_irq_disable();		\
> +			(func)(info);			\
> +			local_irq_enable();		\
> +		}					\
> +	} while (0)
> +
>  static inline void smp_send_reschedule(int cpu) { }
>  #define num_booting_cpus()			1
>  #define smp_prepare_boot_cpu()			do {} while (0)
> diff --git a/kernel/smp.c b/kernel/smp.c
> index db197d6..7c0cbd7 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -701,3 +701,23 @@ int on_each_cpu(void (*func) (void *info), void *info, int wait)
>  	return ret;
>  }
>  EXPORT_SYMBOL(on_each_cpu);
> +
> +/*
> + * Call a function on processors specified by cpumask, which may include
> + * the local processor. All the limitation specified in smp_call_function_many
> + * apply.
> + */

Please turn this comment into kerneldoc like the smp_call_function* family.

Also, this is not accurate, as smp_call_function_many requires
preemption to have been disabled while on_each_cpu_mask disables
preemption (via get_cpu).

> +void on_each_cpu_mask(const struct cpumask *mask, void (*func)(void *),
> +			void *info, bool wait)
> +{
> +	int cpu = get_cpu();
> +
> +	smp_call_function_many(mask, func, info, wait);
> +	if (cpumask_test_cpu(cpu, mask)) {
> +		local_irq_disable();
> +		func(info);
> +		local_irq_enable();
> +	}
> +	put_cpu();
> +}
> +EXPORT_SYMBOL(on_each_cpu_mask);

It should be less code if we rewrite on_each_cpu as the one liner
on_each_cpu_mask(cpu_online_mask).  I think the trade off of less
code is worth the cost of the added test of cpu being in online_mask.

That could be a seperate patch, but will be easier to read the result
if on_each_cpu_mask is placed above on_each_cpu in this one.

milton

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v6 0/8] Reduce cross CPU IPI interference
  2012-01-11  7:04 ` Milton Miller
@ 2012-01-11  8:28   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 6+ messages in thread
From: Gilad Ben-Yossef @ 2012-01-11  8:28 UTC (permalink / raw)
  To: Milton Miller
  Cc: linux-kernel, Christoph Lameter, Chris Metcalf, Peter Zijlstra,
	Frederic Weisbecker, Russell King, linux-mm, Pekka Enberg,
	Matt Mackall, Rik van Riel, Andi Kleen, Sasha Levin, Mel Gorman,
	Andrew Morton, Alexander Viro, linux-fsdevel, Avi Kivity,
	Michal Nazarewicz, Kosaki Motohiro

On Wed, Jan 11, 2012 at 9:04 AM, Milton Miller <miltonm@bga.com> wrote:
>
> Hi Gilad.   A few minor corrections for several of the patch logs, but some
> meater discussions on several of the patches.
>
> Overall I like the series and hope you see it through.


Hi Milton. Thanks so much for the detailed review.

As you've no doubt noticed, English is not my mother tongue (as opposed to
 C), so a special thank you for the patch logs review :-)


>
> <SNIP>



>
> > +void on_each_cpu_mask(const struct cpumask *mask, void (*func)(void *),
> > +                     void *info, bool wait)
> > +{
> > +     int cpu = get_cpu();
> > +
> > +     smp_call_function_many(mask, func, info, wait);
> > +     if (cpumask_test_cpu(cpu, mask)) {
> > +             local_irq_disable();
> > +             func(info);
> > +             local_irq_enable();
> > +     }
> > +     put_cpu();
> > +}
> > +EXPORT_SYMBOL(on_each_cpu_mask);
>
> It should be less code if we rewrite on_each_cpu as the one liner
> on_each_cpu_mask(cpu_online_mask).  I think the trade off of less
> code is worth the cost of the added test of cpu being in online_mask.
>
> That could be a seperate patch, but will be easier to read the result
> if on_each_cpu_mask is placed above on_each_cpu in this one.


Yes, it does look cleaner and I agree that the extra test is not a big
price to pay for simplee code.

However, to do that, on_each_cpu return value need to go away and
all caller needs to be adjusted. I figured this is out of scope for this
patch set.

I did send out a separate patch set to do the needed work  (see:
https://lkml.org/lkml/2012/1/8/48) and I suggest that after both of
them go in, I'll send a patch to do exactly what you suggested.

Thanks!
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
gilad@benyossef.com
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"Unfortunately, cache misses are an equal opportunity pain provider."
-- Mike Galbraith, LKML

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-11  8:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-08 16:26 [PATCH v6 0/8] Reduce cross CPU IPI interference Gilad Ben-Yossef
2012-01-08 16:32 ` Gilad Ben-Yossef
2012-01-09  9:30 ` Peter Zijlstra
2012-01-09 17:57 ` Chris Metcalf
2012-01-11  7:04 ` Milton Miller
2012-01-11  8:28   ` Gilad Ben-Yossef

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).