linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jianguo Wu <wujianguo@huawei.com>
To: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
Cc: akpm@linux-foundation.org, jiang.liu@huawei.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	iamjoonsoo.kim@lge.com, hannes@cmpxchg.org,
	tangchen@cn.fujitsu.com, tj@kernel.org, toshi.kani@hp.com
Subject: Re: [PATCH 2/2] mm: free memblock.memory in free_all_bootmem
Date: Wed, 8 Jan 2014 12:08:04 +0800	[thread overview]
Message-ID: <52CCCF24.4080300@huawei.com> (raw)
In-Reply-To: <1389107774-54978-3-git-send-email-phacht@linux.vnet.ibm.com>

On 2014/1/7 23:16, Philipp Hachtmann wrote:

> When calling free_all_bootmem() the free areas under memblock's
> control are released to the buddy allocator. Additionally the
> reserved list is freed if it was reallocated by memblock.
> The same should apply for the memory list.
> 
> Signed-off-by: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
> ---
>  include/linux/memblock.h |  1 +
>  mm/memblock.c            | 12 ++++++++++++
>  mm/nobootmem.c           |  7 ++++++-
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index 77c60e5..d174922 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -52,6 +52,7 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end,
>  phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
>  				   phys_addr_t size, phys_addr_t align);
>  phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
> +phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
>  void memblock_allow_resize(void);
>  int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
>  int memblock_add(phys_addr_t base, phys_addr_t size);
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 53e477b..1a11d04 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -271,6 +271,18 @@ phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
>  			  memblock.reserved.max);
>  }
>  
> +phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
> +					phys_addr_t *addr)
> +{
> +	if (memblock.memory.regions == memblock_memory_init_regions)
> +		return 0;
> +
> +	*addr = __pa(memblock.memory.regions);
> +
> +	return PAGE_ALIGN(sizeof(struct memblock_region) *
> +			  memblock.memory.max);
> +}
> +
>  /**
>   * memblock_double_array - double the size of the memblock regions array
>   * @type: memblock type of the regions array being doubled
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index 3a7e14d..83f36d3 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -122,11 +122,16 @@ static unsigned long __init free_low_memory_core_early(void)
>  	for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL)
>  		count += __free_memory_core(start, end);
>  
> -	/* free range that is used for reserved array if we allocate it */
> +	/* Free memblock.reserved array if it was allocated */
>  	size = get_allocated_memblock_reserved_regions_info(&start);
>  	if (size)
>  		count += __free_memory_core(start, start + size);
>  
> +	/* Free memblock.memory array if it was allocated */
> +	size = get_allocated_memblock_memory_regions_info(&start);
> +	if (size)
> +		count += __free_memory_core(start, start + size);
> +

Hi Philipp,

For some archs, like arm64, would use memblock.memory after system booting,
so we can not simply released to the buddy allocator, maybe need !defined(CONFIG_ARCH_DISCARD_MEMBLOCK).

#ifdef CONFIG_HAVE_ARCH_PFN_VALID
int pfn_valid(unsigned long pfn)
{
	return memblock_is_memory(pfn << PAGE_SHIFT);
}
EXPORT_SYMBOL(pfn_valid);

Thanks,
Jianguo Wu

>  	return count;
>  }
>  



--
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>

  parent reply	other threads:[~2014-01-08  4:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 15:16 [PATCH 0/2] Small fixes to memblock and nobootmem Philipp Hachtmann
2014-01-07 15:16 ` [PATCH 1/2] mm, nobootmem: Add return value check in __alloc_memory_core_early() Philipp Hachtmann
2014-01-07 15:19   ` Tejun Heo
2014-01-07 15:16 ` [PATCH 2/2] mm: free memblock.memory in free_all_bootmem Philipp Hachtmann
2014-01-07 15:23   ` Tejun Heo
2014-01-08  4:08   ` Jianguo Wu [this message]
2014-01-08 13:42     ` Philipp Hachtmann
2014-01-08 23:30       ` Yinghai Lu

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=52CCCF24.4080300@huawei.com \
    --to=wujianguo@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=phacht@linux.vnet.ibm.com \
    --cc=tangchen@cn.fujitsu.com \
    --cc=tj@kernel.org \
    --cc=toshi.kani@hp.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