Commit 6e8b708e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] create memblk_online_map

From Matthew Dobson.

Create and use memblk_online_map.

This patch creates a memblk_online_map, much like cpu_online_map.  It
also creates the standard helper functions, ie: memblk_online(),
num_online_memblks(), memblk_set_online(), memblk_set_offline().

This is used by driverFS topology to keep track of which memory blocks
are in the system and online.
parent ef890de6
......@@ -48,7 +48,7 @@ static int __init topology_init(void)
arch_register_node(i);
for (i = 0; i < NR_CPUS; i++)
if (cpu_possible(i)) arch_register_cpu(i);
for (i = 0; i < numnodes; i++)
for (i = 0; i < num_online_memblks(); i++)
arch_register_memblk(i);
return 0;
}
......
......@@ -279,6 +279,38 @@ extern struct pglist_data contig_page_data;
#endif /* !CONFIG_DISCONTIGMEM */
extern DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS);
#if defined(CONFIG_DISCONTIGMEM) || defined(CONFIG_NUMA)
#define memblk_online(memblk) test_bit(memblk, memblk_online_map)
#define memblk_set_online(memblk) set_bit(memblk, memblk_online_map)
#define memblk_set_offline(memblk) clear_bit(memblk, memblk_online_map)
static inline unsigned int num_online_memblks(void)
{
int i, num = 0;
for(i = 0; i < MAX_NR_MEMBLKS; i++){
if (memblk_online(i))
num++;
}
return num;
}
#else /* !CONFIG_DISCONTIGMEM && !CONFIG_NUMA */
#define memblk_online(memblk) \
({ BUG_ON((memblk) != 0); test_bit(memblk, memblk_online_map); })
#define memblk_set_online(memblk) \
({ BUG_ON((memblk) != 0); set_bit(memblk, memblk_online_map); })
#define memblk_set_offline(memblk) \
({ BUG_ON((memblk) != 0); clear_bit(memblk, memblk_online_map); })
#define num_online_memblks() 1
#endif /* CONFIG_DISCONTIGMEM || CONFIG_NUMA */
#define MAP_ALIGN(x) ((((x) % sizeof(struct page)) == 0) ? (x) : ((x) + \
sizeof(struct page) - ((x) % sizeof(struct page))))
......
......@@ -29,6 +29,9 @@
#include <linux/slab.h>
#include <linux/notifier.h>
#include <asm/topology.h>
DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS);
struct pglist_data *pgdat_list;
unsigned long totalram_pages;
unsigned long totalhigh_pages;
......@@ -1164,6 +1167,7 @@ void __init free_area_init_node(int nid, struct pglist_data *pgdat,
pgdat->node_mem_map = node_mem_map;
free_area_init_core(pgdat, zones_size, zholes_size);
memblk_set_online(__node_to_memblk(nid));
calculate_zone_bitmap(pgdat, zones_size);
}
......
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