Lines Matching +full:compound +full:- +full:device
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Macros for manipulating and testing page->flags
18 * Various page->flags bits:
23 * - Pages part of the kernel image (including vDSO) and similar (e.g. BIOS,
25 * - Pages reserved or allocated early during boot (before the page allocator
30 * - Pages falling into physical memory gaps - not IORESOURCE_SYSRAM. Trying
32 * - The zero page(s)
33 * - Pages not added to the page allocator when onlining a section because
36 * - Pages allocated in the context of kexec/kdump (loaded kernel image,
38 * - MMIO/DMA pages. Some architectures don't allow to ioremap pages that are
41 * - Pages part of an offline section (struct pages of offline sections should
43 * - MCA pages on ia64
44 * - Pages holding CPU notes for POWER Firmware Assisted Dump
45 * - Device memory (e.g. PMEM, DAX, HMM)
50 * the zero page, the vDSO, MMIO pages or device memory.
53 * specific data (which is normally at page->private). It can be used by
72 * file-backed pagecache (see mm/vmscan.c).
93 * N-1 ^ 0
116 PG_private, /* If pagecache, has fs-private data */
118 PG_mappedtodisk, /* Has blocks allocated on-disk */
145 * table (e.g., single PMD/PUD/CONT of the head page vs. PTE-mapped
148 * set on tail pages for PTE-mapped THP.
158 /* Two page bits are conscripted by FS-Cache to maintain local caching
165 /* Pinned in Xen as a read-only pagetable page. */
171 /* Remapped by swiotlb-xen. */
174 /* non-lru isolated movable page */
181 /* For self-hosted memmap pages */
186 * Flags only valid for compound pages. Stored in first tail page's
194 PG_large_rmappable = PG_workingset, /* anon or file-backed */
197 #define PAGEFLAGS_MASK ((1UL << NR_PAGEFLAGS) - 1)
220 test_bit(PG_head, &page->flags)) { in page_fixed_fake_head()
223 * because the @page is a compound page composed with at least in page_fixed_fake_head()
229 return (const struct page *)(head - 1); in page_fixed_fake_head()
247 unsigned long head = READ_ONCE(page->compound_head); in _compound_head()
250 return head - 1; in _compound_head()
257 * page_folio - Converts from page to folio.
265 * it should re-check the folio still contains this page after gaining
274 * folio_page - Return a page from a folio.
282 #define folio_page(folio, n) nth_page(&(folio)->page, n)
286 return READ_ONCE(page->compound_head) & 1 || page_is_fake_head(page); in PageTail()
291 return test_bit(PG_head, &page->flags) || in PageCompound()
292 READ_ONCE(page->compound_head) & 1; in PageCompound()
295 #define PAGE_POISON_PATTERN -1l
298 return READ_ONCE(page->flags) == PAGE_POISON_PATTERN; in PagePoisoned()
311 struct page *page = &folio->page; in folio_flags()
314 VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page); in folio_flags()
319 * Page flags policies wrt compound pages
328 * for compound page all operations related to the page flag applied to
332 * for compound page, callers only ever operate on the head page.
339 * the page flag is not relevant for compound pages.
377 { return test_bit(PG_##lname, &policy(page, 0)->flags); }
384 { set_bit(PG_##lname, &policy(page, 1)->flags); }
391 { clear_bit(PG_##lname, &policy(page, 1)->flags); }
398 { __set_bit(PG_##lname, &policy(page, 1)->flags); }
405 { __clear_bit(PG_##lname, &policy(page, 1)->flags); }
412 { return test_and_set_bit(PG_##lname, &policy(page, 1)->flags); }
419 { return test_and_clear_bit(PG_##lname, &policy(page, 1)->flags); }
502 * - PG_private and PG_private_2 cause release_folio() and co to be invoked in PAGEFLAG()
510 * Only test-and-set exist for PG_writeback. The unconditional operators are in PAGEFLAG()
594 * allocator. We can use the non-atomic version of the test and set in TESTPAGEFLAG()
608 * page->mapping points to its anon_vma, not to a struct address_space; in TESTPAGEFLAG()
613 * bit; and then page->mapping points, not to an anon_vma, but to a private in TESTPAGEFLAG()
616 * PAGE_MAPPING_KSM without PAGE_MAPPING_ANON is used for non-lru movable in TESTPAGEFLAG()
617 * page and then page->mapping points to a struct movable_operations. in TESTPAGEFLAG()
624 * internal states, the page->mapping does not exist as such, nor do these in TESTPAGEFLAG()
625 * flags below. So in order to avoid testing non-existent bits, please in TESTPAGEFLAG()
636 * indicates that this page->mapping is now under reflink case. in TESTPAGEFLAG()
642 return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) != 0; in TESTPAGEFLAG()
647 return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) != 0; in PageMappingFlags()
652 return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0; in folio_test_anon()
662 return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) == in __folio_test_movable()
668 return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) == in __PageMovable()
674 * A KSM page is one of those write-protected "shared pages" or "merged pages"
681 return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) == in folio_test_ksm()
696 * folio_xor_flags_has_waiters - Change some folio flags.
703 * on flags which are in the range 0-6 as some of the implementations
715 * folio_test_uptodate - Is this folio up to date?
729 * _after_ we've loaded folio->flags to check the uptodate bit. in folio_test_uptodate()
791 return test_bit(PG_head, &page->flags) && !page_is_fake_head(page); in PageHead()
799 * folio_test_large() - Does this folio contain more than one page? in __SETPAGEFLAG()
811 WRITE_ONCE(page->compound_head, (unsigned long)head + 1); in set_compound_head()
816 WRITE_ONCE(page->compound_head, 0); in clear_compound_head()
838 * folio_test_hugetlb - Determine if the folio belongs to hugetlbfs in SETPAGEFLAG()
899 * compound page. in TESTPAGEFLAG_FALSE()
924 * page_type may be used. Because it is initialised to -1, we invert the
933 #define PAGE_MAPCOUNT_RESERVE -128
940 ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
942 ((folio->page.page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
951 return page_type_has_type(page->page_type); in page_has_type()
966 page->page_type &= ~PG_##lname; \
971 folio->page.page_type &= ~PG_##lname; \
976 page->page_type |= PG_##lname; \
981 folio->page.page_type |= PG_##lname; \
1003 * relies on this feature is aware that re-onlining the memory block will
1004 * require to re-set the pages PageOffline() and not giving them to the
1037 return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); in PageAnonExclusive()
1044 set_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); in SetPageAnonExclusive()
1051 clear_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); in ClearPageAnonExclusive()
1058 __clear_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); in __ClearPageAnonExclusive()
1084 * alloc-free cycle to prevent from reusing the page.
1090 * Flags stored in the second page of a compound page. They may overlap
1100 * page_has_private - Determine if page has private stuff
1108 return !!(page->flags & PAGE_FLAGS_PRIVATE); in page_has_private()
1113 return page_has_private(&folio->page); in folio_has_private()