linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Wei Yang <richard.weiyang@gmail.com>,
	mhocko@suse.com, linux-mm@kvack.org
Subject: Re: [RFC PATCH 4/4] base/memory: pass start_section_nr to init_memory_block()
Date: Tue, 27 Jun 2017 00:11:52 -0700	[thread overview]
Message-ID: <ac2b2750-d673-ce91-cd48-fc95e41ae6f7@nvidia.com> (raw)
In-Reply-To: <20170625025227.45665-5-richard.weiyang@gmail.com>

On 06/24/2017 07:52 PM, Wei Yang wrote:
> The second parameter of init_memory_block() is to calculate the
> start_section_nr for the memory_block. While current implementation dose
> some unnecessary transform between mem_sectioni and section_nr.

Hi Wei,

I am unable to find anything wrong with this patch (except of course
that your top-level description in the "[PATCH 0/4" thread will need
to be added somewhere).

Here's a slight typo/grammar improvement for the patch
description above, if you like:

"The current implementation does some unnecessary conversions
between mem_section and section_nr."

thanks,
john h

> 
> This patch simplifies the function by just passing the start_section_nr to
> it. By doing so, we can also simplify add_memory_block() too.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>  drivers/base/memory.c  | 16 ++++++----------
>  include/linux/memory.h |  2 +-
>  mm/memory_hotplug.c    |  2 +-
>  3 files changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 468e5ad1bc87..43783dbb1d5e 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -645,7 +645,7 @@ int register_memory(struct memory_block *memory)
>  }
>  
>  static int init_memory_block(struct memory_block **memory,
> -			     struct mem_section *section, unsigned long state)
> +			     int start_section_nr, unsigned long state)
>  {
>  	struct memory_block *mem;
>  	unsigned long start_pfn;
> @@ -656,9 +656,7 @@ static int init_memory_block(struct memory_block **memory,
>  	if (!mem)
>  		return -ENOMEM;
>  
> -	scn_nr = __section_nr(section);
> -	mem->start_section_nr =
> -			base_memory_block_id(scn_nr) * sections_per_block;
> +	mem->start_section_nr = start_section_nr;
>  	mem->end_section_nr = mem->start_section_nr + sections_per_block - 1;
>  	mem->state = state;
>  	start_pfn = section_nr_to_pfn(mem->start_section_nr);
> @@ -673,21 +671,19 @@ static int init_memory_block(struct memory_block **memory,
>  static int add_memory_block(int base_section_nr)
>  {
>  	struct memory_block *mem;
> -	int i, ret, section_count = 0, section_nr;
> +	int i, ret, section_count = 0;
>  
>  	for (i = base_section_nr;
>  	     (i < base_section_nr + sections_per_block) && i < NR_MEM_SECTIONS;
>  	     i++) {
>  		if (!present_section_nr(i))
>  			continue;
> -		if (section_count == 0)
> -			section_nr = i;
>  		section_count++;
>  	}
>  
>  	if (section_count == 0)
>  		return 0;
> -	ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE);
> +	ret = init_memory_block(&mem, base_section_nr, MEM_ONLINE);
>  	if (ret)
>  		return ret;
>  	mem->section_count = section_count;
> @@ -698,14 +694,14 @@ static int add_memory_block(int base_section_nr)
>   * need an interface for the VM to add new memory regions,
>   * but without onlining it.
>   */
> -int register_new_memory(int nid, struct mem_section *section)
> +int register_new_memory(int nid, int start_section_nr)
>  {
>  	int ret = 0;
>  	struct memory_block *mem;
>  
>  	mutex_lock(&mem_sysfs_mutex);
>  
> -	ret = init_memory_block(&mem, section, MEM_OFFLINE);
> +	ret = init_memory_block(&mem, start_section_nr, MEM_OFFLINE);
>  	if (ret)
>  		goto out;
>  	mem->section_count = sections_per_block;
> diff --git a/include/linux/memory.h b/include/linux/memory.h
> index 51a6355aa56d..0cbde14f7cea 100644
> --- a/include/linux/memory.h
> +++ b/include/linux/memory.h
> @@ -108,7 +108,7 @@ extern int register_memory_notifier(struct notifier_block *nb);
>  extern void unregister_memory_notifier(struct notifier_block *nb);
>  extern int register_memory_isolate_notifier(struct notifier_block *nb);
>  extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
> -extern int register_new_memory(int, struct mem_section *);
> +extern int register_new_memory(int, int);
>  #ifdef CONFIG_MEMORY_HOTREMOVE
>  extern int unregister_memory_section(struct mem_section *);
>  #endif
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 14a08b980b59..fc198847dd5b 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -346,7 +346,7 @@ static int __meminit __add_memory_block(int nid, unsigned long phys_start_pfn,
>  	if (!want_memblock)
>  		return 0;
>  
> -	return register_new_memory(nid, __pfn_to_section(phys_start_pfn));
> +	return register_new_memory(nid, pfn_to_section_nr(phys_start_pfn));
>  }
>  
>  /*
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-06-27  7:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-25  2:52 [RFC PATCH 0/4] mm/hotplug: make hotplug memory_block alligned Wei Yang
2017-06-25  2:52 ` [RFC PATCH 1/4] mm/hotplug: aligne the hotplugable range with memory_block Wei Yang
2017-06-25  3:31   ` John Hubbard
2017-06-26  0:20     ` Wei Yang
2017-06-26  6:49       ` John Hubbard
2017-06-26 23:21         ` Wei Yang
2017-06-25  2:52 ` [RFC PATCH 2/4] mm/hotplug: walk_memroy_range on memory_block uit Wei Yang
2017-06-26  7:32   ` John Hubbard
2017-06-26 23:40     ` Wei Yang
2017-06-27  6:59       ` John Hubbard
2017-06-28  0:11         ` Wei Yang
2017-06-25  2:52 ` [RFC PATCH 3/4] mm/hotplug: make __add_pages() iterate on memory_block and split __add_section() Wei Yang
2017-06-26  7:50   ` John Hubbard
2017-06-26 23:53     ` Wei Yang
2017-06-27  6:47       ` John Hubbard
2017-06-28  0:16         ` Wei Yang
2017-06-28  0:22   ` Wei Yang
2017-06-25  2:52 ` [RFC PATCH 4/4] base/memory: pass start_section_nr to init_memory_block() Wei Yang
2017-06-27  7:11   ` John Hubbard [this message]
2017-06-28  0:18     ` Wei Yang
2017-06-26  7:46 ` [RFC PATCH 0/4] mm/hotplug: make hotplug memory_block alligned Michal Hocko
2017-06-27  2:13   ` Wei Yang
2017-06-28  9:43     ` Michal Hocko

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=ac2b2750-d673-ce91-cd48-fc95e41ae6f7@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=richard.weiyang@gmail.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;
as well as URLs for NNTP newsgroup(s).