diff mbox series

mm/mm_init.c: don't initialize page->lru again

Message ID 20240605221436.24627-1-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series mm/mm_init.c: don't initialize page->lru again | expand

Commit Message

Wei Yang June 5, 2024, 10:14 p.m. UTC
After init_reserved_page(), we expect __init_single_page() has done its
work to the page, which already initialize page->lru properly.

We don't need to do it again.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/mm_init.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Mike Rapoport June 7, 2024, 7:33 a.m. UTC | #1
On Wed, Jun 05, 2024 at 10:14:36PM +0000, Wei Yang wrote:
> After init_reserved_page(), we expect __init_single_page() has done its
> work to the page, which already initialize page->lru properly.

init_reserved_page only available with CONFIG_DEFERRED_STRUCT_PAGE_INIT
 
> We don't need to do it again.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>  mm/mm_init.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 14133a1cfc7b..30379b0e7729 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -759,9 +759,6 @@ void __meminit reserve_bootmem_region(phys_addr_t start,
>  
>  			init_reserved_page(start_pfn, nid);
>  
> -			/* Avoid false-positive PageTail() */
> -			INIT_LIST_HEAD(&page->lru);
> -
>  			/*
>  			 * no need for atomic set_bit because the struct
>  			 * page is not visible yet so nobody should
> -- 
> 2.34.1
> 
>
Wei Yang June 8, 2024, 12:35 a.m. UTC | #2
On Fri, Jun 07, 2024 at 10:33:41AM +0300, Mike Rapoport wrote:
>On Wed, Jun 05, 2024 at 10:14:36PM +0000, Wei Yang wrote:
>> After init_reserved_page(), we expect __init_single_page() has done its
>> work to the page, which already initialize page->lru properly.
>
>init_reserved_page only available with CONFIG_DEFERRED_STRUCT_PAGE_INIT

The common page initialize path is :

memmap_init
    memmap_init_zone_range
        memmap_init_range
	    defer_init
	    __init_single_page

If CONFIG_DEFERRED_STRUCT_PAGE_INIT set, we would skip initialization for pages
after first_init_pfn. So init_reserved_page would initialize page struct
before __SetPageReserved().

If CONFIG_DEFERRED_STRUCT_PAGE_INIT not set, page struct is already initialized.

Is my understanding correct?

> 
>> We don't need to do it again.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>>  mm/mm_init.c | 3 ---
>>  1 file changed, 3 deletions(-)
>> 
>> diff --git a/mm/mm_init.c b/mm/mm_init.c
>> index 14133a1cfc7b..30379b0e7729 100644
>> --- a/mm/mm_init.c
>> +++ b/mm/mm_init.c
>> @@ -759,9 +759,6 @@ void __meminit reserve_bootmem_region(phys_addr_t start,
>>  
>>  			init_reserved_page(start_pfn, nid);
>>  
>> -			/* Avoid false-positive PageTail() */
>> -			INIT_LIST_HEAD(&page->lru);
>> -
>>  			/*
>>  			 * no need for atomic set_bit because the struct
>>  			 * page is not visible yet so nobody should
>> -- 
>> 2.34.1
>> 
>> 
>
>-- 
>Sincerely yours,
>Mike.
Mike Rapoport June 8, 2024, 7:56 a.m. UTC | #3
On Sat, Jun 08, 2024 at 12:35:35AM +0000, Wei Yang wrote:
> On Fri, Jun 07, 2024 at 10:33:41AM +0300, Mike Rapoport wrote:
> >On Wed, Jun 05, 2024 at 10:14:36PM +0000, Wei Yang wrote:
> >> After init_reserved_page(), we expect __init_single_page() has done its
> >> work to the page, which already initialize page->lru properly.
> >
> >init_reserved_page only available with CONFIG_DEFERRED_STRUCT_PAGE_INIT
> 
> The common page initialize path is :
> 
> memmap_init
>     memmap_init_zone_range
>         memmap_init_range
> 	    defer_init
> 	    __init_single_page
> 
> If CONFIG_DEFERRED_STRUCT_PAGE_INIT set, we would skip initialization for pages
> after first_init_pfn. So init_reserved_page would initialize page struct
> before __SetPageReserved().
> 
> If CONFIG_DEFERRED_STRUCT_PAGE_INIT not set, page struct is already initialized.
> 
> Is my understanding correct?
 
Yes, and it should be a part of the changelog :)
 
> >> We don't need to do it again.
> >> 
> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> >> ---
> >>  mm/mm_init.c | 3 ---
> >>  1 file changed, 3 deletions(-)
> >> 
> >> diff --git a/mm/mm_init.c b/mm/mm_init.c
> >> index 14133a1cfc7b..30379b0e7729 100644
> >> --- a/mm/mm_init.c
> >> +++ b/mm/mm_init.c
> >> @@ -759,9 +759,6 @@ void __meminit reserve_bootmem_region(phys_addr_t start,
> >>  
> >>  			init_reserved_page(start_pfn, nid);
> >>  
> >> -			/* Avoid false-positive PageTail() */
> >> -			INIT_LIST_HEAD(&page->lru);
> >> -
> >>  			/*
> >>  			 * no need for atomic set_bit because the struct
> >>  			 * page is not visible yet so nobody should
> >> -- 
> >> 2.34.1
> >> 
> >> 
> >
> >-- 
> >Sincerely yours,
> >Mike.
> 
> -- 
> Wei Yang
> Help you, Help me
diff mbox series

Patch

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 14133a1cfc7b..30379b0e7729 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -759,9 +759,6 @@  void __meminit reserve_bootmem_region(phys_addr_t start,
 
 			init_reserved_page(start_pfn, nid);
 
-			/* Avoid false-positive PageTail() */
-			INIT_LIST_HEAD(&page->lru);
-
 			/*
 			 * no need for atomic set_bit because the struct
 			 * page is not visible yet so nobody should