From 6e8b708eb14ca90a08bf679ff4503ce3ec8effc1 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 31 Oct 2002 20:02:20 -0800 Subject: [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. --- include/linux/mmzone.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'include/linux') diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d80490b1265c..be4f03235e3d 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -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)))) -- cgit v1.2.3