Skip to content
Commit fa3fb21b authored by Alexandru Elisei's avatar Alexandru Elisei
Browse files

mm: arm64: mte: Optimize tag zeroing for transparent huge pages

For clearing regular (PAGE_SIZE) pages when MTE is enabled for a VMA, arm64
uses the DC GZVA instruction, which clears both the tags and the data,
which reduces the overhead of cleaning them separately. This is done by the
page allocator in post_alloc_hook(), when __GFP_ZERO (or init_on_alloc is
1), but __GFP_SKIP_ZERO is not set, and __GFP_TAGGED are both set for the
  allocation.

For allocating transparent hugepages neither flags are set in
do_huge_pmd_anonymous_page() because the zeroing of hugepages is done after
the allocation, in clear_huge_page(), which is optimized to not starve
other processes of CPU time. Then tags for a tagged thp page are zeroed
later in set_pte_at().

Similar to regular pages, optimize the initialization of tagged thp pages
by calling tag_clear_highpage() for each subpage, which does both the
clearing of data and zeroing of tags.

Note that it is not strictly necessary to add __GFP_TAGGED to the get free
pages flags, as the page allocator will zero the tags + data only when
__GFP_ZERO is also set, which is not the case in vma_thp_gfp_mask(). The
__GFP_TAGGEG flag is set because it allow the page allocator when an
allocation is tagged.
parent 269201f5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment