All of lore.kernel.org
 help / color / mirror / Atom feed
From: qiuxishi@huawei.com (Xishi Qiu)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] Memory hotplug support for arm64 platform
Date: Thu, 15 Dec 2016 14:18:00 +0800	[thread overview]
Message-ID: <58523598.3080902@huawei.com> (raw)
In-Reply-To: <1481717765-31186-1-git-send-email-m.bielski@virtualopensystems.com>

On 2016/12/14 20:16, Maciej Bielski wrote:

> 
>  
> -#ifdef CONFIG_MEMORY_HOTREMOVE
> -int arch_remove_memory(u64 start, u64 size)
> -{
> -	unsigned long start_pfn = start >> PAGE_SHIFT;
> -	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
> -	int ret;
> +		SetPageReserved(pfn_to_page(pfn));
> +	}

Hi Maciej,

Why we need to set reserved here?
I think the new pages are already reserved in __add_zone() -> memmap_init_zone(), right?

Thanks,
Xishi Qiu

>  
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	ret = __remove_pages(zone, start_pfn, nr_pages);
>  	if (ret)
> -		pr_warn("%s: Problem encountered in __remove_pages() ret=%d\n",
> +		pr_warn("%s: Problem encountered in __add_pages() ret=%d\n",
>  			__func__, ret);
>  
>  	return ret;
>  }
>  #endif
> -#endif
>  
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 05615a3..9efa7d1 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -493,6 +493,30 @@ void __init paging_init(void)
>  		      SWAPPER_DIR_SIZE - PAGE_SIZE);
>  }
>  
> +#ifdef CONFIG_MEMORY_HOTPLUG
> +/*
> + * hotplug_paging() is used by memory hotplug to build new page tables
> + * for hot added memory.
> + */
> +void hotplug_paging(phys_addr_t start, phys_addr_t size)
> +{
> +	phys_addr_t pgd_phys = pgd_pgtable_alloc();
> +	pgd_t *pgd = pgd_set_fixmap(pgd_phys);
> +
> +	memcpy(pgd, swapper_pg_dir, PAGE_SIZE);
> +
> +	__create_pgd_mapping(pgd, start, __phys_to_virt(start), size,
> +			PAGE_KERNEL, pgd_pgtable_alloc, false);
> +
> +	cpu_replace_ttbr1(__va(pgd_phys));
> +	memcpy(swapper_pg_dir, pgd, PAGE_SIZE);
> +	cpu_replace_ttbr1(swapper_pg_dir);
> +
> +	pgd_clear_fixmap();
> +	memblock_free(pgd_phys, PAGE_SIZE);
> +}
> +#endif
> +
>  /*
>   * Check whether a kernel address is valid (derived from arch/x86/).
>   */
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index 5b759c9..5f78257 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -92,6 +92,7 @@ int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size);
>  int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
>  int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
>  int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
> +int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
>  ulong choose_memblock_flags(void);
>  
>  /* Low level functions */
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 7608bc3..05e7676 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -814,6 +814,16 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)
>  }
>  
>  /**
> + * memblock_clear_nomap - Clear a flag of MEMBLOCK_NOMAP memory region
> + * @base: the base phys addr of the region
> + * @size: the size of the region
> + */
> +int __init_memblock memblock_clear_nomap(phys_addr_t base, phys_addr_t size)
> +{
> +	return memblock_setclr_flag(base, size, 0, MEMBLOCK_NOMAP);
> +}
> +
> +/**
>   * __next_reserved_mem_region - next function for for_each_reserved_region()
>   * @idx: pointer to u64 loop variable
>   * @out_start: ptr to phys_addr_t for start address of the region, can be %NULL

WARNING: multiple messages have this Message-ID (diff)
From: Xishi Qiu <qiuxishi@huawei.com>
To: Maciej Bielski <m.bielski@virtualopensystems.com>
Cc: <scott.branden@broadcom.com>, <will.deacon@arm.com>,
	<ar@linux.vnet.ibm.com>, <tech@virtualopensystems.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] Memory hotplug support for arm64 platform
Date: Thu, 15 Dec 2016 14:18:00 +0800	[thread overview]
Message-ID: <58523598.3080902@huawei.com> (raw)
In-Reply-To: <1481717765-31186-1-git-send-email-m.bielski@virtualopensystems.com>

On 2016/12/14 20:16, Maciej Bielski wrote:

> 
>  
> -#ifdef CONFIG_MEMORY_HOTREMOVE
> -int arch_remove_memory(u64 start, u64 size)
> -{
> -	unsigned long start_pfn = start >> PAGE_SHIFT;
> -	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
> -	int ret;
> +		SetPageReserved(pfn_to_page(pfn));
> +	}

Hi Maciej,

Why we need to set reserved here?
I think the new pages are already reserved in __add_zone() -> memmap_init_zone(), right?

Thanks,
Xishi Qiu

>  
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	ret = __remove_pages(zone, start_pfn, nr_pages);
>  	if (ret)
> -		pr_warn("%s: Problem encountered in __remove_pages() ret=%d\n",
> +		pr_warn("%s: Problem encountered in __add_pages() ret=%d\n",
>  			__func__, ret);
>  
>  	return ret;
>  }
>  #endif
> -#endif
>  
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 05615a3..9efa7d1 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -493,6 +493,30 @@ void __init paging_init(void)
>  		      SWAPPER_DIR_SIZE - PAGE_SIZE);
>  }
>  
> +#ifdef CONFIG_MEMORY_HOTPLUG
> +/*
> + * hotplug_paging() is used by memory hotplug to build new page tables
> + * for hot added memory.
> + */
> +void hotplug_paging(phys_addr_t start, phys_addr_t size)
> +{
> +	phys_addr_t pgd_phys = pgd_pgtable_alloc();
> +	pgd_t *pgd = pgd_set_fixmap(pgd_phys);
> +
> +	memcpy(pgd, swapper_pg_dir, PAGE_SIZE);
> +
> +	__create_pgd_mapping(pgd, start, __phys_to_virt(start), size,
> +			PAGE_KERNEL, pgd_pgtable_alloc, false);
> +
> +	cpu_replace_ttbr1(__va(pgd_phys));
> +	memcpy(swapper_pg_dir, pgd, PAGE_SIZE);
> +	cpu_replace_ttbr1(swapper_pg_dir);
> +
> +	pgd_clear_fixmap();
> +	memblock_free(pgd_phys, PAGE_SIZE);
> +}
> +#endif
> +
>  /*
>   * Check whether a kernel address is valid (derived from arch/x86/).
>   */
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index 5b759c9..5f78257 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -92,6 +92,7 @@ int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size);
>  int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
>  int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
>  int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
> +int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
>  ulong choose_memblock_flags(void);
>  
>  /* Low level functions */
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 7608bc3..05e7676 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -814,6 +814,16 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)
>  }
>  
>  /**
> + * memblock_clear_nomap - Clear a flag of MEMBLOCK_NOMAP memory region
> + * @base: the base phys addr of the region
> + * @size: the size of the region
> + */
> +int __init_memblock memblock_clear_nomap(phys_addr_t base, phys_addr_t size)
> +{
> +	return memblock_setclr_flag(base, size, 0, MEMBLOCK_NOMAP);
> +}
> +
> +/**
>   * __next_reserved_mem_region - next function for for_each_reserved_region()
>   * @idx: pointer to u64 loop variable
>   * @out_start: ptr to phys_addr_t for start address of the region, can be %NULL

  reply	other threads:[~2016-12-15  6:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14 12:16 [RFC PATCH] Memory hotplug support for arm64 platform Maciej Bielski
2016-12-14 12:16 ` Maciej Bielski
2016-12-15  6:18 ` Xishi Qiu [this message]
2016-12-15  6:18   ` Xishi Qiu
2016-12-15  6:40   ` Xishi Qiu
2016-12-15  6:40     ` Xishi Qiu
2016-12-15 18:31     ` Andrea Reale
2016-12-15 18:31       ` Andrea Reale
2016-12-16  1:31       ` Xishi Qiu
2016-12-16  1:31         ` Xishi Qiu
2016-12-20 19:12 ` Scott Branden
2016-12-20 19:12   ` Scott Branden
2016-12-21  9:44   ` Maciej Bielski
2016-12-21  9:44     ` Maciej Bielski
2016-12-22  1:20     ` Scott Branden
2016-12-22  1:20       ` Scott Branden
2017-02-06 11:17       ` Andrea Reale
2017-02-06 11:17         ` Andrea Reale
2017-02-08 20:08         ` Scott Branden
2017-02-08 20:08           ` Scott Branden
2017-03-30  0:40         ` Florian Fainelli
2017-03-30  0:40           ` Florian Fainelli
2017-03-31 14:16           ` Andrea Reale
2017-03-31 14:16             ` Andrea Reale

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=58523598.3080902@huawei.com \
    --to=qiuxishi@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.