All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: Software suspend testing in 2.6.0-test1
Date: 18 Jul 2003 17:55:01 +0200	[thread overview]
Message-ID: <m2el0nvnhm.fsf@telia.com> (raw)
In-Reply-To: <20030718152205.GA407@elf.ucw.cz>

Pavel Machek <pavel@ucw.cz> writes:

> > However I'm trying to remember why the code exists at all.  Why doesn't
> > swsusp just allocate lots of pages then free them again?
> 
> Because that either
> 
> a) does not free enough pages or
> 
> b) triggers OOM killer.
> 
> It was actually your idea, IIRC ;-).
> 
> Ahha, you seem to be addressing that in your code. Peter, perhaps you
> want to test that one?

I tried the patch below, but it didn't work. Nothing (or very little)
was swapped out to disk. I also tried using GFP_KERNEL, but that
seemed to cause a deadlock. (Maybe it would have gone OOM if I had
waited long enough). I think the problem is that pdflush and friends
are already frozen when this code runs.

--- linux/kernel/suspend.c.old	Fri Jul 18 15:46:48 2003
+++ linux/kernel/suspend.c	Fri Jul 18 15:45:51 2003
@@ -621,10 +621,32 @@
  */
 static void free_some_memory(void)
 {
-	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))
-		printk(".");
+	LIST_HEAD(list);
+	struct page *page, *tmp;
+	int sleep_count = 0;
+	int i = 0;
+
+	while (sleep_count < 10) {
+		page = alloc_page(GFP_ATOMIC);
+		if (page) {
+			list_add(&page->list, &list);
+			sleep_count = 0;
+		} else {
+			blk_congestion_wait(WRITE, HZ/20);
+			sleep_count++;
+		}
+		i++;
+		if (!(i%1000))
+			printk(".");
+	}
 	printk("|\n");
+
+	i = 0;
+	list_for_each_entry_safe(page, tmp, &list, list) {
+		__free_page(page);
+		i++;
+	}
+	printk("%d pages freed\n", i);
 }
 
 /* Make disk drivers accept operations, again */

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

  reply	other threads:[~2003-07-18 15:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-17 19:46 Software suspend testing in 2.6.0-test1 Peter Osterlund
2003-07-17 20:00 ` Pavel Machek
2003-07-17 20:09   ` Andrew Morton
2003-07-18  9:59     ` Peter Osterlund
2003-07-18 10:24       ` Andrew Morton
2003-07-18 15:22         ` Pavel Machek
2003-07-18 15:55           ` Peter Osterlund [this message]
2003-07-18 16:45             ` Andrew Morton
2003-07-18 17:50               ` Pavel Machek
2003-07-18 18:02                 ` Patrick Mochel
2003-07-18 18:04                   ` Pavel Machek
2003-07-18 21:05                     ` Nigel Cunningham
2003-07-18 19:37                 ` Andrew Morton
2003-07-18 19:58               ` Peter Osterlund
2003-07-18 20:15                 ` Andrew Morton
2003-07-18 22:13                   ` Pavel Machek
2003-07-20  0:22                   ` Peter Osterlund
2003-07-20  1:01                     ` Andrew Morton
2003-07-20  7:45                       ` Peter Osterlund
2003-07-18 21:05               ` Nigel Cunningham
2003-07-21 10:00   ` Peter Osterlund
2003-07-21 12:58     ` Pavel Machek
2003-07-21 14:36       ` Peter Osterlund
2003-07-21 21:28         ` Pavel Machek
2003-07-21 23:46           ` Peter Osterlund
2003-07-22 11:04             ` 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=m2el0nvnhm.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=akpm@osdl.org \
    --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 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.