public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: torvalds@transmeta.com, kernel list <linux-kernel@vger.kernel.org>
Cc: wli@holomorphy.com
Subject: swsusp: cleanup -- use list_for_each in head_of_free_region
Date: Tue, 28 May 2002 21:33:57 +0200	[thread overview]
Message-ID: <20020528193357.GA801@elf.ucw.cz> (raw)

Hi!

This cleans up is_head_of_free_region, thanks to William Lee Irwin III
<wli@holomorphy.com>. Please apply,

									Pavel

--- linux-swsusp.test//mm/page_alloc.c	Sun May 26 19:32:05 2002
+++ linux-swsusp/mm/page_alloc.c	Tue May 28 21:19:26 2002
@@ -249,42 +249,31 @@
 }
 
 #ifdef CONFIG_SOFTWARE_SUSPEND
-int is_head_of_free_region(struct page *p)
+int is_head_of_free_region(struct page *page)
 {
-	pg_data_t *pgdat = pgdat_list;
-	unsigned type;
-	unsigned long flags;
+        zone_t *zone, *node_zones = pgdat_list->node_zones;
+        unsigned long flags;
 
-	for (type=0;type < MAX_NR_ZONES; type++) {
-		zone_t *zone = pgdat->node_zones + type;
-		int order = MAX_ORDER - 1;
-		free_area_t *area;
-		struct list_head *head, *curr;
-		spin_lock_irqsave(&zone->lock, flags);	/* Should not matter as we need quiescent system for suspend anyway, but... */
+        for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
+                int order;
+                list_t *curr;
 
-		do {
-			area = zone->free_area + order;
-			head = &area->free_list;
-			curr = head;
-
-			for(;;) {
-				if(!curr) {
-//					printk("FIXME: this should not happen but it does!!!");
+                /*
+                 * Should not matter as we need quiescent system for
+                 * suspend anyway, but...
+                 */
+                spin_lock_irqsave(&zone->lock, flags);
+                for (order = MAX_ORDER - 1; order >= 0; --order)
+                        list_for_each(curr, &zone->free_area[order].free_list) {
+				if (!curr)
 					break;
-				}
-				if(p != memlist_entry(curr, struct page, list)) {
-					curr = memlist_next(curr);
-					if (curr == head)
-						break;
-					continue;
-				}
-				return 1 << order;
+                                if (page == list_entry(curr, struct page, list))
+                                        return 1 << order;
 			}
-		} while(order--);
-		spin_unlock_irqrestore(&zone->lock, flags);
+                spin_unlock_irqrestore(&zone->lock, flags);
 
-	}
-	return 0;
+        }
+        return 0;
 }
 #endif /* CONFIG_SOFTWARE_SUSPEND */
 



-- 
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa

             reply	other threads:[~2002-05-28 20:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-28 19:33 Pavel Machek [this message]
2002-05-28 21:03 ` swsusp: cleanup -- use list_for_each in head_of_free_region William Lee Irwin III
2002-05-28 21:13   ` Pavel Machek
2002-05-28 22:08 ` DO NOT APPLY " 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=20020528193357.GA801@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=wli@holomorphy.com \
    /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