public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Andrew Morton <akpm@digeo.com>,
	kernel list <linux-kernel@vger.kernel.org>
Subject: Re: Hot/cold allocation -- swsusp can not handle hot pages
Date: Sun, 3 Nov 2002 12:52:06 -0800	[thread overview]
Message-ID: <20021103205206.GN23425@holomorphy.com> (raw)
In-Reply-To: <20021103200809.GC27271@elf.ucw.cz>

On Sun, Nov 03, 2002 at 09:08:09PM +0100, Pavel Machek wrote:
> "big-picture" should be in Documentation/swsusp.txt...
> *Should* be :-(. I need to copy all used memory, to make sure my
> snapshot is atomic.
> Copying works by looking at what is allocated, counting needed pages,
> allocating 'directory' for them, allocating memory for copies, and
> actually copying.
> When I suddenly find I have less data to copy than I thought, it
> screws up the code.

Why don't we just mark PG_nosave in page->flags and stuff order in
page->index (or elsewhere) for you and then you can safely walk
the zone->zone_mem_map? A single pass of marking up-front should
be a bit quicker than searching the lists for a list head at every
page, and also something more maintainable/comprehensible: we can
basically know what we're dealing with and do a kind of "shutdown"
of the stuff for you:


static void empty_pageset(struct zone *zone, struct per_cpu_pages *pcp)
{
	pcp->batch = pcp->low = pcp->high = 1;
	pcp->count -= free_pages_bulk(zone, pcp->batch, &pcp->list, 0);
}

static void empty_cpu_pages(void *unused)
{
	struct zone *zone;
	unsigned long flags;
	int cpu;

	cpu = get_cpu();
	local_irq_save(flags);

	for_each_zone(zone) {
		empty_pcp(zone, &zone->pageset[cpu].pcp[0]);
		empty_pcp(zone, &zone->pageset[cpu].pcp[1]);
	}

	local_irq_restore(flags);
	put_cpu();
}

static void shootdown_per_cpu_pages(void)
{
	smp_call_function(empty_cpu_pages, NULL, 0, 1);
	empty_cpu_pages(NULL);
}

void suspend_mark_free_pages(void)
{
	struct zone *zone;
	struct free_area *area;
	struct page *page;
	unsigned long flags;
	int order;

	shootdown_per_cpu_pages();

	for_each_zone(zone) {
		spin_lock_irqsave(&zone->lock, flags);
		for (order = 0; order < MAX_ORDER; ++order) {
			area = &zone->free_area[order];
			list_for_each_entry(page, &area->free_list, list) {
				SetPageNosave(page);
				/* if ->index clashes, use flag bits */
				page->index = order;
			}
		}
		spin_unlock_irqrestore(&zone->lock, flags);
	}
}

Then you can just do

	if (PageNosave(page))
		pfn += 1 << page->index;

in kernel/suspend.c and everybody's happy, no?


Bill

  parent reply	other threads:[~2002-11-03 20:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-02 18:19 Hot/cold allocation -- swsusp can not handle hot pages Pavel Machek
2002-11-02 18:46 ` William Lee Irwin III
2002-11-02 20:22   ` Pavel Machek
2002-11-02 21:48     ` Andrew Morton
2002-11-03 20:08       ` Pavel Machek
2002-11-03 20:14         ` William Lee Irwin III
2002-11-03 20:21         ` Andrew Morton
2002-11-03 20:26           ` Pavel Machek
2002-11-03 20:52         ` William Lee Irwin III [this message]
2002-11-03 21:22           ` William Lee Irwin III
2002-11-03 22:53           ` 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=20021103205206.GN23425@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox