From: Michal Hocko <mhocko@kernel.org>
To: osalvador@techadventures.net
Cc: akpm@linux-foundation.org, pasha.tatashin@oracle.com,
vbabka@suse.cz, aaron.lu@intel.com, iamjoonsoo.kim@lge.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Oscar Salvador <osalvador@suse.de>
Subject: Re: [PATCH v2 3/5] mm/page_alloc: Optimize free_area_init_core
Date: Thu, 19 Jul 2018 15:44:17 +0200 [thread overview]
Message-ID: <20180719134417.GC7193@dhcp22.suse.cz> (raw)
In-Reply-To: <20180719132740.32743-4-osalvador@techadventures.net>
On Thu 19-07-18 15:27:38, osalvador@techadventures.net wrote:
> From: Oscar Salvador <osalvador@suse.de>
>
> In free_area_init_core we calculate the amount of managed pages
> we are left with, by substracting the memmap pages and the pages
> reserved for dma.
> With the values left, we also account the total of kernel pages and
> the total of pages.
>
> Since memmap pages are calculated from zone->spanned_pages,
> let us only do these calculcations whenever zone->spanned_pages is greather
> than 0.
But why do we care? How do we test this? In other words, why is this
worth merging?
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
> mm/page_alloc.c | 73 ++++++++++++++++++++++++++++++---------------------------
> 1 file changed, 38 insertions(+), 35 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 10b754fba5fa..f7a6f4e13f41 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6237,6 +6237,40 @@ static void pgdat_init_kcompactd(struct pglist_data *pgdat)
> static void pgdat_init_kcompactd(struct pglist_data *pgdat) {}
> #endif
>
> +static unsigned long calc_remaining_pages(enum zone_type type, unsigned long freesize,
> + unsigned long size)
> +{
> + unsigned long memmap_pages = calc_memmap_size(size, freesize);
> +
> + if(!is_highmem_idx(type)) {
> + if (freesize >= memmap_pages) {
> + freesize -= memmap_pages;
> + if (memmap_pages)
> + printk(KERN_DEBUG
> + " %s zone: %lu pages used for memmap\n",
> + zone_names[type], memmap_pages);
> + } else
> + pr_warn(" %s zone: %lu pages exceeds freesize %lu\n",
> + zone_names[type], memmap_pages, freesize);
> + }
> +
> + /* Account for reserved pages */
> + if (type == 0 && freesize > dma_reserve) {
> + freesize -= dma_reserve;
> + printk(KERN_DEBUG " %s zone: %lu pages reserved\n",
> + zone_names[0], dma_reserve);
> + }
> +
> + if (!is_highmem_idx(type))
> + nr_kernel_pages += freesize;
> + /* Charge for highmem memmap if there are enough kernel pages */
> + else if (nr_kernel_pages > memmap_pages * 2)
> + nr_kernel_pages -= memmap_pages;
> + nr_all_pages += freesize;
> +
> + return freesize;
> +}
> +
> /*
> * Set up the zone data structures:
> * - mark all pages reserved
> @@ -6267,43 +6301,12 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)
>
> for (j = 0; j < MAX_NR_ZONES; j++) {
> struct zone *zone = pgdat->node_zones + j;
> - unsigned long size, freesize, memmap_pages;
> + unsigned long size = zone->spanned_pages;
> + unsigned long freesize = zone->present_pages;
> unsigned long zone_start_pfn = zone->zone_start_pfn;
>
> - size = zone->spanned_pages;
> - freesize = zone->present_pages;
> -
> - /*
> - * Adjust freesize so that it accounts for how much memory
> - * is used by this zone for memmap. This affects the watermark
> - * and per-cpu initialisations
> - */
> - memmap_pages = calc_memmap_size(size, freesize);
> - if (!is_highmem_idx(j)) {
> - if (freesize >= memmap_pages) {
> - freesize -= memmap_pages;
> - if (memmap_pages)
> - printk(KERN_DEBUG
> - " %s zone: %lu pages used for memmap\n",
> - zone_names[j], memmap_pages);
> - } else
> - pr_warn(" %s zone: %lu pages exceeds freesize %lu\n",
> - zone_names[j], memmap_pages, freesize);
> - }
> -
> - /* Account for reserved pages */
> - if (j == 0 && freesize > dma_reserve) {
> - freesize -= dma_reserve;
> - printk(KERN_DEBUG " %s zone: %lu pages reserved\n",
> - zone_names[0], dma_reserve);
> - }
> -
> - if (!is_highmem_idx(j))
> - nr_kernel_pages += freesize;
> - /* Charge for highmem memmap if there are enough kernel pages */
> - else if (nr_kernel_pages > memmap_pages * 2)
> - nr_kernel_pages -= memmap_pages;
> - nr_all_pages += freesize;
> + if (size)
> + freesize = calc_remaining_pages(j, freesize, size);
>
> /*
> * Set an approximate value for lowmem here, it will be adjusted
> --
> 2.13.6
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2018-07-19 13:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 13:27 [PATCH v2 0/5] Refactor free_area_init_node/free_area_init_core osalvador
2018-07-19 13:27 ` [PATCH v2 1/5] mm/page_alloc: Move ifdefery out of free_area_init_core osalvador
2018-07-19 13:27 ` [PATCH v2 2/5] mm: access zone->node via zone_to_nid() and zone_set_nid() osalvador
2018-07-19 13:40 ` Michal Hocko
2018-07-19 13:44 ` Pavel Tatashin
2018-07-19 13:47 ` Michal Hocko
2018-07-19 13:27 ` [PATCH v2 3/5] mm/page_alloc: Optimize free_area_init_core osalvador
2018-07-19 13:44 ` Michal Hocko [this message]
2018-07-19 14:03 ` Oscar Salvador
2018-07-19 15:15 ` Michal Hocko
2018-07-19 20:52 ` Oscar Salvador
2018-07-20 10:03 ` Oscar Salvador
2018-07-23 8:35 ` Michal Hocko
2018-07-23 11:42 ` Oscar Salvador
2018-07-23 8:30 ` Michal Hocko
2018-07-19 13:27 ` [PATCH v2 4/5] mm/page_alloc: Inline function to handle CONFIG_DEFERRED_STRUCT_PAGE_INIT osalvador
2018-07-19 13:45 ` Michal Hocko
2018-07-19 13:27 ` [PATCH v2 5/5] mm/page_alloc: Only call pgdat_set_deferred_range when the system boots osalvador
2018-07-19 13:46 ` Michal Hocko
2018-07-19 13:58 ` Oscar Salvador
2018-07-19 14:03 ` Michal Hocko
2018-07-19 14:27 ` Pavel Tatashin
2018-07-19 15:01 ` Oscar Salvador
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180719134417.GC7193@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=aaron.lu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=osalvador@techadventures.net \
--cc=pasha.tatashin@oracle.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).