Skip to content

Commit

Permalink
mm: Make some folio function arguments const
Browse files Browse the repository at this point in the history
Mark the folio* argument to some of the folio accessor functions as a const
pointer.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Jun 8, 2022
1 parent 958568e commit f951c96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions include/linux/mm.h
Expand Up @@ -676,7 +676,7 @@ int vma_is_stack_for_current(struct vm_area_struct *vma);
struct mmu_gather;
struct inode;

static inline unsigned int compound_order(struct page *page)
static inline unsigned int compound_order(const struct page *page)
{
if (!PageHead(page))
return 0;
Expand All @@ -692,7 +692,7 @@ static inline unsigned int compound_order(struct page *page)
*
* Return: The order of the folio.
*/
static inline unsigned int folio_order(struct folio *folio)
static inline unsigned int folio_order(const struct folio *folio)
{
return compound_order(&folio->page);
}
Expand Down Expand Up @@ -912,7 +912,7 @@ static inline void set_compound_order(struct page *page, unsigned int order)
}

/* Returns the number of pages in this potentially compound page. */
static inline unsigned long compound_nr(struct page *page)
static inline unsigned long compound_nr(const struct page *page)
{
if (!PageHead(page))
return 1;
Expand Down Expand Up @@ -1516,7 +1516,7 @@ static inline unsigned long page_to_section(const struct page *page)
*
* Return: The Page Frame Number of the first page in the folio.
*/
static inline unsigned long folio_pfn(struct folio *folio)
static inline unsigned long folio_pfn(const struct folio *folio)
{
return page_to_pfn(&folio->page);
}
Expand Down Expand Up @@ -1592,7 +1592,7 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma,

/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin pages */
#ifdef CONFIG_MIGRATION
static inline bool is_pinnable_page(struct page *page)
static inline bool is_pinnable_page(const struct page *page)
{
#ifdef CONFIG_CMA
int mt = get_pageblock_migratetype(page);
Expand All @@ -1603,13 +1603,13 @@ static inline bool is_pinnable_page(struct page *page)
return !(is_zone_movable_page(page) || is_zero_pfn(page_to_pfn(page)));
}
#else
static inline bool is_pinnable_page(struct page *page)
static inline bool is_pinnable_page(const struct page *page)
{
return true;
}
#endif

static inline bool folio_is_pinnable(struct folio *folio)
static inline bool folio_is_pinnable(const struct folio *folio)
{
return is_pinnable_page(&folio->page);
}
Expand Down Expand Up @@ -1642,7 +1642,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
*
* Return: A positive power of two.
*/
static inline long folio_nr_pages(struct folio *folio)
static inline long folio_nr_pages(const struct folio *folio)
{
return compound_nr(&folio->page);
}
Expand Down Expand Up @@ -1678,7 +1678,7 @@ static inline struct folio *folio_next(struct folio *folio)
* it from being split. It is not necessary for the folio to be locked.
* Return: The base-2 logarithm of the size of this folio.
*/
static inline unsigned int folio_shift(struct folio *folio)
static inline unsigned int folio_shift(const struct folio *folio)
{
return PAGE_SHIFT + folio_order(folio);
}
Expand All @@ -1691,7 +1691,7 @@ static inline unsigned int folio_shift(struct folio *folio)
* it from being split. It is not necessary for the folio to be locked.
* Return: The number of bytes in this folio.
*/
static inline size_t folio_size(struct folio *folio)
static inline size_t folio_size(const struct folio *folio)
{
return PAGE_SIZE << folio_order(folio);
}
Expand Down
4 changes: 2 additions & 2 deletions include/linux/page-flags.h
Expand Up @@ -262,7 +262,7 @@ static inline bool hugetlb_optimize_vmemmap_enabled(void)
}
#endif

static __always_inline int page_is_fake_head(struct page *page)
static __always_inline int page_is_fake_head(const struct page *page)
{
return page_fixed_fake_head(page) != page;
}
Expand Down Expand Up @@ -783,7 +783,7 @@ static __always_inline bool folio_test_head(struct folio *folio)
return test_bit(PG_head, folio_flags(folio, FOLIO_PF_ANY));
}

static __always_inline int PageHead(struct page *page)
static __always_inline int PageHead(const struct page *page)
{
PF_POISONED_CHECK(page);
return test_bit(PG_head, &page->flags) && !page_is_fake_head(page);
Expand Down

0 comments on commit f951c96

Please sign in to comment.