linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>,
	mark.rutland@arm.com, david@redhat.com, catalin.marinas@arm.com,
	linux-mm@kvack.org, arunks@codeaurora.org,
	cpandya@codeaurora.org, will@kernel.org, ira.weiny@intel.com,
	steven.price@arm.com, valentin.schneider@arm.com,
	suzuki.poulose@arm.com, robin.murphy@arm.com, broonie@kernel.org,
	cai@lca.pw, ard.biesheuvel@arm.com, dan.j.williams@intel.com,
	linux-arm-kernel@lists.infradead.org, osalvador@suse.de,
	steve.capper@arm.com, logang@deltatee.com,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	mgorman@techsingularity.net
Subject: Re: [PATCH V11 2/5] mm/memblock: Introduce MEMBLOCK_BOOT flag
Date: Mon, 13 Jan 2020 09:57:09 +0100	[thread overview]
Message-ID: <12BCAD36-D99C-4AC0-B466-06E1A02DDD72@redhat.com> (raw)
In-Reply-To: <08a2f82a-3201-055a-316a-a2f11c7ff7a5@arm.com>



> Am 13.01.2020 um 09:41 schrieb Anshuman Khandual <anshuman.khandual@arm.com>:
> 
> 
> 
>> On 01/13/2020 01:07 PM, Mike Rapoport wrote:
>>> On Fri, Jan 10, 2020 at 08:39:12AM +0530, Anshuman Khandual wrote:
>>> On arm64 platform boot memory should never be hot removed due to certain
>>> platform specific constraints. Hence the platform would like to override
>>> earlier added arch call back arch_memory_removable() for this purpose. In
>>> order to reject boot memory hot removal request, it needs to first track
>>> them at runtime. In the future, there might be other platforms requiring
>>> runtime boot memory enumeration. Hence lets expand the existing generic
>>> memblock framework for this purpose rather then creating one just for
>>> arm64 platforms.
>>> 
>>> This introduces a new memblock flag MEMBLOCK_BOOT along with helpers which
>>> can be marked by given platform on all memory regions discovered during
>>> boot.
>> 
>> We already have MEMBLOCK_HOTPLUG to mark hotpluggable region. Can't we use
>> it for your use-case?
> 
> At present MEMBLOCK_HOTPLUG flag helps in identifying parts of boot memory
> as hotpluggable as indicated by the firmware. This information is then used
> to avoid those regions during standard memblock_alloc_*() API requests and
> later marking them as ZONE_MOVABLE when buddy gets initialized.
> 
> Memory hot remove does not check for MEMBLOCK_HOTPLUG flag as a requirement
> before initiating the process. We could probably use this flag if generic
> hot remove can be changed to check for MEMBLOCK_HOTPLUG as a prerequisite
> which will require changes to memblock handling (boot and runtime) on all
> existing platforms currently supporting hot remove. But what about handling
> the movable boot memory created with movablecore/kernelcore command line,
> should generic MM update their memblock regions with MEMBLOCK_HOTPLUG ?

As I said in my other mail, just disallow offlining of the affected (boot) memory blocks using a memory notifier and you should be good to go. No changes in memory unplug code required.

> 
>> 
>>> Cc: Mike Rapoport <rppt@linux.ibm.com>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>> ---
>>> include/linux/memblock.h | 10 ++++++++++
>>> mm/memblock.c            | 37 +++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 47 insertions(+)
>>> 
>>> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
>>> index b38bbef..fb04c87 100644
>>> --- a/include/linux/memblock.h
>>> +++ b/include/linux/memblock.h
>>> @@ -31,12 +31,14 @@ extern unsigned long long max_possible_pfn;
>>>  * @MEMBLOCK_HOTPLUG: hotpluggable region
>>>  * @MEMBLOCK_MIRROR: mirrored region
>>>  * @MEMBLOCK_NOMAP: don't add to kernel direct mapping
>>> + * @MEMBLOCK_BOOT: memory received from firmware during boot
>>>  */
>>> enum memblock_flags {
>>>    MEMBLOCK_NONE        = 0x0,    /* No special request */
>>>    MEMBLOCK_HOTPLUG    = 0x1,    /* hotpluggable region */
>>>    MEMBLOCK_MIRROR        = 0x2,    /* mirrored region */
>>>    MEMBLOCK_NOMAP        = 0x4,    /* don't add to kernel direct mapping */
>>> +    MEMBLOCK_BOOT        = 0x8,    /* memory received from firmware during boot */
>>> };
>>> 
>>> /**
>>> @@ -116,6 +118,8 @@ int memblock_reserve(phys_addr_t base, phys_addr_t size);
>>> void memblock_trim_memory(phys_addr_t align);
>>> bool memblock_overlaps_region(struct memblock_type *type,
>>>                  phys_addr_t base, phys_addr_t size);
>>> +int memblock_mark_boot(phys_addr_t base, phys_addr_t size);
>>> +int memblock_clear_boot(phys_addr_t base, phys_addr_t size);
>>> 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);
>>> @@ -216,6 +220,11 @@ static inline bool memblock_is_nomap(struct memblock_region *m)
>>>    return m->flags & MEMBLOCK_NOMAP;
>>> }
>>> 
>>> +static inline bool memblock_is_boot(struct memblock_region *m)
>>> +{
>>> +    return m->flags & MEMBLOCK_BOOT;
>>> +}
>>> +
>>> #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
>>> int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn,
>>>                unsigned long  *end_pfn);
>>> @@ -449,6 +458,7 @@ void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size);
>>> void memblock_mem_limit_remove_map(phys_addr_t limit);
>>> bool memblock_is_memory(phys_addr_t addr);
>>> bool memblock_is_map_memory(phys_addr_t addr);
>>> +bool memblock_is_boot_memory(phys_addr_t addr);
>>> bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
>>> bool memblock_is_reserved(phys_addr_t addr);
>>> bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
>>> diff --git a/mm/memblock.c b/mm/memblock.c
>>> index 4bc2c7d..e10207f 100644
>>> --- a/mm/memblock.c
>>> +++ b/mm/memblock.c
>>> @@ -865,6 +865,30 @@ static int __init_memblock memblock_setclr_flag(phys_addr_t base,
>>> }
>>> 
>>> /**
>>> + * memblock_mark_bootmem - Mark boot memory with flag MEMBLOCK_BOOT.
>>> + * @base: the base phys addr of the region
>>> + * @size: the size of the region
>>> + *
>>> + * Return: 0 on success, -errno on failure.
>>> + */
>>> +int __init_memblock memblock_mark_boot(phys_addr_t base, phys_addr_t size)
>>> +{
>>> +    return memblock_setclr_flag(base, size, 1, MEMBLOCK_BOOT);
>>> +}
>>> +
>>> +/**
>>> + * memblock_clear_bootmem - Clear flag MEMBLOCK_BOOT for a specified region.
>>> + * @base: the base phys addr of the region
>>> + * @size: the size of the region
>>> + *
>>> + * Return: 0 on success, -errno on failure.
>>> + */
>>> +int __init_memblock memblock_clear_boot(phys_addr_t base, phys_addr_t size)
>>> +{
>>> +    return memblock_setclr_flag(base, size, 0, MEMBLOCK_BOOT);
>>> +}
>>> +
>>> +/**
>>>  * memblock_mark_hotplug - Mark hotpluggable memory with flag MEMBLOCK_HOTPLUG.
>>>  * @base: the base phys addr of the region
>>>  * @size: the size of the region
>>> @@ -974,6 +998,10 @@ static bool should_skip_region(struct memblock_region *m, int nid, int flags)
>>>    if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m))
>>>        return true;
>>> 
>>> +    /* if we want boot memory skip non-boot memory regions */
>>> +    if ((flags & MEMBLOCK_BOOT) && !memblock_is_boot(m))
>>> +        return true;
>>> +
>>>    /* skip nomap memory unless we were asked for it explicitly */
>>>    if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m))
>>>        return true;
>>> @@ -1785,6 +1813,15 @@ bool __init_memblock memblock_is_map_memory(phys_addr_t addr)
>>>    return !memblock_is_nomap(&memblock.memory.regions[i]);
>>> }
>>> 
>>> +bool __init_memblock memblock_is_boot_memory(phys_addr_t addr)
>>> +{
>>> +    int i = memblock_search(&memblock.memory, addr);
>>> +
>>> +    if (i == -1)
>>> +        return false;
>>> +    return memblock_is_boot(&memblock.memory.regions[i]);
>>> +}
>>> +
>>> #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
>>> int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
>>>             unsigned long *start_pfn, unsigned long *end_pfn)
>>> -- 
>>> 2.7.4
>>> 
>> 
> 



  reply	other threads:[~2020-01-13  8:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  3:09 [PATCH V11 0/5] arm64/mm: Enable memory hot remove Anshuman Khandual
2020-01-10  3:09 ` [PATCH V11 1/5] mm/hotplug: Introduce arch callback validating the hot remove range Anshuman Khandual
2020-01-10  8:42   ` David Hildenbrand
2020-01-13  9:11     ` Anshuman Khandual
2020-01-13  9:14       ` David Hildenbrand
2020-01-13  9:50         ` Anshuman Khandual
2020-01-13 10:37           ` David Hildenbrand
2020-01-14  2:13             ` Anshuman Khandual
2020-01-14 11:09               ` Anshuman Khandual
2020-01-14 12:30                 ` David Hildenbrand
2020-01-11 14:11   ` kbuild test robot
2020-01-13  4:06     ` Anshuman Khandual
2020-01-11 19:49   ` kbuild test robot
2020-01-10  3:09 ` [PATCH V11 2/5] mm/memblock: Introduce MEMBLOCK_BOOT flag Anshuman Khandual
2020-01-13  7:37   ` Mike Rapoport
2020-01-13  8:43     ` Anshuman Khandual
2020-01-13  8:57       ` David Hildenbrand [this message]
2020-01-10  3:09 ` [PATCH V11 3/5] of/fdt: Mark boot memory with MEMBLOCK_BOOT Anshuman Khandual
2020-01-10  3:09 ` [PATCH V11 4/5] arm64/mm: Hold memory hotplug lock while walking for kernel page table dump Anshuman Khandual
2020-01-10  3:09 ` [PATCH V11 5/5] arm64/mm: Enable memory hot remove Anshuman Khandual

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=12BCAD36-D99C-4AC0-B466-06E1A02DDD72@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ard.biesheuvel@arm.com \
    --cc=arunks@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=cai@lca.pw \
    --cc=catalin.marinas@arm.com \
    --cc=cpandya@codeaurora.org \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=logang@deltatee.com \
    --cc=mark.rutland@arm.com \
    --cc=mgorman@techsingularity.net \
    --cc=osalvador@suse.de \
    --cc=robin.murphy@arm.com \
    --cc=rppt@linux.ibm.com \
    --cc=steve.capper@arm.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=valentin.schneider@arm.com \
    --cc=will@kernel.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 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).