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 pagemap 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-3-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
7c3e97ac 8eccb066

+28 -27
+28 -27
include/linux/pagemap.h
··· 140 140 return filemap_write_and_wait(inode->i_mapping); 141 141 } 142 142 143 - static inline bool mapping_empty(struct address_space *mapping) 143 + static inline bool mapping_empty(const struct address_space *mapping) 144 144 { 145 145 return xa_empty(&mapping->i_pages); 146 146 } ··· 166 166 * refcount and the referenced bit, which will be elevated or set in 167 167 * the process of adding new cache pages to an inode. 168 168 */ 169 - static inline bool mapping_shrinkable(struct address_space *mapping) 169 + static inline bool mapping_shrinkable(const struct address_space *mapping) 170 170 { 171 171 void *head; 172 172 ··· 267 267 clear_bit(AS_UNEVICTABLE, &mapping->flags); 268 268 } 269 269 270 - static inline bool mapping_unevictable(struct address_space *mapping) 270 + static inline bool mapping_unevictable(const struct address_space *mapping) 271 271 { 272 272 return mapping && test_bit(AS_UNEVICTABLE, &mapping->flags); 273 273 } ··· 277 277 set_bit(AS_EXITING, &mapping->flags); 278 278 } 279 279 280 - static inline int mapping_exiting(struct address_space *mapping) 280 + static inline int mapping_exiting(const struct address_space *mapping) 281 281 { 282 282 return test_bit(AS_EXITING, &mapping->flags); 283 283 } ··· 287 287 set_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags); 288 288 } 289 289 290 - static inline int mapping_use_writeback_tags(struct address_space *mapping) 290 + static inline int mapping_use_writeback_tags(const struct address_space *mapping) 291 291 { 292 292 return !test_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags); 293 293 } ··· 333 333 set_bit(AS_INACCESSIBLE, &mapping->flags); 334 334 } 335 335 336 - static inline bool mapping_inaccessible(struct address_space *mapping) 336 + static inline bool mapping_inaccessible(const struct address_space *mapping) 337 337 { 338 338 return test_bit(AS_INACCESSIBLE, &mapping->flags); 339 339 } ··· 343 343 set_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); 344 344 } 345 345 346 - static inline bool mapping_writeback_may_deadlock_on_reclaim(struct address_space *mapping) 346 + static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct address_space *mapping) 347 347 { 348 348 return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); 349 349 } 350 350 351 - static inline gfp_t mapping_gfp_mask(struct address_space * mapping) 351 + static inline gfp_t mapping_gfp_mask(const struct address_space *mapping) 352 352 { 353 353 return mapping->gfp_mask; 354 354 } 355 355 356 356 /* Restricts the given gfp_mask to what the mapping allows. */ 357 - static inline gfp_t mapping_gfp_constraint(struct address_space *mapping, 357 + static inline gfp_t mapping_gfp_constraint(const struct address_space *mapping, 358 358 gfp_t gfp_mask) 359 359 { 360 360 return mapping_gfp_mask(mapping) & gfp_mask; ··· 477 477 } 478 478 479 479 static inline unsigned long 480 - mapping_min_folio_nrpages(struct address_space *mapping) 480 + mapping_min_folio_nrpages(const struct address_space *mapping) 481 481 { 482 482 return 1UL << mapping_min_folio_order(mapping); 483 483 } ··· 491 491 * new folio to the page cache and need to know what index to give it, 492 492 * call this function. 493 493 */ 494 - static inline pgoff_t mapping_align_index(struct address_space *mapping, 494 + static inline pgoff_t mapping_align_index(const struct address_space *mapping, 495 495 pgoff_t index) 496 496 { 497 497 return round_down(index, mapping_min_folio_nrpages(mapping)); ··· 501 501 * Large folio support currently depends on THP. These dependencies are 502 502 * being worked on but are not yet fixed. 503 503 */ 504 - static inline bool mapping_large_folio_support(struct address_space *mapping) 504 + static inline bool mapping_large_folio_support(const struct address_space *mapping) 505 505 { 506 506 /* AS_FOLIO_ORDER is only reasonable for pagecache folios */ 507 507 VM_WARN_ONCE((unsigned long)mapping & FOLIO_MAPPING_ANON, ··· 516 516 return PAGE_SIZE << mapping_max_folio_order(mapping); 517 517 } 518 518 519 - static inline int filemap_nr_thps(struct address_space *mapping) 519 + static inline int filemap_nr_thps(const struct address_space *mapping) 520 520 { 521 521 #ifdef CONFIG_READ_ONLY_THP_FOR_FS 522 522 return atomic_read(&mapping->nr_thps); ··· 930 930 * 931 931 * Return: The index of the folio which follows this folio in the file. 932 932 */ 933 - static inline pgoff_t folio_next_index(struct folio *folio) 933 + static inline pgoff_t folio_next_index(const struct folio *folio) 934 934 { 935 935 return folio->index + folio_nr_pages(folio); 936 936 } ··· 959 959 * e.g., shmem did not move this folio to the swap cache. 960 960 * Return: true or false. 961 961 */ 962 - static inline bool folio_contains(struct folio *folio, pgoff_t index) 962 + static inline bool folio_contains(const struct folio *folio, pgoff_t index) 963 963 { 964 964 VM_WARN_ON_ONCE_FOLIO(folio_test_swapcache(folio), folio); 965 965 return index - folio->index < folio_nr_pages(folio); ··· 1036 1036 /* 1037 1037 * Get the offset in PAGE_SIZE (even for hugetlb folios). 1038 1038 */ 1039 - static inline pgoff_t folio_pgoff(struct folio *folio) 1039 + static inline pgoff_t folio_pgoff(const struct folio *folio) 1040 1040 { 1041 1041 return folio->index; 1042 1042 } 1043 1043 1044 - static inline pgoff_t linear_page_index(struct vm_area_struct *vma, 1045 - unsigned long address) 1044 + static inline pgoff_t linear_page_index(const struct vm_area_struct *vma, 1045 + const unsigned long address) 1046 1046 { 1047 1047 pgoff_t pgoff; 1048 1048 pgoff = (address - vma->vm_start) >> PAGE_SHIFT; ··· 1462 1462 * readahead_pos - The byte offset into the file of this readahead request. 1463 1463 * @rac: The readahead request. 1464 1464 */ 1465 - static inline loff_t readahead_pos(struct readahead_control *rac) 1465 + static inline loff_t readahead_pos(const struct readahead_control *rac) 1466 1466 { 1467 1467 return (loff_t)rac->_index * PAGE_SIZE; 1468 1468 } ··· 1471 1471 * readahead_length - The number of bytes in this readahead request. 1472 1472 * @rac: The readahead request. 1473 1473 */ 1474 - static inline size_t readahead_length(struct readahead_control *rac) 1474 + static inline size_t readahead_length(const struct readahead_control *rac) 1475 1475 { 1476 1476 return rac->_nr_pages * PAGE_SIZE; 1477 1477 } ··· 1480 1480 * readahead_index - The index of the first page in this readahead request. 1481 1481 * @rac: The readahead request. 1482 1482 */ 1483 - static inline pgoff_t readahead_index(struct readahead_control *rac) 1483 + static inline pgoff_t readahead_index(const struct readahead_control *rac) 1484 1484 { 1485 1485 return rac->_index; 1486 1486 } ··· 1489 1489 * readahead_count - The number of pages in this readahead request. 1490 1490 * @rac: The readahead request. 1491 1491 */ 1492 - static inline unsigned int readahead_count(struct readahead_control *rac) 1492 + static inline unsigned int readahead_count(const struct readahead_control *rac) 1493 1493 { 1494 1494 return rac->_nr_pages; 1495 1495 } ··· 1498 1498 * readahead_batch_length - The number of bytes in the current batch. 1499 1499 * @rac: The readahead request. 1500 1500 */ 1501 - static inline size_t readahead_batch_length(struct readahead_control *rac) 1501 + static inline size_t readahead_batch_length(const struct readahead_control *rac) 1502 1502 { 1503 1503 return rac->_batch_count * PAGE_SIZE; 1504 1504 } 1505 1505 1506 - static inline unsigned long dir_pages(struct inode *inode) 1506 + static inline unsigned long dir_pages(const struct inode *inode) 1507 1507 { 1508 1508 return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >> 1509 1509 PAGE_SHIFT; ··· 1517 1517 * Return: the number of bytes in the folio up to EOF, 1518 1518 * or -EFAULT if the folio was truncated. 1519 1519 */ 1520 - static inline ssize_t folio_mkwrite_check_truncate(struct folio *folio, 1521 - struct inode *inode) 1520 + static inline ssize_t folio_mkwrite_check_truncate(const struct folio *folio, 1521 + const struct inode *inode) 1522 1522 { 1523 1523 loff_t size = i_size_read(inode); 1524 1524 pgoff_t index = size >> PAGE_SHIFT; ··· 1549 1549 * Return: The number of filesystem blocks covered by this folio. 1550 1550 */ 1551 1551 static inline 1552 - unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio) 1552 + unsigned int i_blocks_per_folio(const struct inode *inode, 1553 + const struct folio *folio) 1553 1554 { 1554 1555 return folio_size(folio) >> inode->i_blkbits; 1555 1556 }