diff mbox

[v2,5/5] mm/page_alloc: Only call pgdat_set_deferred_range when the system boots

Message ID 20180719132740.32743-6-osalvador@techadventures.net (mailing list archive)
State New, archived
Headers show

Commit Message

Oscar Salvador July 19, 2018, 1:27 p.m. UTC
From: Oscar Salvador <osalvador@suse.de>

We should only care about deferred initialization when booting.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 mm/page_alloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michal Hocko July 19, 2018, 1:46 p.m. UTC | #1
On Thu 19-07-18 15:27:40, osalvador@techadventures.net wrote:
> From: Oscar Salvador <osalvador@suse.de>
> 
> We should only care about deferred initialization when booting.

Again why is this worth doing?
 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
>  mm/page_alloc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index d77bc2a7ec2c..5911b64a88ab 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6419,7 +6419,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
>  				  zones_size, zholes_size);
>  
>  	alloc_node_mem_map(pgdat);
> -	pgdat_set_deferred_range(pgdat);
> +	if (system_state == SYSTEM_BOOTING)
> +		pgdat_set_deferred_range(pgdat);
>  
>  	free_area_init_core(pgdat);
>  }
> -- 
> 2.13.6
>
Oscar Salvador July 19, 2018, 1:58 p.m. UTC | #2
On Thu, Jul 19, 2018 at 03:46:22PM +0200, Michal Hocko wrote:
> On Thu 19-07-18 15:27:40, osalvador@techadventures.net wrote:
> > From: Oscar Salvador <osalvador@suse.de>
> > 
> > We should only care about deferred initialization when booting.
> 
> Again why is this worth doing?

Well, it is not a big win if that is what you meant.

Those two fields are only being used when dealing with deferred pages,
which only happens at boot time.

If later on, free_area_init_node gets called from memhotplug code,
we will also set the fields, although they will not be used.

Is this a problem? No, but I think it is more clear from the code if we
see when this is called.
So I would say it was only for code consistency.

If you think this this is not worth, I am ok with dropping it.

Thanks
Michal Hocko July 19, 2018, 2:03 p.m. UTC | #3
On Thu 19-07-18 15:58:59, Oscar Salvador wrote:
> On Thu, Jul 19, 2018 at 03:46:22PM +0200, Michal Hocko wrote:
> > On Thu 19-07-18 15:27:40, osalvador@techadventures.net wrote:
> > > From: Oscar Salvador <osalvador@suse.de>
> > > 
> > > We should only care about deferred initialization when booting.
> > 
> > Again why is this worth doing?
> 
> Well, it is not a big win if that is what you meant.
> 
> Those two fields are only being used when dealing with deferred pages,
> which only happens at boot time.
> 
> If later on, free_area_init_node gets called from memhotplug code,
> we will also set the fields, although they will not be used.
> 
> Is this a problem? No, but I think it is more clear from the code if we
> see when this is called.
> So I would say it was only for code consistency.

Then put it to the changelog.

> If you think this this is not worth, I am ok with dropping it.

I am not really sure. I am not a big fan of SYSTEM_BOOTING global
thingy so I would rather not spread its usage.
Pavel Tatashin July 19, 2018, 2:27 p.m. UTC | #4
On Thu, Jul 19, 2018 at 10:03 AM Michal Hocko <mhocko@kernel.org> wrote:
>
> On Thu 19-07-18 15:58:59, Oscar Salvador wrote:
> > On Thu, Jul 19, 2018 at 03:46:22PM +0200, Michal Hocko wrote:
> > > On Thu 19-07-18 15:27:40, osalvador@techadventures.net wrote:
> > > > From: Oscar Salvador <osalvador@suse.de>
> > > >
> > > > We should only care about deferred initialization when booting.
> > >
> > > Again why is this worth doing?
> >
> > Well, it is not a big win if that is what you meant.
> >
> > Those two fields are only being used when dealing with deferred pages,
> > which only happens at boot time.
> >
> > If later on, free_area_init_node gets called from memhotplug code,
> > we will also set the fields, although they will not be used.
> >
> > Is this a problem? No, but I think it is more clear from the code if we
> > see when this is called.
> > So I would say it was only for code consistency.
>
> Then put it to the changelog.
>
> > If you think this this is not worth, I am ok with dropping it.
>
> I am not really sure. I am not a big fan of SYSTEM_BOOTING global
> thingy so I would rather not spread its usage.

I agree, I do not think this patch is necessary. Calling
pgdat_set_deferred_range() does not hurt in hotplug context, and it is
cheap too. SYSTEM_BOOTING sometimes useful, but it is better to use it
only where necessary, where without this "if" we will encounter some
bugs.

Thank you,
Pavel
Oscar Salvador July 19, 2018, 3:01 p.m. UTC | #5
On Thu, Jul 19, 2018 at 10:27:44AM -0400, Pavel Tatashin wrote:
> On Thu, Jul 19, 2018 at 10:03 AM Michal Hocko <mhocko@kernel.org> wrote:
> > I am not really sure. I am not a big fan of SYSTEM_BOOTING global
> > thingy so I would rather not spread its usage.
> 
> I agree, I do not think this patch is necessary. Calling
> pgdat_set_deferred_range() does not hurt in hotplug context, and it is
> cheap too. SYSTEM_BOOTING sometimes useful, but it is better to use it
> only where necessary, where without this "if" we will encounter some
> bugs.

Ok, let us drop it then ;-).

Thanks
diff mbox

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d77bc2a7ec2c..5911b64a88ab 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6419,7 +6419,8 @@  void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
 				  zones_size, zholes_size);
 
 	alloc_node_mem_map(pgdat);
-	pgdat_set_deferred_range(pgdat);
+	if (system_state == SYSTEM_BOOTING)
+		pgdat_set_deferred_range(pgdat);
 
 	free_area_init_core(pgdat);
 }