linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: linux-mm@kvack.org
Cc: shangw@linux.vnet.ibm.com
Subject: [PATCH 1/2] MM: fixup on addition to bootmem data list
Date: Fri, 27 Apr 2012 11:41:43 +0800	[thread overview]
Message-ID: <1335498104-31900-1-git-send-email-shangw@linux.vnet.ibm.com> (raw)

The objects of "struct bootmem_data_t" are being linked together
to form double-linked list sequentially based on its minimal page
frame number. Current implementation implicitly supports the
following cases, which means the inserting point for current bootmem
data depends on how "list_for_each" works. That makes the code a
little hard to read. Besides, "list_for_each" and "list_entry" can
be replaced with "list_for_each_entry".

	- The linked list is empty.
	- There has no entry in the linked list, whose minimal page
	  frame number is bigger than current one.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 mm/bootmem.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 0131170..5a04536 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -77,16 +77,16 @@ unsigned long __init bootmem_bootmap_pages(unsigned long pages)
  */
 static void __init link_bootmem(bootmem_data_t *bdata)
 {
-	struct list_head *iter;
+	bootmem_data_t *ent;
 
-	list_for_each(iter, &bdata_list) {
-		bootmem_data_t *ent;
-
-		ent = list_entry(iter, bootmem_data_t, list);
-		if (bdata->node_min_pfn < ent->node_min_pfn)
-			break;
+	list_for_each_entry(ent, &bdata_list, list) {
+		if (bdata->node_min_pfn < ent->node_min_pfn) {
+			list_add_tail(&bdata->list, &ent->list);
+			return;
+		}
 	}
-	list_add_tail(&bdata->list, iter);
+
+	list_add_tail(&bdata->list, &bdata_list);
 }
 
 /*
-- 
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2012-04-27  3:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  3:41 Gavin Shan [this message]
2012-04-27  3:41 ` [PATCH 2/2] MM: check limit while deallocating bootmem node Gavin Shan
2012-04-27 23:27   ` Johannes Weiner
2012-04-28  1:58     ` Gavin Shan
2012-04-28  1:38   ` Gavin Shan
2012-04-28  2:00     ` Gavin Shan
2012-05-09 21:25 ` [PATCH 1/2] MM: fixup on addition to bootmem data list Johannes Weiner
2012-05-10  1:02   ` Gavin Shan

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=1335498104-31900-1-git-send-email-shangw@linux.vnet.ibm.com \
    --to=shangw@linux.vnet.ibm.com \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for NNTP newsgroup(s).