From: Tejun Heo <tj@kernel.org>
To: mingo@redhat.com, yinghai@kernel.org, rientjes@google.com,
tglx@linutronix.de, hpa@zytor.com, x86@kernel.org,
linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 18/25] x86, NUMA: Remove long 64bit assumption from numa.c
Date: Fri, 29 Apr 2011 17:28:37 +0200 [thread overview]
Message-ID: <1304090924-8197-19-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1304090924-8197-1-git-send-email-tj@kernel.org>
Code moved from numa_64.c has assumption that long is 64bit in several
places. This patch removes the assumption by using {s|u}64_t
explicity, using PFN_PHYS() for page number -> addr conversions and
adjusting printf formats.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/mm/numa.c | 45 ++++++++++++++++++++++-----------------------
1 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 22dc9ed..b2fca54 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -192,13 +192,12 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
#endif
/* Initialize bootmem allocator for a node */
-static void __init
-setup_node_bootmem(int nid, unsigned long start, unsigned long end)
+static void __init setup_node_bootmem(int nid, u64 start, u64 end)
{
- const u64 nd_low = (u64)MAX_DMA_PFN << PAGE_SHIFT;
- const u64 nd_high = (u64)max_pfn_mapped << PAGE_SHIFT;
+ const u64 nd_low = PFN_PHYS(MAX_DMA_PFN);
+ const u64 nd_high = PFN_PHYS(max_pfn_mapped);
const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
- unsigned long nd_pa;
+ u64 nd_pa;
int tnid;
/*
@@ -210,7 +209,7 @@ setup_node_bootmem(int nid, unsigned long start, unsigned long end)
start = roundup(start, ZONE_ALIGN);
- printk(KERN_INFO "Initmem setup node %d %016lx-%016lx\n",
+ printk(KERN_INFO "Initmem setup node %d %016Lx-%016Lx\n",
nid, start, end);
/*
@@ -223,13 +222,13 @@ setup_node_bootmem(int nid, unsigned long start, unsigned long end)
nd_pa = memblock_find_in_range(nd_low, nd_high,
nd_size, SMP_CACHE_BYTES);
if (nd_pa == MEMBLOCK_ERROR) {
- pr_err("Cannot find %lu bytes in node %d\n", nd_size, nid);
+ pr_err("Cannot find %zu bytes in node %d\n", nd_size, nid);
return;
}
memblock_x86_reserve_range(nd_pa, nd_pa + nd_size, "NODE_DATA");
/* report and initialize */
- printk(KERN_INFO " NODE_DATA [%016lx - %016lx]\n",
+ printk(KERN_INFO " NODE_DATA [%016Lx - %016Lx]\n",
nd_pa, nd_pa + nd_size - 1);
tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT);
if (tnid != nid)
@@ -257,7 +256,7 @@ setup_node_bootmem(int nid, unsigned long start, unsigned long end)
int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
{
const u64 low = 0;
- const u64 high = (u64)max_pfn << PAGE_SHIFT;
+ const u64 high = PFN_PHYS(max_pfn);
int i, j, k;
for (i = 0; i < mi->nr_blks; i++) {
@@ -275,7 +274,7 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
for (j = i + 1; j < mi->nr_blks; j++) {
struct numa_memblk *bj = &mi->blk[j];
- unsigned long start, end;
+ u64 start, end;
/*
* See whether there are overlapping blocks. Whine
@@ -313,7 +312,7 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
}
if (k < mi->nr_blks)
continue;
- printk(KERN_INFO "NUMA: Node %d [%Lx,%Lx) + [%Lx,%Lx) -> [%lx,%lx)\n",
+ printk(KERN_INFO "NUMA: Node %d [%Lx,%Lx) + [%Lx,%Lx) -> [%Lx,%Lx)\n",
bi->nid, bi->start, bi->end, bj->start, bj->end,
start, end);
bi->start = start;
@@ -378,7 +377,7 @@ static int __init numa_alloc_distance(void)
cnt++;
size = cnt * cnt * sizeof(numa_distance[0]);
- phys = memblock_find_in_range(0, (u64)max_pfn_mapped << PAGE_SHIFT,
+ phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
size, PAGE_SIZE);
if (phys == MEMBLOCK_ERROR) {
pr_warning("NUMA: Warning: can't allocate distance table!\n");
@@ -456,24 +455,24 @@ EXPORT_SYMBOL(__node_distance);
*/
static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
{
- unsigned long numaram, e820ram;
+ u64 numaram, e820ram;
int i;
numaram = 0;
for (i = 0; i < mi->nr_blks; i++) {
- unsigned long s = mi->blk[i].start >> PAGE_SHIFT;
- unsigned long e = mi->blk[i].end >> PAGE_SHIFT;
+ u64 s = mi->blk[i].start >> PAGE_SHIFT;
+ u64 e = mi->blk[i].end >> PAGE_SHIFT;
numaram += e - s;
numaram -= __absent_pages_in_range(mi->blk[i].nid, s, e);
- if ((long)numaram < 0)
+ if ((s64)numaram < 0)
numaram = 0;
}
e820ram = max_pfn - (memblock_x86_hole_size(0,
- max_pfn << PAGE_SHIFT) >> PAGE_SHIFT);
+ PFN_PHYS(max_pfn)) >> PAGE_SHIFT);
/* We seem to lose 3 pages somewhere. Allow 1M of slack. */
- if ((long)(e820ram - numaram) >= (1 << (20 - PAGE_SHIFT))) {
- printk(KERN_ERR "NUMA: nodes only cover %luMB of your %luMB e820 RAM. Not used.\n",
+ if ((s64)(e820ram - numaram) >= (1 << (20 - PAGE_SHIFT))) {
+ printk(KERN_ERR "NUMA: nodes only cover %LuMB of your %LuMB e820 RAM. Not used.\n",
(numaram << PAGE_SHIFT) >> 20,
(e820ram << PAGE_SHIFT) >> 20);
return false;
@@ -503,7 +502,7 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
/* Finally register nodes. */
for_each_node_mask(nid, node_possible_map) {
- u64 start = (u64)max_pfn << PAGE_SHIFT;
+ u64 start = PFN_PHYS(max_pfn);
u64 end = 0;
for (i = 0; i < mi->nr_blks; i++) {
@@ -595,11 +594,11 @@ static int __init dummy_numa_init(void)
{
printk(KERN_INFO "%s\n",
numa_off ? "NUMA turned off" : "No NUMA configuration found");
- printk(KERN_INFO "Faking a node at %016lx-%016lx\n",
- 0LU, max_pfn << PAGE_SHIFT);
+ printk(KERN_INFO "Faking a node at %016Lx-%016Lx\n",
+ 0LLU, PFN_PHYS(max_pfn));
node_set(0, numa_nodes_parsed);
- numa_add_memblk(0, 0, (u64)max_pfn << PAGE_SHIFT);
+ numa_add_memblk(0, 0, PFN_PHYS(max_pfn));
return 0;
}
--
1.7.1
next prev parent reply other threads:[~2011-04-29 15:31 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 15:28 [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Tejun Heo
2011-04-29 15:28 ` [PATCH 01/25] x86-64, NUMA: Simplify hotadd memory handling Tejun Heo
2011-04-29 15:28 ` [PATCH 02/25] x86-64, NUMA: trivial cleanups for setup_node_bootmem() Tejun Heo
2011-04-29 15:28 ` [PATCH 03/25] x86-64, NUMA: simplify nodedata allocation Tejun Heo
2011-04-29 17:23 ` Yinghai Lu
2011-04-30 12:02 ` Tejun Heo
2011-04-29 15:28 ` [PATCH 04/25] x86-32, NUMA: Automatically set apicid -> node in setup_local_APIC() Tejun Heo
2011-04-29 15:28 ` [PATCH 05/25] x86, NUMA: Unify 32/64bit numa_cpu_node() implementation Tejun Heo
2011-04-29 15:28 ` [PATCH 06/25] x86-32, NUMA: Make apic->x86_32_numa_cpu_node() optional Tejun Heo
2011-04-29 15:28 ` [PATCH 07/25] x86-32, NUMA: use sparse_memory_present_with_active_regions() Tejun Heo
2011-04-29 15:28 ` [PATCH 08/25] x86, NUMA: trivial cleanups Tejun Heo
2011-04-29 17:25 ` Yinghai Lu
2011-04-30 12:03 ` Tejun Heo
2011-04-30 16:24 ` Yinghai Lu
2011-04-30 18:00 ` Tejun Heo
2011-04-30 23:10 ` Yinghai Lu
2011-04-30 23:11 ` [PATCH] x86, numa: Rename setup_node_bootmem to setup_node_data Yinghai Lu
2011-04-29 15:28 ` [PATCH 09/25] x86, NUMA: rename srat_64.c to srat.c Tejun Heo
2011-04-29 15:28 ` [PATCH 10/25] x86, NUMA: make srat.c 32bit safe Tejun Heo
2011-04-29 15:28 ` [PATCH 11/25] x86-32, NUMA: Move get_memcfg_numa() into numa_32.c Tejun Heo
2011-04-29 15:28 ` [PATCH 12/25] x86, NUMA: Move numa_nodes_parsed to numa.[hc] Tejun Heo
2011-04-29 15:28 ` [PATCH 13/25] x86-32, NUMA: implement temporary NUMA init shims Tejun Heo
2011-04-29 15:28 ` [PATCH 14/25] x86-32, NUMA: Replace srat_32.c with srat.c Tejun Heo
2011-04-29 15:28 ` [PATCH 15/25] x86-32, NUMA: Update numaq to use new NUMA init protocol Tejun Heo
2011-04-29 15:28 ` [PATCH 16/25] x86, NUMA: Move NUMA init logic from numa_64.c to numa.c Tejun Heo
2011-04-29 15:28 ` [PATCH 17/25] x86, NUMA: Enable build of generic NUMA init code on 32bit Tejun Heo
2011-04-29 15:28 ` Tejun Heo [this message]
2011-04-29 15:28 ` [PATCH 19/25] x86-32, NUMA: Add @start and @end to init_alloc_remap() Tejun Heo
2011-04-29 15:28 ` [PATCH 20/25] x86, NUMA: Initialize and use remap allocator from setup_node_bootmem() Tejun Heo
2011-04-29 15:28 ` [PATCH 21/25] x86, NUMA: Make 32bit use common NUMA init path Tejun Heo
2011-04-29 15:28 ` [PATCH 22/25] x86, NUMA: Make numa_init_array() static Tejun Heo
2011-04-29 15:28 ` [PATCH 23/25] x86, NUMA: Rename amdtopology_64.c to amdtopology.c Tejun Heo
2011-04-29 15:28 ` [PATCH 24/25] x86, NUMA: Enable CONFIG_AMD_NUMA on 32bit too Tejun Heo
2011-04-29 15:28 ` [PATCH 25/25] x86, NUMA: Enable emulation " Tejun Heo
2011-04-29 18:15 ` [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Ingo Molnar
2011-04-29 20:14 ` Yinghai Lu
2011-04-30 12:17 ` Tejun Heo
2011-04-30 12:33 ` [PATCH] x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo() Tejun Heo
2011-04-30 12:35 ` Tejun Heo
2011-05-01 0:43 ` Yinghai Lu
2011-05-01 10:20 ` Tejun Heo
2011-05-01 19:44 ` [PATCH] x86, numa: Trim numa meminfo with max_pfn in separated loop Yinghai Lu
2011-04-30 16:31 ` [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Yinghai Lu
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=1304090924-8197-19-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rientjes@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@kernel.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 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.