linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@shadowen.org>
To: apw@shadowen.org, lhms-devel@lists.sourceforge.net, linux-mm@kvack.org
Subject: 100 cleanup node zone
Date: Mon, 18 Oct 2004 15:35:20 +0100	[thread overview]
Message-ID: <E1CJYbY-0000aC-5j@ladymac.shadowen.org> (raw)
In-Reply-To: <4173D219.3010706@shadowen.org>

diffstat 100-cleanup-node-zone
---
 mm.h     |   43 ++++++++++++++++++++++++++++++++++++-------
 mmzone.h |   16 +++-------------
 2 files changed, 39 insertions(+), 20 deletions(-)

diff -upN reference/include/linux/mm.h current/include/linux/mm.h
--- reference/include/linux/mm.h
+++ current/include/linux/mm.h
@@ -376,16 +376,41 @@ static inline void put_page(struct page 
  * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total,
  * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits.
  */
-#define NODEZONE_SHIFT (sizeof(page_flags_t)*8 - MAX_NODES_SHIFT - MAX_ZONES_SHIFT)
-#define NODEZONE(node, zone)	((node << ZONES_SHIFT) | zone)
+
+#define FLAGS_SHIFT	(sizeof(page_flags_t)*8)
+
+/* 32bit: NODE:ZONE */
+#define PGFLAGS_NODES_SHIFT	(FLAGS_SHIFT - NODES_SHIFT)
+#define PGFLAGS_ZONES_SHIFT	(PGFLAGS_NODES_SHIFT - ZONES_SHIFT)
+
+#define ZONETABLE_SHIFT		(NODES_SHIFT + ZONES_SHIFT)
+#define PGFLAGS_ZONETABLE_SHIFT	(FLAGS_SHIFT - ZONETABLE_SHIFT)
+
+#if NODES_SHIFT+ZONES_SHIFT > FLAGS_TOTAL_SHIFT
+#error NODES_SHIFT+ZONES_SHIFT > FLAGS_TOTAL_SHIFT
+#endif
+
+#define NODEZONE(node, zone)		((node << ZONES_SHIFT) | zone)
+
+#define ZONES_MASK		(~((~0UL) << ZONES_SHIFT))
+#define NODES_MASK		(~((~0UL) << NODES_SHIFT))
+#define ZONETABLE_MASK		(~((~0UL) << ZONETABLE_SHIFT))
+
+#define PGFLAGS_MASK		(~((~0UL) << PGFLAGS_ZONETABLE_SHIFT)
 
 static inline unsigned long page_zonenum(struct page *page)
 {
-	return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT));
+	if (FLAGS_SHIFT == (PGFLAGS_ZONES_SHIFT + ZONES_SHIFT))
+ 		return (page->flags >> PGFLAGS_ZONES_SHIFT);
+ 	else
+ 		return (page->flags >> PGFLAGS_ZONES_SHIFT) & ZONES_MASK;
 }
 static inline unsigned long page_to_nid(struct page *page)
 {
-	return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT));
+	if (FLAGS_SHIFT == (PGFLAGS_NODES_SHIFT + NODES_SHIFT))
+		return (page->flags >> PGFLAGS_NODES_SHIFT);
+	else
+		return (page->flags >> PGFLAGS_NODES_SHIFT) & NODES_MASK;
 }
 
 struct zone;
@@ -393,13 +418,17 @@ extern struct zone *zone_table[];
 
 static inline struct zone *page_zone(struct page *page)
 {
-	return zone_table[page->flags >> NODEZONE_SHIFT];
+	if (FLAGS_SHIFT == (PGFLAGS_ZONETABLE_SHIFT + ZONETABLE_SHIFT))
+		return zone_table[page->flags >> PGFLAGS_ZONETABLE_SHIFT];
+	else
+		return zone_table[page->flags >> PGFLAGS_ZONETABLE_SHIFT &
+			ZONETABLE_MASK];
 }
 
 static inline void set_page_zone(struct page *page, unsigned long nodezone_num)
 {
-	page->flags &= ~(~0UL << NODEZONE_SHIFT);
-	page->flags |= nodezone_num << NODEZONE_SHIFT;
+	page->flags &= PGFLAGS_MASK;
+	page->flags |= nodezone_num << PGFLAGS_ZONETABLE_SHIFT;
 }
 
 #ifndef CONFIG_DISCONTIGMEM
diff -upN reference/include/linux/mmzone.h current/include/linux/mmzone.h
--- reference/include/linux/mmzone.h
+++ current/include/linux/mmzone.h
@@ -389,27 +389,17 @@ extern struct pglist_data contig_page_da
  * with 32 bit page->flags field, we reserve 8 bits for node/zone info.
  * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
  */
-#define MAX_NODES_SHIFT		6
+#define FLAGS_TOTAL_SHIFT	8
+
 #elif BITS_PER_LONG == 64
 /*
  * with 64 bit flags field, there's plenty of room.
  */
-#define MAX_NODES_SHIFT		10
+#define FLAGS_TOTAL_SHIFT	12
 #endif
 
 #endif /* !CONFIG_DISCONTIGMEM */
 
-#if NODES_SHIFT > MAX_NODES_SHIFT
-#error NODES_SHIFT > MAX_NODES_SHIFT
-#endif
-
-/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */
-#define MAX_ZONES_SHIFT		2
-
-#if ZONES_SHIFT > MAX_ZONES_SHIFT
-#error ZONES_SHIFT > MAX_ZONES_SHIFT
-#endif
-
 extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
 
 #if defined(CONFIG_DISCONTIGMEM) || defined(CONFIG_NUMA)

--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  parent reply	other threads:[~2004-10-18 14:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 14:24 CONFIG_NONLINEAR for small systems Andy Whitcroft
2004-10-18 14:32 ` 050 bootmem use NODE_DATA Andy Whitcroft
2004-10-26 18:16   ` Dave Hansen
2004-10-18 14:33 ` 060 refactor setup_memory i386 Andy Whitcroft
2004-10-18 14:34 ` 080 alloc_remap i386 Andy Whitcroft
2004-10-18 14:35 ` Andy Whitcroft [this message]
2004-10-18 14:35 ` 150 nonlinear Andy Whitcroft
2004-10-26 18:36   ` Dave Hansen
2004-10-26 19:07     ` [Lhms-devel] " Mika Penttilä
2004-10-26 19:42       ` Dave Hansen
2004-10-26 20:41         ` Mika Penttilä
2004-10-26 20:55           ` Dave Hansen
2004-10-26 21:20             ` Mika Penttilä
2004-10-26 21:27               ` Dave Hansen
2004-10-26 21:38                 ` Mika Penttilä
2004-10-26 21:41                   ` Dave Hansen
2004-10-26 21:55                     ` Mika Penttilä
2004-10-26 21:53                       ` Dave Hansen
2004-10-26 22:01                         ` Mika Penttilä
2004-10-28 11:07     ` Andy Whitcroft
2004-10-18 14:36 ` 160 nonlinear i386 Andy Whitcroft
2004-10-18 14:36 ` 170 nonlinear ppc64 Andy Whitcroft
2004-10-18 15:17 ` [Lhms-devel] CONFIG_NONLINEAR for small systems Hirokazu Takahashi
2004-10-18 15:29   ` Andy Whitcroft
2004-10-19  4:30 ` Hiroyuki KAMEZAWA
2004-10-19  8:16   ` Andy Whitcroft

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=E1CJYbY-0000aC-5j@ladymac.shadowen.org \
    --to=apw@shadowen.org \
    --cc=lhms-devel@lists.sourceforge.net \
    --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