From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Pavel Machek <pavel@suse.cz>
Cc: Dave Hansen <haveblue@us.ibm.com>, Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] swsusp: Fix mark_free_pages
Date: Wed, 2 Aug 2006 22:48:54 +0200 [thread overview]
Message-ID: <200608022248.54162.rjw@sisk.pl> (raw)
In-Reply-To: <20060802203005.GF8124@elf.ucw.cz>
On Wednesday 02 August 2006 22:30, Pavel Machek wrote:
> Hi!
>
> Looks good to me (ACK).
>
> > if (page) {
> > - long *src, *dst;
> > - int n;
> > + void *ptr = page_address(page);;
>
> You probably want to remove one of ";"s.
Ouch.
I hope this is the final one.
---
Clean up mm/page_alloc.c#mark_free_pages() and make it avoid clearing
PageNosaveFree for PageNosave pages. This allows us to get rid of an ugly
hack in kernel/power/snapshot.c#copy_data_pages().
Additionally, the page-copying loop in copy_data_pages() is moved to an
inline function.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
kernel/power/snapshot.c | 27 +++++++++++++--------------
mm/page_alloc.c | 24 ++++++++++++++++--------
2 files changed, 29 insertions(+), 22 deletions(-)
Index: linux-2.6.18-rc2-mm1/mm/page_alloc.c
===================================================================
--- linux-2.6.18-rc2-mm1.orig/mm/page_alloc.c
+++ linux-2.6.18-rc2-mm1/mm/page_alloc.c
@@ -703,7 +703,8 @@ static void __drain_pages(unsigned int c
void mark_free_pages(struct zone *zone)
{
- unsigned long zone_pfn, flags;
+ unsigned long pfn, max_zone_pfn;
+ unsigned long flags;
int order;
struct list_head *curr;
@@ -711,18 +712,25 @@ void mark_free_pages(struct zone *zone)
return;
spin_lock_irqsave(&zone->lock, flags);
- for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
- ClearPageNosaveFree(pfn_to_page(zone_pfn + zone->zone_start_pfn));
+
+ max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
+ for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+
+ if (!PageNosave(page))
+ ClearPageNosaveFree(page);
+ }
for (order = MAX_ORDER - 1; order >= 0; --order)
list_for_each(curr, &zone->free_area[order].free_list) {
- unsigned long start_pfn, i;
+ unsigned long i;
- start_pfn = page_to_pfn(list_entry(curr, struct page, lru));
+ pfn = page_to_pfn(list_entry(curr, struct page, lru));
+ for (i = 0; i < (1UL << order); i++)
+ SetPageNosaveFree(pfn_to_page(pfn + i));
+ }
- for (i=0; i < (1<<order); i++)
- SetPageNosaveFree(pfn_to_page(start_pfn+i));
- }
spin_unlock_irqrestore(&zone->lock, flags);
}
Index: linux-2.6.18-rc2-mm1/kernel/power/snapshot.c
===================================================================
--- linux-2.6.18-rc2-mm1.orig/kernel/power/snapshot.c
+++ linux-2.6.18-rc2-mm1/kernel/power/snapshot.c
@@ -208,37 +208,36 @@ unsigned int count_data_pages(void)
return n;
}
+static inline void copy_data_page(long *dst, long *src)
+{
+ int n;
+
+ /* copy_page and memcpy are not usable for copying task structs. */
+ for (n = PAGE_SIZE / sizeof(long); n; n--)
+ *dst++ = *src++;
+}
+
static void copy_data_pages(struct pbe *pblist)
{
struct zone *zone;
unsigned long pfn, max_zone_pfn;
- struct pbe *pbe, *p;
+ struct pbe *pbe;
pbe = pblist;
for_each_zone (zone) {
if (is_highmem(zone))
continue;
mark_free_pages(zone);
- /* This is necessary for swsusp_free() */
- for_each_pb_page (p, pblist)
- SetPageNosaveFree(virt_to_page(p));
- for_each_pbe (p, pblist)
- SetPageNosaveFree(virt_to_page(p->address));
max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
struct page *page = saveable_page(pfn);
if (page) {
- long *src, *dst;
- int n;
+ void *ptr = page_address(page);
BUG_ON(!pbe);
- pbe->orig_address = (unsigned long)page_address(page);
- /* copy_page and memcpy are not usable for copying task structs. */
- dst = (long *)pbe->address;
- src = (long *)pbe->orig_address;
- for (n = PAGE_SIZE / sizeof(long); n; n--)
- *dst++ = *src++;
+ copy_data_page((void *)pbe->address, ptr);
+ pbe->orig_address = (unsigned long)ptr;
pbe = pbe->next;
}
}
next prev parent reply other threads:[~2006-08-02 20:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-02 16:42 [PATCH 0/3] swsusp cleanups Rafael J. Wysocki
2006-08-02 16:48 ` [PATCH 1/3] swsusp: Fix mark_free_pages Rafael J. Wysocki
2006-08-02 19:51 ` Dave Hansen
2006-08-02 20:12 ` Rafael J. Wysocki
2006-08-02 20:30 ` Pavel Machek
2006-08-02 20:48 ` Rafael J. Wysocki [this message]
2006-08-02 16:53 ` [PATCH 2/3] swsusp: Reorder memory-allocating functions Rafael J. Wysocki
2006-08-02 20:19 ` Pavel Machek
2006-08-02 16:57 ` [PATCH 3/3] swsusp: Fix alloc_pagedir Rafael J. Wysocki
2006-08-02 20:22 ` 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=200608022248.54162.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@osdl.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/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.