From rjw@sisk.pl Thu Jul 27 03:38:39 2006 Return-Path: Delivered-To: ncunningham:linuxmail.org@linuxmail.org Received: (qmail 23825 invoked by uid 0); 26 Jul 2006 17:43:35 -0000 X-OB-Received: from unknown (192.168.9.134) by mta45-1.us4.outblaze.com; 26 Jul 2006 17:43:35 -0000 Received: from asclepius.uwa.edu.au (asclepius.uwa.edu.au [130.95.128.56]) by spf5-1.us4.outblaze.com (Postfix) with ESMTP id B5D6763D8C for ; Wed, 26 Jul 2006 17:42:22 +0000 (GMT) Received: from asclepius.kas (localhost.localdomain [127.0.0.1]) by asclepius.uwa.edu.au (Postfix) with SMTP id F4233184968 for ; Thu, 27 Jul 2006 01:40:41 +0800 (WST) Received: from asclepius (localhost.localdomain [127.0.0.1]) by asclepius.prekas (Postfix) with SMTP id D1DE9184830 for ; Thu, 27 Jul 2006 01:40:41 +0800 (WST) X-UWA-Client-IP: 130.95.13.29 (UWA) Received: from coolstore.ucc.gu.uwa.edu.au (coolstore.ucc.gu.uwa.edu.au [130.95.13.29]) by asclepius.extinput (Postfix) with ESMTP id A8E331840D6 for ; Thu, 27 Jul 2006 01:40:41 +0800 (WST) Received: by coolstore.ucc.gu.uwa.edu.au (Postfix) id 55A2F3292E; Thu, 27 Jul 2006 03:40:41 +1000 (EST) Delivered-To: nigel@suspend2.net Received: from asclepius.uwa.edu.au (asclepius.uwa.edu.au [130.95.128.56]) by coolstore.ucc.gu.uwa.edu.au (Postfix) with ESMTP id 2E35E323B6 for ; Thu, 27 Jul 2006 03:40:41 +1000 (EST) Received: from asclepius.kas (localhost.localdomain [127.0.0.1]) by asclepius.uwa.edu.au (Postfix) with SMTP id 373E7184985 for ; Thu, 27 Jul 2006 01:40:39 +0800 (WST) Received: from asclepius (localhost.localdomain [127.0.0.1]) by asclepius.prekas (Postfix) with SMTP id 148991848F0 for ; Thu, 27 Jul 2006 01:40:39 +0800 (WST) X-UWA-Client-IP: 65.172.181.4 (EXTERNAL) Received: from smtp.osdl.org (smtp.osdl.org [65.172.181.4]) by asclepius.input (Postfix) with ESMTP id 2452C1848BF for ; Thu, 27 Jul 2006 01:40:37 +0800 (WST) Received: from fire-2.osdl.org (localhost [127.0.0.1]) by smtp.osdl.org (8.12.8/8.12.8) with ESMTP id k6QHcsnW013724; Wed, 26 Jul 2006 10:39:11 -0700 Received: from ogre.sisk.pl (ogre.sisk.pl [217.79.144.158]) by smtp.osdl.org (8.12.8/8.12.8) with ESMTP id k6QHcpnV013720 for ; Wed, 26 Jul 2006 10:38:52 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 2C42510A98; Wed, 26 Jul 2006 19:29:10 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 15869-04; Wed, 26 Jul 2006 19:29:09 +0200 (CEST) Received: from [192.168.100.153] (nat-be2.aster.pl [212.76.37.166]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 0B9DED522; Wed, 26 Jul 2006 19:29:09 +0200 (CEST) From: "Rafael J. Wysocki" To: Andi Kleen Date: Wed, 26 Jul 2006 19:38:39 +0200 User-Agent: KMail/1.9.3 References: <200607251325.14747.rjw@sisk.pl> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200607261938.39213.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-5.013 required=5 tests=AWL,OSDL_HEADER_LISTID_KNOWN,OSDL_HEADER_SUBJECT_BRACKETED,PATCH_UNIFIED_DIFF_OSDL X-Spam-Checker-Version: SpamAssassin 2.63-osdl_revision__1.94__ X-MIMEDefang-Filter: osdl$Revision: 1.141 $ Cc: Linux PM , linux-kernel@vger.kernel.org, Pavel Machek Subject: Re: [linux-pm] swsusp status report X-BeenThere: linux-pm@lists.osdl.org X-Mailman-Version: 2.1.8 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: linux-pm-bounces@lists.osdl.org Errors-To: linux-pm-bounces@lists.osdl.org X-SpamTest-Info: Profile: Formal (459/060726) X-SpamTest-Info: Profile: Detect Hard [UCS 290904] X-SpamTest-Info: Profile: SysLog X-SpamTest-Info: Profile: Marking Spam - Subject (UCS) [02-08-04] X-SpamTest-Status: Not detected X-SpamTest-Version: SMTP-Filter Version 2.0.0 [0125], KAS/Release SMTP-Filter Version 2.0.0 [0125], KAS/Release X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.0.1 X-UID: Status: R X-Status: NC X-KMail-EncryptionState: X-KMail-SignatureState: X-KMail-MDN-Sent: On Wednesday 26 July 2006 17:13, Andi Kleen wrote: > "Rafael J. Wysocki" writes: > > = > > The code that restores the memory state from the suspend image in step > > (11) also uses the kernel identity mapping to address memory, so it can= not > > access highmem pages on i386, but it practically has no other limitatio= ns as > > far as the image size is concerned. In other words, it would be possib= le to > > restore suspend images as big as 80% or even 90% of RAM, or the normal = zone > > on i386, if the 'snapshotting' code were able to create them. > = > Why can't you just kmap or ioremap them as needed and pass the pfns/struct > page * for IO? In principle we can, but that's a long way to go from where we are today. Currently, we need to make a copy of each highmem page, because we have no good method of checking which of them are going to change after we have created the snapshot image and before we save them. Moreover, the copies a= re made in the normal zone, because swsusp uses kernel virtual addresses to enumerate the suspend image pages. If the copies of the highmem pages were made in the highmem zone, we'd have to use pfns to enumerate them and that would require some substantial code changes. > > The code that performs steps (5) and (11) of the suspend-resume cycle is > > quite robust and there is only one known problem with it, which seems to > > be x86_64-specific. Namely, on x86_64 machines with more than 2 GB of = RAM > > there are memory gaps and/or reserved memory areas between the 2nd and = 3rd > > Gbyte of physical memory and swsusp tries to save these areas as though > > they were RAM which leads to oopses. This issue is now being worked on. > = > I guess we could just borrow a new struct page flags bit again and set it > during memory setup. That would fix your problem I guess. Should be fairly > easy to do. Let me know if you need it. Actaully we already have the PG_nosave bit for this purpose and a patch that fixes this is in the -mm tree now. [I'm sorry you were not on the Cc list, but one of the Andrew's machines was affected and he just picked up the patch.] I'm appeding it for reference (hope it's OK ;-) ). Greetings, Rafael --- arch/x86_64/kernel/e820.c | 48 ++++++++++++++++++++++++++++++++++++++++= +++++ arch/x86_64/kernel/setup.c | 1 = include/asm-x86_64/e820.h | 1 = 3 files changed, 50 insertions(+) Index: linux-2.6.18-rc1-mm2/arch/x86_64/kernel/e820.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.18-rc1-mm2.orig/arch/x86_64/kernel/e820.c +++ linux-2.6.18-rc1-mm2/arch/x86_64/kernel/e820.c @@ -16,6 +16,7 @@ #include #include #include +#include = #include #include @@ -293,6 +294,53 @@ void __init e820_reserve_resources(void) } } = +/* Mark pages corresponding to given address range as nosave */ +static void __init +e820_mark_nosave_range(unsigned long start, unsigned long end) +{ + unsigned long pfn, max_pfn; + + if (start >=3D end) + return; + + printk("Nosave address range: %016lx - %016lx\n", start, end); + max_pfn =3D end >> PAGE_SHIFT; + for (pfn =3D start >> PAGE_SHIFT; pfn < max_pfn; pfn++) + if (pfn_valid(pfn)) + SetPageNosave(pfn_to_page(pfn)); +} + +/* + * Find the ranges of physical addresses that do not correspond to + * e820 RAM areas and mark the corresponding pages as nosave for software + * suspend and suspend to RAM. + * + * This function requires the e820 map to be sorted and without any + * overlapping entries and assumes the first e820 area to be RAM. + */ +void __init e820_mark_nosave_regions(void) +{ + int i; + unsigned long paddr; + + paddr =3D round_down(e820.map[0].addr + e820.map[0].size, PAGE_SIZE); + for (i =3D 1; i < e820.nr_map; i++) { + struct e820entry *ei =3D &e820.map[i]; + + if (paddr < ei->addr) + e820_mark_nosave_range(paddr, + round_up(ei->addr, PAGE_SIZE)); + + paddr =3D round_down(ei->addr + ei->size, PAGE_SIZE); + if (ei->type !=3D E820_RAM) + e820_mark_nosave_range(round_up(ei->addr, PAGE_SIZE), + paddr); + + if (paddr >=3D (end_pfn << PAGE_SHIFT)) + break; + } +} + /* = * Add a memory region to the kernel e820 map. */ = Index: linux-2.6.18-rc1-mm2/arch/x86_64/kernel/setup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.18-rc1-mm2.orig/arch/x86_64/kernel/setup.c +++ linux-2.6.18-rc1-mm2/arch/x86_64/kernel/setup.c @@ -684,6 +684,7 @@ void __init setup_arch(char **cmdline_p) */ probe_roms(); e820_reserve_resources(); = + e820_mark_nosave_regions(); = request_resource(&iomem_resource, &video_ram_resource); = Index: linux-2.6.18-rc1-mm2/include/asm-x86_64/e820.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.18-rc1-mm2.orig/include/asm-x86_64/e820.h +++ linux-2.6.18-rc1-mm2/include/asm-x86_64/e820.h @@ -46,6 +46,7 @@ extern void setup_memory_region(void); extern void contig_e820_setup(void); = extern unsigned long e820_end_of_ram(void); extern void e820_reserve_resources(void); +extern void e820_mark_nosave_regions(void); extern void e820_print_map(char *who); extern int e820_any_mapped(unsigned long start, unsigned long end, unsigne= d type); extern int e820_all_mapped(unsigned long start, unsigned long end, unsigne= d type); _______________________________________________ linux-pm mailing list linux-pm@lists.osdl.org https://lists.osdl.org/mailman/listinfo/linux-pm