All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Shaohua Li <shaohua.li@intel.com>
Cc: pavel@ucw.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] don't use flush_tlb_all in suspend time
Date: Sat, 29 Apr 2006 23:57:21 -0700	[thread overview]
Message-ID: <20060429235721.1d081ea5.akpm@osdl.org> (raw)
In-Reply-To: <1146379596.8456.4.camel@sli10-desk.sh.intel.com>

Shaohua Li <shaohua.li@intel.com> wrote:
>
> On Sun, 2006-04-30 at 06:45 +0000, Pavel Machek wrote:
> > Hi!
> > 
> > > flush_tlb_all uses on_each_cpu, which will disable/enable interrupt.
> > > In suspend/resume time, this will make interrupt wrongly enabled.
> > 
> > > diff -puN arch/i386/mm/init.c~flush_tlb_all_check arch/i386/mm/init.c
> > > --- linux-2.6.17-rc3/arch/i386/mm/init.c~flush_tlb_all_check	2006-04-29 08:47:05.000000000 +0800
> > > +++ linux-2.6.17-rc3-root/arch/i386/mm/init.c	2006-04-29 08:48:15.000000000 +0800
> > > @@ -420,7 +420,10 @@ void zap_low_mappings (void)
> > >  #else
> > >  		set_pgd(swapper_pg_dir+i, __pgd(0));
> > >  #endif
> > > -	flush_tlb_all();
> > > +	if (cpus_weight(cpu_online_map) == 1)
> > > +		local_flush_tlb();
> > > +	else
> > > +		flush_tlb_all();
> > >  }
> > >
> > 
> > Either it is okay to enable interrupts here -> unneccessary and ugly
> > test, or it is not, and then we are broken in SMP case.
> It's not broken in SMP case, APs are offlined here in suspend/resume.
> 

In which case, how's about this?


 arch/i386/kernel/acpi/sleep.c   |    3 +++
 arch/i386/mm/init.c             |   10 +++++++++-
 arch/x86_64/kernel/acpi/sleep.c |    3 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff -puN arch/i386/kernel/acpi/sleep.c~dont-use-flush_tlb_all-in-suspend-time-tidy arch/i386/kernel/acpi/sleep.c
--- devel/arch/i386/kernel/acpi/sleep.c~dont-use-flush_tlb_all-in-suspend-time-tidy	2006-04-29 23:53:33.000000000 -0700
+++ devel-akpm/arch/i386/kernel/acpi/sleep.c	2006-04-29 23:54:09.000000000 -0700
@@ -8,6 +8,8 @@
 #include <linux/acpi.h>
 #include <linux/bootmem.h>
 #include <linux/dmi.h>
+#include <linux/cpumask.h>
+
 #include <asm/smp.h>
 #include <asm/tlbflush.h>
 
@@ -29,6 +31,7 @@ static void init_low_mapping(pgd_t * pgd
 		set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD));
 		pgd_ofs++, pgd++;
 	}
+	WARN_ON(num_online_cpus() != 1);
 	local_flush_tlb();
 }
 
diff -puN arch/i386/mm/init.c~dont-use-flush_tlb_all-in-suspend-time-tidy arch/i386/mm/init.c
--- devel/arch/i386/mm/init.c~dont-use-flush_tlb_all-in-suspend-time-tidy	2006-04-29 23:53:33.000000000 -0700
+++ devel-akpm/arch/i386/mm/init.c	2006-04-29 23:56:00.000000000 -0700
@@ -29,6 +29,7 @@
 #include <linux/efi.h>
 #include <linux/memory_hotplug.h>
 #include <linux/initrd.h>
+#include <linux/cpumask.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -420,7 +421,14 @@ void zap_low_mappings (void)
 #else
 		set_pgd(swapper_pg_dir+i, __pgd(0));
 #endif
-	if (cpus_weight(cpu_online_map) == 1)
+	/*
+	 * We can be called at suspend/resume time, with local interrupts
+	 * disabled.  But flush_tlb_all() requires that local interrupts be
+	 * enabled.
+	 *
+	 * Happily, the APs are not yet started, so we can use local_flush_tlb()	 * in that case
+	 */
+	if (num_online_cpus() == 1)
 		local_flush_tlb();
 	else
 		flush_tlb_all();
diff -puN arch/x86_64/kernel/acpi/sleep.c~dont-use-flush_tlb_all-in-suspend-time-tidy arch/x86_64/kernel/acpi/sleep.c
--- devel/arch/x86_64/kernel/acpi/sleep.c~dont-use-flush_tlb_all-in-suspend-time-tidy	2006-04-29 23:53:33.000000000 -0700
+++ devel-akpm/arch/x86_64/kernel/acpi/sleep.c	2006-04-29 23:56:24.000000000 -0700
@@ -35,6 +35,8 @@
 #include <linux/pci.h>
 #include <linux/bootmem.h>
 #include <linux/acpi.h>
+#include <linux/cpumask.h>
+
 #include <asm/mpspec.h>
 #include <asm/io.h>
 #include <asm/apic.h>
@@ -66,6 +68,7 @@ static void init_low_mapping(void)
 	pgd_t *slot0 = pgd_offset(current->mm, 0UL);
 	low_ptr = *slot0;
 	set_pgd(slot0, *pgd_offset(current->mm, PAGE_OFFSET));
+	WARN_ON(num_online_cpus() != 1);
 	local_flush_tlb();
 }
 
_


  reply	other threads:[~2006-04-30  6:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-30  3:24 [PATCH] don't use flush_tlb_all in suspend time Shaohua Li
2006-04-30  6:45 ` Pavel Machek
2006-04-30  6:46   ` Shaohua Li
2006-04-30  6:57     ` Andrew Morton [this message]
2006-04-30  7:19       ` Shaohua Li
2006-04-30 12:04       ` Pavel Machek
2006-05-08  2:27         ` Shaohua Li
2006-05-18  3:29         ` Shaohua Li
2006-05-18  8:31           ` Pavel Machek
2006-05-18  8:38             ` Shaohua Li
2006-05-18  8:46               ` Pavel Machek
2006-05-19  1:15             ` Shaohua Li
2006-05-20 15:50               ` Pavel Machek

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=20060429235721.1d081ea5.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=shaohua.li@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.