Oscar Salvador 03e85f9d5f mm/page_alloc: Introduce free_area_init_core_hotplug
Currently, whenever a new node is created/re-used from the memhotplug
path, we call free_area_init_node()->free_area_init_core().  But there is
some code that we do not really need to run when we are coming from such
path.

free_area_init_core() performs the following actions:

1) Initializes pgdat internals, such as spinlock, waitqueues and more.
2) Account # nr_all_pages and # nr_kernel_pages. These values are used later on
   when creating hash tables.
3) Account number of managed_pages per zone, substracting dma_reserved and
   memmap pages.
4) Initializes some fields of the zone structure data
5) Calls init_currently_empty_zone to initialize all the freelists
6) Calls memmap_init to initialize all pages belonging to certain zone

When called from memhotplug path, free_area_init_core() only performs
actions #1 and #4.

Action #2 is pointless as the zones do not have any pages since either the
node was freed, or we are re-using it, eitherway all zones belonging to
this node should have 0 pages.  For the same reason, action #3 results
always in manages_pages being 0.

Action #5 and #6 are performed later on when onlining the pages:
 online_pages()->move_pfn_range_to_zone()->init_currently_empty_zone()
 online_pages()->move_pfn_range_to_zone()->memmap_init_zone()

This patch does two things:

First, moves the node/zone initializtion to their own function, so it
allows us to create a small version of free_area_init_core, where we only
perform:

1) Initialization of pgdat internals, such as spinlock, waitqueues and more
4) Initialization of some fields of the zone structure data

These two functions are: pgdat_init_internals() and zone_init_internals().

The second thing this patch does, is to introduce
free_area_init_core_hotplug(), the memhotplug version of
free_area_init_core():

Currently, we call free_area_init_node() from the memhotplug path.  In
there, we set some pgdat's fields, and call calculate_node_totalpages().
calculate_node_totalpages() calculates the # of pages the node has.

Since the node is either new, or we are re-using it, the zones belonging
to this node should not have any pages, so there is no point to calculate
this now.

Actually, we re-set these values to 0 later on with the calls to:

reset_node_managed_pages()
reset_node_present_pages()

The # of pages per node and the # of pages per zone will be calculated when
onlining the pages:

online_pages()->move_pfn_range()->move_pfn_range_to_zone()->resize_zone_range()
online_pages()->move_pfn_range()->move_pfn_range_to_zone()->resize_pgdat_range()

Also, since free_area_init_core/free_area_init_node will now only get called during early init, let us replace
__paginginit with __init, so their code gets freed up.

[osalvador@techadventures.net: fix section usage]
  Link: http://lkml.kernel.org/r/20180731101752.GA473@techadventures.net
[osalvador@suse.de: v6]
  Link: http://lkml.kernel.org/r/20180801122348.21588-6-osalvador@techadventures.net
Link: http://lkml.kernel.org/r/20180730101757.28058-5-osalvador@techadventures.net
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Pasha Tatashin <Pavel.Tatashin@microsoft.com>
Cc: Aaron Lu <aaron.lu@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-22 10:52:45 -07:00
..
2018-08-18 15:55:59 -07:00
2018-07-15 13:55:44 +02:00
2018-08-20 15:38:44 -07:00
2018-08-11 12:19:35 +02:00
2018-08-09 14:05:30 -07:00
2018-08-18 16:42:04 -07:00
2018-08-14 12:01:08 -07:00
2018-06-12 10:09:03 -07:00
2018-08-18 10:21:49 -07:00
2018-06-15 18:10:01 -03:00
2018-07-24 14:43:26 -06:00
2018-08-14 10:23:25 -07:00
2018-06-15 18:10:01 -03:00
2018-06-19 10:06:29 -07:00
2018-06-19 10:06:29 -07:00
2018-08-14 16:39:13 -07:00
2018-08-14 13:12:24 -07:00
2018-08-18 11:44:53 -07:00
2018-07-22 14:13:43 +02:00
2018-06-01 07:38:16 -06:00
2018-07-12 10:04:29 -04:00
2018-06-11 10:16:13 -07:00
2018-06-11 10:16:13 -07:00
2018-07-27 09:57:23 +10:00
2018-06-28 20:32:51 +09:00
2018-06-07 17:34:37 -07:00
2018-06-04 10:58:12 -07:00
2018-06-18 11:22:54 -06:00
2018-06-22 13:43:27 +09:00
2018-06-22 13:43:27 +09:00
2018-06-21 17:39:18 +02:00
2018-08-18 11:44:53 -07:00
2018-06-21 12:33:21 +02:00
2018-07-12 21:35:28 +02:00
2018-08-15 22:06:26 -07:00
2018-06-05 08:50:16 -04:00
2018-06-07 17:34:35 -07:00
2018-06-08 17:21:52 -07:00
2018-08-17 11:32:50 -07:00
2018-06-07 17:34:39 -07:00
2018-07-10 17:22:35 +02:00
2018-06-07 17:34:36 -07:00
2018-08-15 14:59:03 -05:00
2018-07-19 11:34:23 +01:00
2018-08-16 09:21:54 -07:00
2018-06-07 17:34:35 -07:00
2018-07-25 13:41:22 -07:00
2018-07-20 01:11:45 +02:00
2018-08-02 17:33:06 -04:00
2018-07-17 09:27:43 +02:00
2018-08-02 17:16:05 +02:00
2018-06-29 08:48:06 -06:00
2018-06-07 17:34:35 -07:00
2018-07-07 17:25:23 +02:00
2018-07-03 09:20:44 +02:00
2018-08-16 12:14:42 -07:00
2018-06-20 11:35:56 +02:00
2018-08-14 16:39:13 -07:00
2018-08-18 11:44:53 -07:00
2018-06-05 16:14:12 -07:00