* [PATCH] don't use flush_tlb_all in suspend time
@ 2006-04-30 3:24 Shaohua Li
2006-04-30 6:45 ` Pavel Machek
0 siblings, 1 reply; 13+ messages in thread
From: Shaohua Li @ 2006-04-30 3:24 UTC (permalink / raw)
To: lkml; +Cc: Pavel Machek, Andrew Morton
flush_tlb_all uses on_each_cpu, which will disable/enable interrupt.
In suspend/resume time, this will make interrupt wrongly enabled.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
linux-2.6.17-rc3-root/arch/i386/kernel/acpi/sleep.c | 2 +-
linux-2.6.17-rc3-root/arch/i386/mm/init.c | 5 ++++-
linux-2.6.17-rc3-root/arch/x86_64/kernel/acpi/sleep.c | 4 ++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff -puN arch/i386/kernel/acpi/sleep.c~flush_tlb_all_check arch/i386/kernel/acpi/sleep.c
--- linux-2.6.17-rc3/arch/i386/kernel/acpi/sleep.c~flush_tlb_all_check 2006-04-29 08:45:24.000000000 +0800
+++ linux-2.6.17-rc3-root/arch/i386/kernel/acpi/sleep.c 2006-04-29 08:46:49.000000000 +0800
@@ -29,7 +29,7 @@ static void init_low_mapping(pgd_t * pgd
set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD));
pgd_ofs++, pgd++;
}
- flush_tlb_all();
+ local_flush_tlb();
}
/**
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();
}
static int disable_nx __initdata = 0;
diff -puN arch/x86_64/kernel/acpi/sleep.c~flush_tlb_all_check arch/x86_64/kernel/acpi/sleep.c
--- linux-2.6.17-rc3/arch/x86_64/kernel/acpi/sleep.c~flush_tlb_all_check 2006-04-29 09:16:48.000000000 +0800
+++ linux-2.6.17-rc3-root/arch/x86_64/kernel/acpi/sleep.c 2006-04-29 09:17:19.000000000 +0800
@@ -66,7 +66,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));
- flush_tlb_all();
+ local_flush_tlb();
}
/**
@@ -92,7 +92,7 @@ int acpi_save_state_mem(void)
void acpi_restore_state_mem(void)
{
set_pgd(pgd_offset(current->mm, 0UL), low_ptr);
- flush_tlb_all();
+ local_flush_tlb();
}
/**
_
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] don't use flush_tlb_all in suspend time 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 0 siblings, 1 reply; 13+ messages in thread From: Pavel Machek @ 2006-04-30 6:45 UTC (permalink / raw) To: Shaohua Li; +Cc: lkml, Andrew Morton 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. Pavel -- Thanks, Sharp! ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-04-30 6:45 ` Pavel Machek @ 2006-04-30 6:46 ` Shaohua Li 2006-04-30 6:57 ` Andrew Morton 0 siblings, 1 reply; 13+ messages in thread From: Shaohua Li @ 2006-04-30 6:46 UTC (permalink / raw) To: Pavel Machek; +Cc: lkml, Andrew Morton 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. Thanks, Shaohua ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-04-30 6:46 ` Shaohua Li @ 2006-04-30 6:57 ` Andrew Morton 2006-04-30 7:19 ` Shaohua Li 2006-04-30 12:04 ` Pavel Machek 0 siblings, 2 replies; 13+ messages in thread From: Andrew Morton @ 2006-04-30 6:57 UTC (permalink / raw) To: Shaohua Li; +Cc: pavel, linux-kernel 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(); } _ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-04-30 6:57 ` Andrew Morton @ 2006-04-30 7:19 ` Shaohua Li 2006-04-30 12:04 ` Pavel Machek 1 sibling, 0 replies; 13+ messages in thread From: Shaohua Li @ 2006-04-30 7:19 UTC (permalink / raw) To: Andrew Morton; +Cc: pavel, linux-kernel On Sat, 2006-04-29 at 23:57 -0700, Andrew Morton wrote: > 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? Yes, this is great. Thanks! > 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(); > } > > _ -- Shaohua Li <shaohua.li@intel.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-04-30 6:57 ` Andrew Morton 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 1 sibling, 2 replies; 13+ messages in thread From: Pavel Machek @ 2006-04-30 12:04 UTC (permalink / raw) To: Andrew Morton; +Cc: Shaohua Li, linux-kernel On So 29-04-06 23:57:21, Andrew Morton wrote: > 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? Certainly better, I'd say. > @@ -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(); But this still scares. It means calling convention is "may enable interrupts with >1 cpu, may not with == 1 cpu". Pavel -- Thanks for all the (sleeping) penguins. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-04-30 12:04 ` Pavel Machek @ 2006-05-08 2:27 ` Shaohua Li 2006-05-18 3:29 ` Shaohua Li 1 sibling, 0 replies; 13+ messages in thread From: Shaohua Li @ 2006-05-08 2:27 UTC (permalink / raw) To: Pavel Machek; +Cc: Andrew Morton, linux-kernel On Sun, 2006-04-30 at 14:04 +0200, Pavel Machek wrote: > On So 29-04-06 23:57:21, Andrew Morton wrote: > > 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? > > Certainly better, I'd say. > > > @@ -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(); Sorry for the delay. Last week is holiday here. > But this still scares. It means calling convention is "may enable > interrupts with >1 cpu, may not with == 1 cpu". Then we need port x86_64's implementation. I'll try if I can work it out. Thanks, Shaohua ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 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 1 sibling, 1 reply; 13+ messages in thread From: Shaohua Li @ 2006-05-18 3:29 UTC (permalink / raw) To: Pavel Machek; +Cc: Andrew Morton, linux-kernel On Sun, 2006-04-30 at 14:04 +0200, Pavel Machek wrote: > On So 29-04-06 23:57:21, Andrew Morton wrote: > > 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? > > Certainly better, I'd say. > > > @@ -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(); > > But this still scares. It means calling convention is "may enable > interrupts with >1 cpu, may not with == 1 cpu". Below patch should make things clean. How do you think? Signed-off-by: Shaohua Li <shaohua.li@intel.com> --- linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/sleep.c | 10 +++------- linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/wakeup.S | 2 +- linux-2.6.17-rc4-mm1-root/arch/i386/mm/init.c | 13 +------------ 3 files changed, 5 insertions(+), 20 deletions(-) diff -puN arch/i386/kernel/acpi/wakeup.S~i386_direct_mapping arch/i386/kernel/acpi/wakeup.S --- linux-2.6.17-rc4-mm1/arch/i386/kernel/acpi/wakeup.S~i386_direct_mapping 2006-05-16 14:52:37.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/wakeup.S 2006-05-16 15:10:57.000000000 +0800 @@ -56,7 +56,7 @@ wakeup_code: 1: # set up page table - movl $swapper_pg_dir-__PAGE_OFFSET, %eax + movl $sleep_pg_dir-__PAGE_OFFSET, %eax movl %eax, %cr3 testl $1, real_efer_save_restore - wakeup_code diff -puN arch/i386/kernel/acpi/sleep.c~i386_direct_mapping arch/i386/kernel/acpi/sleep.c --- linux-2.6.17-rc4-mm1/arch/i386/kernel/acpi/sleep.c~i386_direct_mapping 2006-05-16 14:52:51.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/sleep.c 2006-05-17 09:30:26.000000000 +0800 @@ -11,16 +11,14 @@ #include <linux/cpumask.h> #include <asm/smp.h> -#include <asm/tlbflush.h> /* address in low memory of the wakeup routine. */ unsigned long acpi_wakeup_address = 0; unsigned long acpi_video_flags; extern char wakeup_start, wakeup_end; -extern void zap_low_mappings(void); - extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long)); +char sleep_pg_dir[PAGE_SIZE]; static void init_low_mapping(pgd_t * pgd, int pgd_limit) { @@ -31,8 +29,6 @@ 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(); } /** @@ -45,7 +41,8 @@ int acpi_save_state_mem(void) { if (!acpi_wakeup_address) return 1; - init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD); + memcpy(sleep_pg_dir, swapper_pg_dir, PAGE_SIZE); + init_low_mapping((pgd_t *)sleep_pg_dir, USER_PTRS_PER_PGD); memcpy((void *)acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); acpi_copy_wakeup_routine(acpi_wakeup_address); @@ -58,7 +55,6 @@ int acpi_save_state_mem(void) */ void acpi_restore_state_mem(void) { - zap_low_mappings(); } /** diff -puN arch/i386/mm/init.c~i386_direct_mapping arch/i386/mm/init.c --- linux-2.6.17-rc4-mm1/arch/i386/mm/init.c~i386_direct_mapping 2006-05-17 09:03:39.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/mm/init.c 2006-05-17 09:03:49.000000000 +0800 @@ -422,18 +422,7 @@ void zap_low_mappings (void) #else set_pgd(swapper_pg_dir+i, __pgd(0)); #endif - /* - * 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(); + flush_tlb_all(); } static int disable_nx __initdata = 0; _ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-05-18 3:29 ` Shaohua Li @ 2006-05-18 8:31 ` Pavel Machek 2006-05-18 8:38 ` Shaohua Li 2006-05-19 1:15 ` Shaohua Li 0 siblings, 2 replies; 13+ messages in thread From: Pavel Machek @ 2006-05-18 8:31 UTC (permalink / raw) To: Shaohua Li; +Cc: Andrew Morton, linux-kernel Hi! > > > In which case, how's about this? > > > > Certainly better, I'd say. > > > > > @@ -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(); > > > > But this still scares. It means calling convention is "may enable > > interrupts with >1 cpu, may not with == 1 cpu". > Below patch should make things clean. How do you think? Nice... Could we perhaps reuse swsusp_pg_dir (just make it used for swsusp & suspend-to-ram) to save a bit more code? It is in arch/i386/mm/init.c . Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 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 1 sibling, 1 reply; 13+ messages in thread From: Shaohua Li @ 2006-05-18 8:38 UTC (permalink / raw) To: Pavel Machek; +Cc: Andrew Morton, linux-kernel On Thu, 2006-05-18 at 10:31 +0200, Pavel Machek wrote: > Hi! > > > > > In which case, how's about this? > > > > > > Certainly better, I'd say. > > > > > > > @@ -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(); > > > > > > But this still scares. It means calling convention is "may enable > > > interrupts with >1 cpu, may not with == 1 cpu". > > Below patch should make things clean. How do you think? > > Nice... > > Could we perhaps reuse swsusp_pg_dir (just make it used for swsusp & > suspend-to-ram) to save a bit more code? It is in arch/i386/mm/init.c Sure. But it's under CONFIG_SOFTWARE_SUSPEND. That part needs cleanup I think and it's a little strange to me (why should we simply copy swapper_pg_dir to swsusp_pg_dir, instead do it in zap_low_mappings?). Thanks, Shaohua ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-05-18 8:38 ` Shaohua Li @ 2006-05-18 8:46 ` Pavel Machek 0 siblings, 0 replies; 13+ messages in thread From: Pavel Machek @ 2006-05-18 8:46 UTC (permalink / raw) To: Shaohua Li; +Cc: Andrew Morton, linux-kernel On Čt 18-05-06 16:38:21, Shaohua Li wrote: > On Thu, 2006-05-18 at 10:31 +0200, Pavel Machek wrote: > > Hi! > > > > > > > In which case, how's about this? > > > > > > > > Certainly better, I'd say. > > > > > > > > > @@ -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(); > > > > > > > > But this still scares. It means calling convention is "may enable > > > > interrupts with >1 cpu, may not with == 1 cpu". > > > Below patch should make things clean. How do you think? > > > > Nice... > > > > Could we perhaps reuse swsusp_pg_dir (just make it used for swsusp & > > suspend-to-ram) to save a bit more code? It is in arch/i386/mm/init.c > Sure. But it's under CONFIG_SOFTWARE_SUSPEND. Yes, #ifdef definitely does need to change there. > That part needs cleanup I > think and it's a little strange to me (why should we simply copy > swapper_pg_dir to swsusp_pg_dir, instead do it in zap_low_mappings?). ?? Sorry, I do not understand. "instead of doing"? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-05-18 8:31 ` Pavel Machek 2006-05-18 8:38 ` Shaohua Li @ 2006-05-19 1:15 ` Shaohua Li 2006-05-20 15:50 ` Pavel Machek 1 sibling, 1 reply; 13+ messages in thread From: Shaohua Li @ 2006-05-19 1:15 UTC (permalink / raw) To: Pavel Machek; +Cc: Andrew Morton, linux-kernel On Thu, 2006-05-18 at 10:31 +0200, Pavel Machek wrote: > Hi! > > > > > In which case, how's about this? > > > > > > Certainly better, I'd say. > > > > > > > @@ -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(); > > > > > > But this still scares. It means calling convention is "may enable > > > interrupts with >1 cpu, may not with == 1 cpu". > > Below patch should make things clean. How do you think? > > Nice... > > Could we perhaps reuse swsusp_pg_dir (just make it used for swsusp & > suspend-to-ram) to save a bit more code? It is in arch/i386/mm/init.c Ok, I guess this is what you want. Signed-off-by: Shaohua Li <shaohua.li@intel.com> --- linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/sleep.c | 18 --------------- linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/wakeup.S | 2 - linux-2.6.17-rc4-mm1-root/arch/i386/mm/init.c | 15 +----------- 3 files changed, 3 insertions(+), 32 deletions(-) diff -puN arch/i386/kernel/acpi/wakeup.S~i386_direct_mapping arch/i386/kernel/acpi/wakeup.S --- linux-2.6.17-rc4-mm1/arch/i386/kernel/acpi/wakeup.S~i386_direct_mapping 2006-05-16 14:52:37.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/wakeup.S 2006-05-18 07:12:40.000000000 +0800 @@ -56,7 +56,7 @@ wakeup_code: 1: # set up page table - movl $swapper_pg_dir-__PAGE_OFFSET, %eax + movl $swsusp_pg_dir-__PAGE_OFFSET, %eax movl %eax, %cr3 testl $1, real_efer_save_restore - wakeup_code diff -puN arch/i386/kernel/acpi/sleep.c~i386_direct_mapping arch/i386/kernel/acpi/sleep.c --- linux-2.6.17-rc4-mm1/arch/i386/kernel/acpi/sleep.c~i386_direct_mapping 2006-05-16 14:52:51.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/kernel/acpi/sleep.c 2006-05-18 07:11:38.000000000 +0800 @@ -11,30 +11,14 @@ #include <linux/cpumask.h> #include <asm/smp.h> -#include <asm/tlbflush.h> /* address in low memory of the wakeup routine. */ unsigned long acpi_wakeup_address = 0; unsigned long acpi_video_flags; extern char wakeup_start, wakeup_end; -extern void zap_low_mappings(void); - extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long)); -static void init_low_mapping(pgd_t * pgd, int pgd_limit) -{ - int pgd_ofs = 0; - - while ((pgd_ofs < pgd_limit) - && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) { - set_pgd(pgd, *(pgd + USER_PTRS_PER_PGD)); - pgd_ofs++, pgd++; - } - WARN_ON(num_online_cpus() != 1); - local_flush_tlb(); -} - /** * acpi_save_state_mem - save kernel state * @@ -45,7 +29,6 @@ int acpi_save_state_mem(void) { if (!acpi_wakeup_address) return 1; - init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD); memcpy((void *)acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); acpi_copy_wakeup_routine(acpi_wakeup_address); @@ -58,7 +41,6 @@ int acpi_save_state_mem(void) */ void acpi_restore_state_mem(void) { - zap_low_mappings(); } /** diff -puN arch/i386/mm/init.c~i386_direct_mapping arch/i386/mm/init.c --- linux-2.6.17-rc4-mm1/arch/i386/mm/init.c~i386_direct_mapping 2006-05-17 09:03:39.000000000 +0800 +++ linux-2.6.17-rc4-mm1-root/arch/i386/mm/init.c 2006-05-18 07:11:10.000000000 +0800 @@ -386,7 +386,7 @@ static void __init pagetable_init (void) #endif } -#ifdef CONFIG_SOFTWARE_SUSPEND +#if defined(CONFIG_SOFTWARE_SUSPEND) || defined(CONFIG_ACPI_SLEEP) /* * Swap suspend & friends need this for resume because things like the intel-agp * driver might have split up a kernel 4MB mapping. @@ -422,18 +422,7 @@ void zap_low_mappings (void) #else set_pgd(swapper_pg_dir+i, __pgd(0)); #endif - /* - * 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(); + flush_tlb_all(); } static int disable_nx __initdata = 0; _ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] don't use flush_tlb_all in suspend time 2006-05-19 1:15 ` Shaohua Li @ 2006-05-20 15:50 ` Pavel Machek 0 siblings, 0 replies; 13+ messages in thread From: Pavel Machek @ 2006-05-20 15:50 UTC (permalink / raw) To: Shaohua Li; +Cc: Andrew Morton, linux-kernel Hi! > > > > > @@ -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(); > > > > > > > > But this still scares. It means calling convention is "may enable > > > > interrupts with >1 cpu, may not with == 1 cpu". > > > Below patch should make things clean. How do you think? > > > > Nice... > > > > Could we perhaps reuse swsusp_pg_dir (just make it used for swsusp & > > suspend-to-ram) to save a bit more code? It is in arch/i386/mm/init.c > Ok, I guess this is what you want. Yes, thanks a lot for patience. > Signed-off-by: Shaohua Li <shaohua.li@intel.com> Acked-by: Pavel Machek <pavel@suse.cz> -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2006-05-20 15:50 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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.