diff options
Diffstat (limited to 'include/linux/mmzone.h')
| -rw-r--r-- | include/linux/mmzone.h | 25 | 
1 files changed, 21 insertions, 4 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 6c90461ed99f..5ed471b58f4f 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h  | |||
| @@ -487,11 +487,27 @@ struct mem_section { | |||
| 487 | unsigned long section_mem_map; | 487 | unsigned long section_mem_map; | 
| 488 | }; | 488 | }; | 
| 489 | 489 | ||
| 490 | extern struct mem_section mem_section[NR_MEM_SECTIONS]; | 490 | #ifdef CONFIG_SPARSEMEM_EXTREME | 
| 491 | #define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section)) | ||
| 492 | #else | ||
| 493 | #define SECTIONS_PER_ROOT 1 | ||
| 494 | #endif | ||
| 495 | |||
| 496 | #define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT) | ||
| 497 | #define NR_SECTION_ROOTS (NR_MEM_SECTIONS / SECTIONS_PER_ROOT) | ||
| 498 | #define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1) | ||
| 499 | |||
| 500 | #ifdef CONFIG_SPARSEMEM_EXTREME | ||
| 501 | extern struct mem_section *mem_section[NR_SECTION_ROOTS]; | ||
| 502 | #else | ||
| 503 | extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]; | ||
| 504 | #endif | ||
| 491 | 505 | ||
| 492 | static inline struct mem_section *__nr_to_section(unsigned long nr) | 506 | static inline struct mem_section *__nr_to_section(unsigned long nr) | 
| 493 | { | 507 | { | 
| 494 | return &mem_section[nr]; | 508 | if (!mem_section[SECTION_NR_TO_ROOT(nr)]) | 
| 509 | return NULL; | ||
| 510 | return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; | ||
| 495 | } | 511 | } | 
| 496 | 512 | ||
| 497 | /* | 513 | /* | 
| @@ -513,12 +529,12 @@ static inline struct page *__section_mem_map_addr(struct mem_section *section) | |||
| 513 | 529 | ||
| 514 | static inline int valid_section(struct mem_section *section) | 530 | static inline int valid_section(struct mem_section *section) | 
| 515 | { | 531 | { | 
| 516 | return (section->section_mem_map & SECTION_MARKED_PRESENT); | 532 | return (section && (section->section_mem_map & SECTION_MARKED_PRESENT)); | 
| 517 | } | 533 | } | 
| 518 | 534 | ||
| 519 | static inline int section_has_mem_map(struct mem_section *section) | 535 | static inline int section_has_mem_map(struct mem_section *section) | 
| 520 | { | 536 | { | 
| 521 | return (section->section_mem_map & SECTION_HAS_MEM_MAP); | 537 | return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP)); | 
| 522 | } | 538 | } | 
| 523 | 539 | ||
| 524 | static inline int valid_section_nr(unsigned long nr) | 540 | static inline int valid_section_nr(unsigned long nr) | 
| @@ -572,6 +588,7 @@ static inline int pfn_valid(unsigned long pfn) | |||
| 572 | void sparse_init(void); | 588 | void sparse_init(void); | 
| 573 | #else | 589 | #else | 
| 574 | #define sparse_init() do {} while (0) | 590 | #define sparse_init() do {} while (0) | 
| 591 | #define sparse_index_init(_sec, _nid) do {} while (0) | ||
| 575 | #endif /* CONFIG_SPARSEMEM */ | 592 | #endif /* CONFIG_SPARSEMEM */ | 
| 576 | 593 | ||
| 577 | #ifdef CONFIG_NODES_SPAN_OTHER_NODES | 594 | #ifdef CONFIG_NODES_SPAN_OTHER_NODES | 
