diff options
Diffstat (limited to 'include/linux/mmzone.h')
-rw-r--r-- | include/linux/mmzone.h | 91 |
1 files changed, 25 insertions, 66 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index ebfc238cc243..b5c21122c299 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/numa.h> | 13 | #include <linux/numa.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/seqlock.h> | 15 | #include <linux/seqlock.h> |
16 | #include <linux/nodemask.h> | ||
16 | #include <asm/atomic.h> | 17 | #include <asm/atomic.h> |
17 | 18 | ||
18 | /* Free memory management - zoned buddy allocator. */ | 19 | /* Free memory management - zoned buddy allocator. */ |
@@ -225,7 +226,6 @@ struct zone { | |||
225 | * Discontig memory support fields. | 226 | * Discontig memory support fields. |
226 | */ | 227 | */ |
227 | struct pglist_data *zone_pgdat; | 228 | struct pglist_data *zone_pgdat; |
228 | struct page *zone_mem_map; | ||
229 | /* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ | 229 | /* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ |
230 | unsigned long zone_start_pfn; | 230 | unsigned long zone_start_pfn; |
231 | 231 | ||
@@ -307,7 +307,6 @@ typedef struct pglist_data { | |||
307 | unsigned long node_spanned_pages; /* total size of physical page | 307 | unsigned long node_spanned_pages; /* total size of physical page |
308 | range, including holes */ | 308 | range, including holes */ |
309 | int node_id; | 309 | int node_id; |
310 | struct pglist_data *pgdat_next; | ||
311 | wait_queue_head_t kswapd_wait; | 310 | wait_queue_head_t kswapd_wait; |
312 | struct task_struct *kswapd; | 311 | struct task_struct *kswapd; |
313 | int kswapd_max_order; | 312 | int kswapd_max_order; |
@@ -324,8 +323,6 @@ typedef struct pglist_data { | |||
324 | 323 | ||
325 | #include <linux/memory_hotplug.h> | 324 | #include <linux/memory_hotplug.h> |
326 | 325 | ||
327 | extern struct pglist_data *pgdat_list; | ||
328 | |||
329 | void __get_zone_counts(unsigned long *active, unsigned long *inactive, | 326 | void __get_zone_counts(unsigned long *active, unsigned long *inactive, |
330 | unsigned long *free, struct pglist_data *pgdat); | 327 | unsigned long *free, struct pglist_data *pgdat); |
331 | void get_zone_counts(unsigned long *active, unsigned long *inactive, | 328 | void get_zone_counts(unsigned long *active, unsigned long *inactive, |
@@ -350,57 +347,6 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); | |||
350 | */ | 347 | */ |
351 | #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) | 348 | #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) |
352 | 349 | ||
353 | /** | ||
354 | * for_each_pgdat - helper macro to iterate over all nodes | ||
355 | * @pgdat - pointer to a pg_data_t variable | ||
356 | * | ||
357 | * Meant to help with common loops of the form | ||
358 | * pgdat = pgdat_list; | ||
359 | * while(pgdat) { | ||
360 | * ... | ||
361 | * pgdat = pgdat->pgdat_next; | ||
362 | * } | ||
363 | */ | ||
364 | #define for_each_pgdat(pgdat) \ | ||
365 | for (pgdat = pgdat_list; pgdat; pgdat = pgdat->pgdat_next) | ||
366 | |||
367 | /* | ||
368 | * next_zone - helper magic for for_each_zone() | ||
369 | * Thanks to William Lee Irwin III for this piece of ingenuity. | ||
370 | */ | ||
371 | static inline struct zone *next_zone(struct zone *zone) | ||
372 | { | ||
373 | pg_data_t *pgdat = zone->zone_pgdat; | ||
374 | |||
375 | if (zone < pgdat->node_zones + MAX_NR_ZONES - 1) | ||
376 | zone++; | ||
377 | else if (pgdat->pgdat_next) { | ||
378 | pgdat = pgdat->pgdat_next; | ||
379 | zone = pgdat->node_zones; | ||
380 | } else | ||
381 | zone = NULL; | ||
382 | |||
383 | return zone; | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * for_each_zone - helper macro to iterate over all memory zones | ||
388 | * @zone - pointer to struct zone variable | ||
389 | * | ||
390 | * The user only needs to declare the zone variable, for_each_zone | ||
391 | * fills it in. This basically means for_each_zone() is an | ||
392 | * easier to read version of this piece of code: | ||
393 | * | ||
394 | * for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next) | ||
395 | * for (i = 0; i < MAX_NR_ZONES; ++i) { | ||
396 | * struct zone * z = pgdat->node_zones + i; | ||
397 | * ... | ||
398 | * } | ||
399 | * } | ||
400 | */ | ||
401 | #define for_each_zone(zone) \ | ||
402 | for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone)) | ||
403 | |||
404 | static inline int populated_zone(struct zone *zone) | 350 | static inline int populated_zone(struct zone *zone) |
405 | { | 351 | { |
406 | return (!!zone->present_pages); | 352 | return (!!zone->present_pages); |
@@ -472,6 +418,30 @@ extern struct pglist_data contig_page_data; | |||
472 | 418 | ||
473 | #endif /* !CONFIG_NEED_MULTIPLE_NODES */ | 419 | #endif /* !CONFIG_NEED_MULTIPLE_NODES */ |
474 | 420 | ||
421 | extern struct pglist_data *first_online_pgdat(void); | ||
422 | extern struct pglist_data *next_online_pgdat(struct pglist_data *pgdat); | ||
423 | extern struct zone *next_zone(struct zone *zone); | ||
424 | |||
425 | /** | ||
426 | * for_each_pgdat - helper macro to iterate over all nodes | ||
427 | * @pgdat - pointer to a pg_data_t variable | ||
428 | */ | ||
429 | #define for_each_online_pgdat(pgdat) \ | ||
430 | for (pgdat = first_online_pgdat(); \ | ||
431 | pgdat; \ | ||
432 | pgdat = next_online_pgdat(pgdat)) | ||
433 | /** | ||
434 | * for_each_zone - helper macro to iterate over all memory zones | ||
435 | * @zone - pointer to struct zone variable | ||
436 | * | ||
437 | * The user only needs to declare the zone variable, for_each_zone | ||
438 | * fills it in. | ||
439 | */ | ||
440 | #define for_each_zone(zone) \ | ||
441 | for (zone = (first_online_pgdat())->node_zones; \ | ||
442 | zone; \ | ||
443 | zone = next_zone(zone)) | ||
444 | |||
475 | #ifdef CONFIG_SPARSEMEM | 445 | #ifdef CONFIG_SPARSEMEM |
476 | #include <asm/sparsemem.h> | 446 | #include <asm/sparsemem.h> |
477 | #endif | 447 | #endif |
@@ -602,17 +572,6 @@ static inline struct mem_section *__pfn_to_section(unsigned long pfn) | |||
602 | return __nr_to_section(pfn_to_section_nr(pfn)); | 572 | return __nr_to_section(pfn_to_section_nr(pfn)); |
603 | } | 573 | } |
604 | 574 | ||
605 | #define pfn_to_page(pfn) \ | ||
606 | ({ \ | ||
607 | unsigned long __pfn = (pfn); \ | ||
608 | __section_mem_map_addr(__pfn_to_section(__pfn)) + __pfn; \ | ||
609 | }) | ||
610 | #define page_to_pfn(page) \ | ||
611 | ({ \ | ||
612 | page - __section_mem_map_addr(__nr_to_section( \ | ||
613 | page_to_section(page))); \ | ||
614 | }) | ||
615 | |||
616 | static inline int pfn_valid(unsigned long pfn) | 575 | static inline int pfn_valid(unsigned long pfn) |
617 | { | 576 | { |
618 | if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) | 577 | if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) |