diff options
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 1813b162b0a8..57b2ead51dba 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -395,19 +395,41 @@ static inline void put_page(struct page *page) | |||
395 | /* | 395 | /* |
396 | * The zone field is never updated after free_area_init_core() | 396 | * The zone field is never updated after free_area_init_core() |
397 | * sets it, so none of the operations on it need to be atomic. | 397 | * sets it, so none of the operations on it need to be atomic. |
398 | * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total, | ||
399 | * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits. | ||
400 | */ | 398 | */ |
401 | #define NODEZONE_SHIFT (sizeof(page_flags_t)*8 - MAX_NODES_SHIFT - MAX_ZONES_SHIFT) | 399 | |
400 | /* Page flags: | NODE | ZONE | ... | FLAGS | */ | ||
401 | #define NODES_PGOFF ((sizeof(page_flags_t)*8) - NODES_SHIFT) | ||
402 | #define ZONES_PGOFF (NODES_PGOFF - ZONES_SHIFT) | ||
403 | |||
404 | /* | ||
405 | * Define the bit shifts to access each section. For non-existant | ||
406 | * sections we define the shift as 0; that plus a 0 mask ensures | ||
407 | * the compiler will optimise away reference to them. | ||
408 | */ | ||
409 | #define NODES_PGSHIFT (NODES_PGOFF * (NODES_SHIFT != 0)) | ||
410 | #define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_SHIFT != 0)) | ||
411 | |||
412 | /* NODE:ZONE is used to lookup the zone from a page. */ | ||
413 | #define ZONETABLE_SHIFT (NODES_SHIFT + ZONES_SHIFT) | ||
414 | #define ZONETABLE_PGSHIFT ZONES_PGSHIFT | ||
415 | |||
416 | #if NODES_SHIFT+ZONES_SHIFT > FLAGS_RESERVED | ||
417 | #error NODES_SHIFT+ZONES_SHIFT > FLAGS_RESERVED | ||
418 | #endif | ||
419 | |||
402 | #define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone) | 420 | #define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone) |
403 | 421 | ||
422 | #define ZONES_MASK ((1UL << ZONES_SHIFT) - 1) | ||
423 | #define NODES_MASK ((1UL << NODES_SHIFT) - 1) | ||
424 | #define ZONETABLE_MASK ((1UL << ZONETABLE_SHIFT) - 1) | ||
425 | |||
404 | static inline unsigned long page_zonenum(struct page *page) | 426 | static inline unsigned long page_zonenum(struct page *page) |
405 | { | 427 | { |
406 | return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT)); | 428 | return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; |
407 | } | 429 | } |
408 | static inline unsigned long page_to_nid(struct page *page) | 430 | static inline unsigned long page_to_nid(struct page *page) |
409 | { | 431 | { |
410 | return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT)); | 432 | return (page->flags >> NODES_PGSHIFT) & NODES_MASK; |
411 | } | 433 | } |
412 | 434 | ||
413 | struct zone; | 435 | struct zone; |
@@ -415,13 +437,26 @@ extern struct zone *zone_table[]; | |||
415 | 437 | ||
416 | static inline struct zone *page_zone(struct page *page) | 438 | static inline struct zone *page_zone(struct page *page) |
417 | { | 439 | { |
418 | return zone_table[page->flags >> NODEZONE_SHIFT]; | 440 | return zone_table[(page->flags >> ZONETABLE_PGSHIFT) & |
441 | ZONETABLE_MASK]; | ||
442 | } | ||
443 | |||
444 | static inline void set_page_zone(struct page *page, unsigned long zone) | ||
445 | { | ||
446 | page->flags &= ~(ZONES_MASK << ZONES_PGSHIFT); | ||
447 | page->flags |= (zone & ZONES_MASK) << ZONES_PGSHIFT; | ||
448 | } | ||
449 | static inline void set_page_node(struct page *page, unsigned long node) | ||
450 | { | ||
451 | page->flags &= ~(NODES_MASK << NODES_PGSHIFT); | ||
452 | page->flags |= (node & NODES_MASK) << NODES_PGSHIFT; | ||
419 | } | 453 | } |
420 | 454 | ||
421 | static inline void set_page_zone(struct page *page, unsigned long nodezone_num) | 455 | static inline void set_page_links(struct page *page, unsigned long zone, |
456 | unsigned long node) | ||
422 | { | 457 | { |
423 | page->flags &= ~(~0UL << NODEZONE_SHIFT); | 458 | set_page_zone(page, zone); |
424 | page->flags |= nodezone_num << NODEZONE_SHIFT; | 459 | set_page_node(page, node); |
425 | } | 460 | } |
426 | 461 | ||
427 | #ifndef CONFIG_DISCONTIGMEM | 462 | #ifndef CONFIG_DISCONTIGMEM |