[v3,0/2] mm: Don't set and reset page count in MEMINIT_EARLY

Message ID 20230926023341.991124-1-yajun.deng@linux.dev
Headers
Series mm: Don't set and reset page count in MEMINIT_EARLY |

Message

Yajun Deng Sept. 26, 2023, 2:33 a.m. UTC
  __init_single_page would set page count and __free_pages_core would
reset it. A lot of pages don't need to do this when in MEMINIT_EARLY
context. It's unnecessary and time-consuming.

The 1st patch is pass page count and reserved to __init_single_page.
It's in preparation for the 2nd patch, it didn't change anything.

The 2nd patch only set page count for the reserved region, not all
of the region.

Yajun Deng (2):
  mm: pass page count and reserved to __init_single_page
  mm: Init page count in reserve_bootmem_region when MEMINIT_EARLY

 mm/hugetlb.c    |  2 +-
 mm/internal.h   |  8 +++++++-
 mm/mm_init.c    | 45 ++++++++++++++++++++++++++++-----------------
 mm/page_alloc.c | 20 ++++++++++++--------
 4 files changed, 48 insertions(+), 27 deletions(-)
  

Comments

David Hildenbrand Sept. 26, 2023, 7:44 a.m. UTC | #1
On 26.09.23 04:33, Yajun Deng wrote:
> When we init a single page, we need to mark this page reserved if it
> does. 

I failed to parse the last part of this sentence.

> And some pages may not need to set page count, such as compound
> pages.

Usually, the refcount of all tail pages *must* be zero. Otherwise, 
get_page_unless_zero() would work on tail pages.

Can you elaborate why it should be okay here?