Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Macros for manipulating and testing flags related to a
0004  * pageblock_nr_pages number of pages.
0005  *
0006  * Copyright (C) IBM Corporation, 2006
0007  *
0008  * Original author, Mel Gorman
0009  * Major cleanups and reduction of bit operations, Andy Whitcroft
0010  */
0011 #ifndef PAGEBLOCK_FLAGS_H
0012 #define PAGEBLOCK_FLAGS_H
0013 
0014 #include <linux/types.h>
0015 
0016 #define PB_migratetype_bits 3
0017 /* Bit indices that affect a whole block of pages */
0018 enum pageblock_bits {
0019     PB_migrate,
0020     PB_migrate_end = PB_migrate + PB_migratetype_bits - 1,
0021             /* 3 bits required for migrate types */
0022     PB_migrate_skip,/* If set the block is skipped by compaction */
0023 
0024     /*
0025      * Assume the bits will always align on a word. If this assumption
0026      * changes then get/set pageblock needs updating.
0027      */
0028     NR_PAGEBLOCK_BITS
0029 };
0030 
0031 #ifdef CONFIG_HUGETLB_PAGE
0032 
0033 #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
0034 
0035 /* Huge page sizes are variable */
0036 extern unsigned int pageblock_order;
0037 
0038 #else /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */
0039 
0040 /*
0041  * Huge pages are a constant size, but don't exceed the maximum allocation
0042  * granularity.
0043  */
0044 #define pageblock_order     min_t(unsigned int, HUGETLB_PAGE_ORDER, MAX_ORDER - 1)
0045 
0046 #endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */
0047 
0048 #else /* CONFIG_HUGETLB_PAGE */
0049 
0050 /* If huge pages are not used, group by MAX_ORDER_NR_PAGES */
0051 #define pageblock_order     (MAX_ORDER-1)
0052 
0053 #endif /* CONFIG_HUGETLB_PAGE */
0054 
0055 #define pageblock_nr_pages  (1UL << pageblock_order)
0056 
0057 /* Forward declaration */
0058 struct page;
0059 
0060 unsigned long get_pfnblock_flags_mask(const struct page *page,
0061                 unsigned long pfn,
0062                 unsigned long mask);
0063 
0064 void set_pfnblock_flags_mask(struct page *page,
0065                 unsigned long flags,
0066                 unsigned long pfn,
0067                 unsigned long mask);
0068 
0069 /* Declarations for getting and setting flags. See mm/page_alloc.c */
0070 #ifdef CONFIG_COMPACTION
0071 #define get_pageblock_skip(page) \
0072     get_pfnblock_flags_mask(page, page_to_pfn(page),    \
0073             (1 << (PB_migrate_skip)))
0074 #define clear_pageblock_skip(page) \
0075     set_pfnblock_flags_mask(page, 0, page_to_pfn(page), \
0076             (1 << PB_migrate_skip))
0077 #define set_pageblock_skip(page) \
0078     set_pfnblock_flags_mask(page, (1 << PB_migrate_skip),   \
0079             page_to_pfn(page),          \
0080             (1 << PB_migrate_skip))
0081 #else
0082 static inline bool get_pageblock_skip(struct page *page)
0083 {
0084     return false;
0085 }
0086 static inline void clear_pageblock_skip(struct page *page)
0087 {
0088 }
0089 static inline void set_pageblock_skip(struct page *page)
0090 {
0091 }
0092 #endif /* CONFIG_COMPACTION */
0093 
0094 #endif  /* PAGEBLOCK_FLAGS_H */