From: Andy Whitcroft <apw@shadowen.org>
To: haveblue@us.ibm.com, lhms-devel@lists.sourceforge.net
Cc: linux-mm@kvack.org, apw@shadowen.org
Subject: [4/7] 100 cleanup node zone
Date: Thu, 28 Oct 2004 15:26:11 +0100 [thread overview]
Message-ID: <E1CNBEB-0006bj-B6@ladymac.shadowen.org> (raw)
In-Reply-To: <1098973549.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>
reply other threads:[~2004-10-28 14:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E1CNBEB-0006bj-B6@ladymac.shadowen.org \
--to=apw@shadowen.org \
--cc=haveblue@us.ibm.com \
--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