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

Configure Feed

Select the types of activity you want to include in your feed.

mm: constify zone related test/getter functions

For improved const-correctness.

We select certain test functions which either invoke each other,
functions that are already const-ified, or no further functions.

It is therefore relatively trivial to const-ify them, which provides a
basis for further const-ification further up the call stack.

Link: https://lkml.kernel.org/r/20250901205021.3573313-4-max.kellermann@ionos.com
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christian Zankel <chris@zankel.net>
Cc: David Rientjes <rientjes@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Bottomley <james.bottomley@HansenPartnership.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: "Nysal Jan K.A" <nysal@linux.ibm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russel King <linux@armlinux.org.uk>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Max Kellermann and committed by
Andrew Morton
959b0886 7c3e97ac

+21 -21
+21 -21
include/linux/mmzone.h
··· 1104 1104 return wmark_pages(z, WMARK_PROMO); 1105 1105 } 1106 1106 1107 - static inline unsigned long zone_managed_pages(struct zone *zone) 1107 + static inline unsigned long zone_managed_pages(const struct zone *zone) 1108 1108 { 1109 1109 return (unsigned long)atomic_long_read(&zone->managed_pages); 1110 1110 } ··· 1128 1128 return zone->zone_start_pfn <= pfn && pfn < zone_end_pfn(zone); 1129 1129 } 1130 1130 1131 - static inline bool zone_is_initialized(struct zone *zone) 1131 + static inline bool zone_is_initialized(const struct zone *zone) 1132 1132 { 1133 1133 return zone->initialized; 1134 1134 } 1135 1135 1136 - static inline bool zone_is_empty(struct zone *zone) 1136 + static inline bool zone_is_empty(const struct zone *zone) 1137 1137 { 1138 1138 return zone->spanned_pages == 0; 1139 1139 } ··· 1273 1273 * Return true if [start_pfn, start_pfn + nr_pages) range has a non-empty 1274 1274 * intersection with the given zone 1275 1275 */ 1276 - static inline bool zone_intersects(struct zone *zone, 1276 + static inline bool zone_intersects(const struct zone *zone, 1277 1277 unsigned long start_pfn, unsigned long nr_pages) 1278 1278 { 1279 1279 if (zone_is_empty(zone)) ··· 1581 1581 #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) 1582 1582 1583 1583 #ifdef CONFIG_ZONE_DEVICE 1584 - static inline bool zone_is_zone_device(struct zone *zone) 1584 + static inline bool zone_is_zone_device(const struct zone *zone) 1585 1585 { 1586 1586 return zone_idx(zone) == ZONE_DEVICE; 1587 1587 } 1588 1588 #else 1589 - static inline bool zone_is_zone_device(struct zone *zone) 1589 + static inline bool zone_is_zone_device(const struct zone *zone) 1590 1590 { 1591 1591 return false; 1592 1592 } ··· 1598 1598 * populated_zone(). If the whole zone is reserved then we can easily 1599 1599 * end up with populated_zone() && !managed_zone(). 1600 1600 */ 1601 - static inline bool managed_zone(struct zone *zone) 1601 + static inline bool managed_zone(const struct zone *zone) 1602 1602 { 1603 1603 return zone_managed_pages(zone); 1604 1604 } 1605 1605 1606 1606 /* Returns true if a zone has memory */ 1607 - static inline bool populated_zone(struct zone *zone) 1607 + static inline bool populated_zone(const struct zone *zone) 1608 1608 { 1609 1609 return zone->present_pages; 1610 1610 } 1611 1611 1612 1612 #ifdef CONFIG_NUMA 1613 - static inline int zone_to_nid(struct zone *zone) 1613 + static inline int zone_to_nid(const struct zone *zone) 1614 1614 { 1615 1615 return zone->node; 1616 1616 } ··· 1620 1620 zone->node = nid; 1621 1621 } 1622 1622 #else 1623 - static inline int zone_to_nid(struct zone *zone) 1623 + static inline int zone_to_nid(const struct zone *zone) 1624 1624 { 1625 1625 return 0; 1626 1626 } ··· 1647 1647 * @zone: pointer to struct zone variable 1648 1648 * Return: 1 for a highmem zone, 0 otherwise 1649 1649 */ 1650 - static inline int is_highmem(struct zone *zone) 1650 + static inline int is_highmem(const struct zone *zone) 1651 1651 { 1652 1652 return is_highmem_idx(zone_idx(zone)); 1653 1653 } ··· 1713 1713 return zoneref->zone; 1714 1714 } 1715 1715 1716 - static inline int zonelist_zone_idx(struct zoneref *zoneref) 1716 + static inline int zonelist_zone_idx(const struct zoneref *zoneref) 1717 1717 { 1718 1718 return zoneref->zone_idx; 1719 1719 } 1720 1720 1721 - static inline int zonelist_node_idx(struct zoneref *zoneref) 1721 + static inline int zonelist_node_idx(const struct zoneref *zoneref) 1722 1722 { 1723 1723 return zone_to_nid(zoneref->zone); 1724 1724 } ··· 2021 2021 return (struct page *)map; 2022 2022 } 2023 2023 2024 - static inline int present_section(struct mem_section *section) 2024 + static inline int present_section(const struct mem_section *section) 2025 2025 { 2026 2026 return (section && (section->section_mem_map & SECTION_MARKED_PRESENT)); 2027 2027 } ··· 2031 2031 return present_section(__nr_to_section(nr)); 2032 2032 } 2033 2033 2034 - static inline int valid_section(struct mem_section *section) 2034 + static inline int valid_section(const struct mem_section *section) 2035 2035 { 2036 2036 return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP)); 2037 2037 } 2038 2038 2039 - static inline int early_section(struct mem_section *section) 2039 + static inline int early_section(const struct mem_section *section) 2040 2040 { 2041 2041 return (section && (section->section_mem_map & SECTION_IS_EARLY)); 2042 2042 } ··· 2046 2046 return valid_section(__nr_to_section(nr)); 2047 2047 } 2048 2048 2049 - static inline int online_section(struct mem_section *section) 2049 + static inline int online_section(const struct mem_section *section) 2050 2050 { 2051 2051 return (section && (section->section_mem_map & SECTION_IS_ONLINE)); 2052 2052 } 2053 2053 2054 2054 #ifdef CONFIG_ZONE_DEVICE 2055 - static inline int online_device_section(struct mem_section *section) 2055 + static inline int online_device_section(const struct mem_section *section) 2056 2056 { 2057 2057 unsigned long flags = SECTION_IS_ONLINE | SECTION_TAINT_ZONE_DEVICE; 2058 2058 2059 2059 return section && ((section->section_mem_map & flags) == flags); 2060 2060 } 2061 2061 #else 2062 - static inline int online_device_section(struct mem_section *section) 2062 + static inline int online_device_section(const struct mem_section *section) 2063 2063 { 2064 2064 return 0; 2065 2065 } 2066 2066 #endif 2067 2067 2068 2068 #ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT 2069 - static inline int preinited_vmemmap_section(struct mem_section *section) 2069 + static inline int preinited_vmemmap_section(const struct mem_section *section) 2070 2070 { 2071 2071 return (section && 2072 2072 (section->section_mem_map & SECTION_IS_VMEMMAP_PREINIT)); ··· 2076 2076 void sparse_vmemmap_init_nid_late(int nid); 2077 2077 2078 2078 #else 2079 - static inline int preinited_vmemmap_section(struct mem_section *section) 2079 + static inline int preinited_vmemmap_section(const struct mem_section *section) 2080 2080 { 2081 2081 return 0; 2082 2082 }