Re: [GIT PULL] x86 fixes for 2.6.30-rc8

From: Pallipadi, Venkatesh
Date: Tue May 26 2009 - 13:33:44 EST


On Mon, May 25, 2009 at 04:03:07PM -0700, H. Peter Anvin wrote:
> Linus Torvalds wrote:
> >
> > On Mon, 25 May 2009, Linus Torvalds wrote:
> >> Now you made it do two different "on_each_cpu" things. Maybe it doesn't
> >> matter, but it just seems wrong.
> >
> > Btw, I pulled, I just wanted to note that I don't think this was done
> > optimally/cleanly.
> >
>
> Understood. Do you want a fix now or for .31?
>

Below is the patch that does this optimally.

Thanks,
Venki


[PATCH] x86: Avoid back to back on_each_cpu in cpa_flush_array

Cleanup cpa_flush_array() to avoid back to back on_each_cpu() calls.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
---
arch/x86/mm/pageattr.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 0f9052b..532d05e 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -213,21 +213,15 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache,
int in_flags, struct page **pages)
{
unsigned int i, level;
+ unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */

BUG_ON(irqs_disabled());

- on_each_cpu(__cpa_flush_range, NULL, 1);
+ on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1);

- if (!cache)
+ if (!cache || do_wbinvd)
return;

- /* 4M threshold */
- if (numpages >= 1024) {
- if (boot_cpu_data.x86 >= 4)
- on_each_cpu(wbinvd_local, NULL, 1);
-
- return;
- }
/*
* We only need to flush on one CPU,
* clflush is a MESI-coherent instruction that
--
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/