linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Baoquan He <bhe@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	pagupta@redhat.com
Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com
Subject: Re: [PATCH v4 4/4] mm/sparse: Optimize memmap allocation during sparse_init()
Date: Thu, 7 Jun 2018 15:46:03 -0700	[thread overview]
Message-ID: <766d4f69-befe-5219-9ede-6c9927f12f0a@intel.com> (raw)
In-Reply-To: <20180521101555.25610-5-bhe@redhat.com>

> @@ -297,8 +298,8 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
>  		if (!present_section_nr(pnum))
>  			continue;
>  
> -		map_map[pnum] = sparse_mem_map_populate(pnum, nodeid, NULL);
> -		if (map_map[pnum])
> +		map_map[nr_consumed_maps] = sparse_mem_map_populate(pnum, nodeid, NULL);
> +		if (map_map[nr_consumed_maps++])
>  			continue;
...

This looks wonky.

This seems to say that even if we fail to sparse_mem_map_populate() (it
returns NULL), we still consume a map.  Is that right?

>  	/* fallback */
> +	nr_consumed_maps = 0;
>  	for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
>  		struct mem_section *ms;
>  
>  		if (!present_section_nr(pnum))
>  			continue;
> -		map_map[pnum] = sparse_mem_map_populate(pnum, nodeid, NULL);
> -		if (map_map[pnum])
> +		map_map[nr_consumed_maps] = sparse_mem_map_populate(pnum, nodeid, NULL);
> +		if (map_map[nr_consumed_maps++])
>  			continue;

Same questionable pattern as above...

>  #ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER
> -	size2 = sizeof(struct page *) * NR_MEM_SECTIONS;
> +	size2 = sizeof(struct page *) * nr_present_sections;
>  	map_map = memblock_virt_alloc(size2, 0);
>  	if (!map_map)
>  		panic("can not allocate map_map\n");
> @@ -586,27 +594,44 @@ void __init sparse_init(void)
>  				sizeof(map_map[0]));
>  #endif
>  
> +	/* The numner of present sections stored in nr_present_sections

"number"?

Also, this is not correct comment CodingStyle.

> +	 * are kept the same since mem sections are marked as present in
> +	 * memory_present().

Are you just trying to say that we are not making sections present here?

>                         In this for loop, we need check which sections
> +	 * failed to allocate memmap or usemap, then clear its
> +	 * ->section_mem_map accordingly. During this process, we need
> +	 * increase 'alloc_usemap_and_memmap' whether its allocation of
> +	 * memmap or usemap failed or not, so that after we handle the i-th
> +	 * memory section, can get memmap and usemap of (i+1)-th section
> +	 * correctly. */

I'm really scratching my head over this comment.  For instance "increase
'alloc_usemap_and_memmap'" doesn't make any sense to me.  How do you
increase a function?

I wonder if you could give that comment another shot.

  reply	other threads:[~2018-06-07 22:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21 10:15 [PATCH v4 0/4] " Baoquan He
2018-05-21 10:15 ` [PATCH v4 1/4] mm/sparse: Add a static variable nr_present_sections Baoquan He
2018-06-07 22:46   ` Dave Hansen
2018-05-21 10:15 ` [PATCH v4 2/4] mm/sparsemem: Defer the ms->section_mem_map clearing Baoquan He
2018-06-07 22:47   ` Dave Hansen
2018-05-21 10:15 ` [PATCH v4 3/4] mm/sparse: Add a new parameter 'data_unit_size' for alloc_usemap_and_memmap Baoquan He
2018-06-07 22:48   ` Dave Hansen
2018-06-08  6:27     ` Baoquan He
2018-06-08 14:20       ` Dave Hansen
2018-06-08 15:17         ` Baoquan He
2018-06-08 16:13           ` Dave Hansen
2018-06-10 23:32             ` Baoquan He
2018-05-21 10:15 ` [PATCH v4 4/4] mm/sparse: Optimize memmap allocation during sparse_init() Baoquan He
2018-06-07 22:46   ` Dave Hansen [this message]
2018-06-08  7:28     ` Baoquan He
2018-06-08  7:41       ` Baoquan He
2018-06-07 22:17 ` [PATCH v4 0/4] " Andrew Morton

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=766d4f69-befe-5219-9ede-6c9927f12f0a@intel.com \
    --to=dave.hansen@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pagupta@redhat.com \
    /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