Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: make some struct page's const

These uses are read-only and in a subsequent patch I have a const struct
page in my hand...

[akpm@linux-foundation.org: fix warnings in lowmem_page_address()]
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ian Campbell and committed by
Linus Torvalds
33dd4e0e ee8f248d

+7 -7
+6 -6
include/linux/mm.h
··· 637 637 #define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1) 638 638 #define ZONEID_MASK ((1UL << ZONEID_SHIFT) - 1) 639 639 640 - static inline enum zone_type page_zonenum(struct page *page) 640 + static inline enum zone_type page_zonenum(const struct page *page) 641 641 { 642 642 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; 643 643 } ··· 665 665 } 666 666 667 667 #ifdef NODE_NOT_IN_PAGE_FLAGS 668 - extern int page_to_nid(struct page *page); 668 + extern int page_to_nid(const struct page *page); 669 669 #else 670 - static inline int page_to_nid(struct page *page) 670 + static inline int page_to_nid(const struct page *page) 671 671 { 672 672 return (page->flags >> NODES_PGSHIFT) & NODES_MASK; 673 673 } 674 674 #endif 675 675 676 - static inline struct zone *page_zone(struct page *page) 676 + static inline struct zone *page_zone(const struct page *page) 677 677 { 678 678 return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; 679 679 } ··· 718 718 */ 719 719 #include <linux/vmstat.h> 720 720 721 - static __always_inline void *lowmem_page_address(struct page *page) 721 + static __always_inline void *lowmem_page_address(const struct page *page) 722 722 { 723 - return __va(PFN_PHYS(page_to_pfn(page))); 723 + return __va(PFN_PHYS(page_to_pfn((struct page *)page))); 724 724 } 725 725 726 726 #if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)
+1 -1
mm/sparse.c
··· 40 40 static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned; 41 41 #endif 42 42 43 - int page_to_nid(struct page *page) 43 + int page_to_nid(const struct page *page) 44 44 { 45 45 return section_to_node_table[page_to_section(page)]; 46 46 }