Commit 79a96230 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] discontigmem code cleanup #1

Patch from Martin Bligh.

"This mainly changes the PLAT_MY_MACRO_IS_ALL_CAPS() stuff to be
 normal_macro(), and takes out some unnecessary redirection of function
 names.  No functionality changes, nothing touched outside i386
 discontigmem ...  just makes code readable.  Rumour has it that the
 PLAT_* stuff came from IRIX - I don't see that as a good reason to make
 the Linux code unreadable.  Tested on 16-way NUMA-Q."
parent 1f90eedd
...@@ -83,7 +83,7 @@ int physnode_map[MAX_ELEMENTS] = { [0 ... (MAX_ELEMENTS - 1)] = -1}; ...@@ -83,7 +83,7 @@ int physnode_map[MAX_ELEMENTS] = { [0 ... (MAX_ELEMENTS - 1)] = -1};
#define MB_TO_ELEMENT(x) (x >> ELEMENT_REPRESENTS) #define MB_TO_ELEMENT(x) (x >> ELEMENT_REPRESENTS)
#define PA_TO_MB(pa) (pa >> 20) /* assumption: a physical address is in bytes */ #define PA_TO_MB(pa) (pa >> 20) /* assumption: a physical address is in bytes */
int numaqpa_to_nid(u64 pa) int pa_to_nid(u64 pa)
{ {
int nid; int nid;
...@@ -96,9 +96,9 @@ int numaqpa_to_nid(u64 pa) ...@@ -96,9 +96,9 @@ int numaqpa_to_nid(u64 pa)
return nid; return nid;
} }
int numaqpfn_to_nid(unsigned long pfn) int pfn_to_nid(unsigned long pfn)
{ {
return numaqpa_to_nid(((u64)pfn) << PAGE_SHIFT); return pa_to_nid(((u64)pfn) << PAGE_SHIFT);
} }
/* /*
......
...@@ -39,7 +39,7 @@ struct pfns { ...@@ -39,7 +39,7 @@ struct pfns {
unsigned long max_pfn; unsigned long max_pfn;
}; };
struct plat_pglist_data *plat_node_data[MAX_NUMNODES]; struct pglist_data *node_data[MAX_NUMNODES];
bootmem_data_t plat_node_bdata; bootmem_data_t plat_node_bdata;
struct pfns plat_node_bootpfns[MAX_NUMNODES]; struct pfns plat_node_bootpfns[MAX_NUMNODES];
...@@ -74,8 +74,8 @@ static void __init find_max_pfn_node(int nid) ...@@ -74,8 +74,8 @@ static void __init find_max_pfn_node(int nid)
} }
plat_node_bootpfns[nid].max_pfn = end; plat_node_bootpfns[nid].max_pfn = end;
node_datasz = PFN_UP(sizeof(struct plat_pglist_data)); node_datasz = PFN_UP(sizeof(struct pglist_data));
PLAT_NODE_DATA(nid) = (struct plat_pglist_data *)(__va(min_low_pfn << PAGE_SHIFT)); NODE_DATA(nid) = (struct pglist_data *)(__va(min_low_pfn << PAGE_SHIFT));
min_low_pfn += node_datasz; min_low_pfn += node_datasz;
} }
...@@ -289,7 +289,7 @@ void __init set_max_mapnr_init(void) ...@@ -289,7 +289,7 @@ void __init set_max_mapnr_init(void)
num_physpages = highend_pfn; num_physpages = highend_pfn;
for (nid = 0; nid < numnodes; nid++) { for (nid = 0; nid < numnodes; nid++) {
lmax_mapnr = PLAT_NODE_DATA_STARTNR(nid) + PLAT_NODE_DATA_SIZE(nid); lmax_mapnr = node_startnr(nid) + node_size(nid);
if (lmax_mapnr > max_mapnr) { if (lmax_mapnr > max_mapnr) {
max_mapnr = lmax_mapnr; max_mapnr = lmax_mapnr;
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#ifdef CONFIG_X86_NUMAQ #ifdef CONFIG_X86_NUMAQ
#include <asm/numaq.h> #include <asm/numaq.h>
#else #else
#define PHYSADDR_TO_NID(pa) (0) #define pa_to_nid(pa) (0)
#define PFN_TO_NID(pfn) (0) #define pfn_to_nid(pfn) (0)
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
#define _cpu_to_node(cpu) 0 #define _cpu_to_node(cpu) 0
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
...@@ -22,11 +22,7 @@ ...@@ -22,11 +22,7 @@
#define numa_node_id() _cpu_to_node(smp_processor_id()) #define numa_node_id() _cpu_to_node(smp_processor_id())
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
struct plat_pglist_data { extern struct pglist_data *node_data[];
pg_data_t gendata;
};
extern struct plat_pglist_data *plat_node_data[];
/* /*
* Following are macros that are specific to this numa platform. * Following are macros that are specific to this numa platform.
...@@ -48,12 +44,9 @@ extern struct plat_pglist_data *plat_node_data[]; ...@@ -48,12 +44,9 @@ extern struct plat_pglist_data *plat_node_data[];
#define alloc_bootmem_low_pages_node(ignore, x) \ #define alloc_bootmem_low_pages_node(ignore, x) \
__alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
#define PLAT_NODE_DATA(n) (plat_node_data[(n)]) #define node_startnr(nid) (node_data[nid]->node_start_mapnr)
#define PLAT_NODE_DATA_STARTNR(n) \ #define node_size(nid) (node_data[nid]->node_size)
(PLAT_NODE_DATA(n)->gendata.node_start_mapnr) #define node_localnr(pfn, nid) ((pfn) - node_data[nid]->node_start_pfn)
#define PLAT_NODE_DATA_SIZE(n) (PLAT_NODE_DATA(n)->gendata.node_size)
#define PLAT_NODE_DATA_LOCALNR(pfn, n) \
((pfn) - PLAT_NODE_DATA(n)->gendata.node_start_pfn)
/* /*
* Following are macros that each numa implmentation must define. * Following are macros that each numa implmentation must define.
...@@ -62,39 +55,23 @@ extern struct plat_pglist_data *plat_node_data[]; ...@@ -62,39 +55,23 @@ extern struct plat_pglist_data *plat_node_data[];
/* /*
* Given a kernel address, find the home node of the underlying memory. * Given a kernel address, find the home node of the underlying memory.
*/ */
#define KVADDR_TO_NID(kaddr) PHYSADDR_TO_NID(__pa(kaddr)) #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
/* /*
* Return a pointer to the node data for node n. * Return a pointer to the node data for node n.
*/ */
#define NODE_DATA(n) (&((PLAT_NODE_DATA(n))->gendata)) #define NODE_DATA(nid) (node_data[nid])
/* #define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
* NODE_MEM_MAP gives the kaddr for the mem_map of the node. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
*/
#define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map)
/*
* Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
* and returns the the mem_map of that node.
*/
#define ADDR_TO_MAPBASE(kaddr) \
NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr)))
/*
* Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
* and returns the kaddr corresponding to first physical page in the
* node's mem_map.
*/
#define LOCAL_BASE_ADDR(kaddr) ((unsigned long)__va(NODE_DATA(KVADDR_TO_NID(kaddr))->node_start_pfn << PAGE_SHIFT))
#define LOCAL_MAP_NR(kvaddr) \ #define local_mapnr(kvaddr) \
(((unsigned long)(kvaddr)-LOCAL_BASE_ADDR(kvaddr)) >> PAGE_SHIFT) ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) )
#define kern_addr_valid(kaddr) test_bit(LOCAL_MAP_NR(kaddr), \ #define kern_addr_valid(kaddr) test_bit(local_mapnr(kaddr), \
NODE_DATA(KVADDR_TO_NID(kaddr))->valid_addr_bitmap) NODE_DATA(kvaddr_to_nid(kaddr))->valid_addr_bitmap)
#define pfn_to_page(pfn) (NODE_MEM_MAP(PFN_TO_NID(pfn)) + PLAT_NODE_DATA_LOCALNR(pfn, PFN_TO_NID(pfn))) #define pfn_to_page(pfn) (node_mem_map(pfn_to_nid(pfn)) + node_localnr(pfn, pfn_to_nid(pfn)))
#define page_to_pfn(page) ((page - page_zone(page)->zone_mem_map) + page_zone(page)->zone_start_pfn) #define page_to_pfn(page) ((page - page_zone(page)->zone_mem_map) + page_zone(page)->zone_start_pfn)
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
#endif /* CONFIG_DISCONTIGMEM */ #endif /* CONFIG_DISCONTIGMEM */
......
...@@ -38,14 +38,12 @@ ...@@ -38,14 +38,12 @@
#define MAX_ELEMENTS 256 #define MAX_ELEMENTS 256
#define ELEMENT_REPRESENTS 8 /* 256 Mb */ #define ELEMENT_REPRESENTS 8 /* 256 Mb */
#define PHYSADDR_TO_NID(pa) numaqpa_to_nid(pa)
#define PFN_TO_NID(pa) numaqpfn_to_nid(pa)
#define MAX_NUMNODES 8 #define MAX_NUMNODES 8
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
#define _cpu_to_node(cpu) (cpu_to_logical_apicid(cpu) >> 4) #define _cpu_to_node(cpu) (cpu_to_logical_apicid(cpu) >> 4)
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
extern int numaqpa_to_nid(u64); extern int pa_to_nid(u64);
extern int numaqpfn_to_nid(unsigned long); extern int pfn_to_nid(unsigned long);
extern void get_memcfg_numaq(void); extern void get_memcfg_numaq(void);
#define get_memcfg_numa() get_memcfg_numaq() #define get_memcfg_numa() get_memcfg_numaq()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment