All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	David Hildenbrand <dhildenb@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org,
	catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
	cai@lca.pw, logang@deltatee.com, cpandya@codeaurora.org,
	arunks@codeaurora.org, dan.j.williams@intel.com,
	mgorman@techsingularity.net, osalvador@suse.de,
	ard.biesheuvel@arm.com, steve.capper@arm.com, broonie@kernel.org,
	valentin.schneider@arm.com, robin.murphy@arm.com,
	steven.price@arm.com, suzuki.poulose@arm.com,
	ira.weiny@intel.com
Subject: Re: [PATCH V11 1/5] mm/hotplug: Introduce arch callback validating the hot remove range
Date: Mon, 13 Jan 2020 11:37:48 +0100	[thread overview]
Message-ID: <19194427-1295-3596-2c2c-463c4adf4f35@redhat.com> (raw)
In-Reply-To: <6b8fb779-31e8-1b63-85a8-9f6c93a04494@arm.com>

On 13.01.20 10:50, Anshuman Khandual wrote:
> 
> 
> On 01/13/2020 02:44 PM, David Hildenbrand wrote:
>>
>>
>>> Am 13.01.2020 um 10:10 schrieb Anshuman Khandual <anshuman.khandual@arm.com>:
>>>
>>> 
>>>
>>>> On 01/10/2020 02:12 PM, David Hildenbrand wrote:
>>>>> On 10.01.20 04:09, Anshuman Khandual wrote:
>>>>> Currently there are two interfaces to initiate memory range hot removal i.e
>>>>> remove_memory() and __remove_memory() which then calls try_remove_memory().
>>>>> Platform gets called with arch_remove_memory() to tear down required kernel
>>>>> page tables and other arch specific procedures. But there are platforms
>>>>> like arm64 which might want to prevent removal of certain specific memory
>>>>> ranges irrespective of their present usage or movability properties.
>>>>
>>>> Why? Is this only relevant for boot memory? I hope so, otherwise the
>>>> arch code needs fixing IMHO.
>>>
>>> Right, it is relevant only for the boot memory on arm64 platform. But this
>>> new arch callback makes it flexible to reject any given memory range.
>>>
>>>>
>>>> If it's only boot memory, we should disallow offlining instead via a
>>>> memory notifier - much cleaner.
>>>
>>> Dont have much detail understanding of MMU notifier mechanism but from some
>>> initial reading, it seems like we need to have a mm_struct for a notifier
>>> to monitor various events on the page table. Just wondering how a physical
>>> memory range like boot memory can be monitored because it can be used both
>>> for for kernel (init_mm) or user space process at same time. Is there some
>>> mechanism we could do this ?
>>>
>>>>
>>>>>
>>>>> Current arch call back arch_remove_memory() is too late in the process to
>>>>> abort memory hot removal as memory block devices and firmware memory map
>>>>> entries would have already been removed. Platforms should be able to abort
>>>>> the process before taking the mem_hotplug_lock with mem_hotplug_begin().
>>>>> This essentially requires a new arch callback for memory range validation.
>>>>
>>>> I somewhat dislike this very much. Memory removal should never fail if
>>>> used sanely. See e.g., __remove_memory(), it will BUG() whenever
>>>> something like that would strike.
>>>>
>>>>>
>>>>> This differentiates memory range validation between memory hot add and hot
>>>>> remove paths before carving out a new helper check_hotremove_memory_range()
>>>>> which incorporates a new arch callback. This call back provides platforms
>>>>> an opportunity to refuse memory removal at the very onset. In future the
>>>>> same principle can be extended for memory hot add path if required.
>>>>>
>>>>> Platforms can choose to override this callback in order to reject specific
>>>>> memory ranges from removal or can just fallback to a default implementation
>>>>> which allows removal of all memory ranges.
>>>>
>>>> I suspect we want really want to disallow offlining instead. E.g., I
>>>
>>> If boot memory pages can be prevented from being offlined for sure, then it
>>> would indirectly definitely prevent hot remove process as well.
>>>
>>>> remember s390x does that with certain areas needed for dumping/kexec.
>>>
>>> Could not find any references to mmu_notifier in arch/s390 or any other arch
>>> for that matter apart from KVM (which has an user space component), could you
>>> please give some pointers ?
>>
>> Memory (hotplug) notifier, not MMU notifier :)
> 
> They are so similarly named :)
> 
>>
>> Not on my notebook right now, grep for MEM_GOING_OFFLINE, that should be it.
>>
> 
> Got it, thanks ! But we will still need boot memory enumeration via MEMBLOCK_BOOT
> to reject affected offline requests in the callback.

Do you really need that?

We have SECTION_IS_EARLY. You could iterate all involved sections (for
which you are getting notified) and check if any one of these is marked
SECTION_IS_EARLY. then, it was added during boot and not via add_memory().


-- 
Thanks,

David / dhildenb


WARNING: multiple messages have this Message-ID (diff)
From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
	David Hildenbrand <dhildenb@redhat.com>
Cc: mark.rutland@arm.com, catalin.marinas@arm.com,
	linux-mm@kvack.org, arunks@codeaurora.org,
	cpandya@codeaurora.org, ira.weiny@intel.com, will@kernel.org,
	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 1/5] mm/hotplug: Introduce arch callback validating the hot remove range
Date: Mon, 13 Jan 2020 11:37:48 +0100	[thread overview]
Message-ID: <19194427-1295-3596-2c2c-463c4adf4f35@redhat.com> (raw)
In-Reply-To: <6b8fb779-31e8-1b63-85a8-9f6c93a04494@arm.com>

On 13.01.20 10:50, Anshuman Khandual wrote:
> 
> 
> On 01/13/2020 02:44 PM, David Hildenbrand wrote:
>>
>>
>>> Am 13.01.2020 um 10:10 schrieb Anshuman Khandual <anshuman.khandual@arm.com>:
>>>
>>> 
>>>
>>>> On 01/10/2020 02:12 PM, David Hildenbrand wrote:
>>>>> On 10.01.20 04:09, Anshuman Khandual wrote:
>>>>> Currently there are two interfaces to initiate memory range hot removal i.e
>>>>> remove_memory() and __remove_memory() which then calls try_remove_memory().
>>>>> Platform gets called with arch_remove_memory() to tear down required kernel
>>>>> page tables and other arch specific procedures. But there are platforms
>>>>> like arm64 which might want to prevent removal of certain specific memory
>>>>> ranges irrespective of their present usage or movability properties.
>>>>
>>>> Why? Is this only relevant for boot memory? I hope so, otherwise the
>>>> arch code needs fixing IMHO.
>>>
>>> Right, it is relevant only for the boot memory on arm64 platform. But this
>>> new arch callback makes it flexible to reject any given memory range.
>>>
>>>>
>>>> If it's only boot memory, we should disallow offlining instead via a
>>>> memory notifier - much cleaner.
>>>
>>> Dont have much detail understanding of MMU notifier mechanism but from some
>>> initial reading, it seems like we need to have a mm_struct for a notifier
>>> to monitor various events on the page table. Just wondering how a physical
>>> memory range like boot memory can be monitored because it can be used both
>>> for for kernel (init_mm) or user space process at same time. Is there some
>>> mechanism we could do this ?
>>>
>>>>
>>>>>
>>>>> Current arch call back arch_remove_memory() is too late in the process to
>>>>> abort memory hot removal as memory block devices and firmware memory map
>>>>> entries would have already been removed. Platforms should be able to abort
>>>>> the process before taking the mem_hotplug_lock with mem_hotplug_begin().
>>>>> This essentially requires a new arch callback for memory range validation.
>>>>
>>>> I somewhat dislike this very much. Memory removal should never fail if
>>>> used sanely. See e.g., __remove_memory(), it will BUG() whenever
>>>> something like that would strike.
>>>>
>>>>>
>>>>> This differentiates memory range validation between memory hot add and hot
>>>>> remove paths before carving out a new helper check_hotremove_memory_range()
>>>>> which incorporates a new arch callback. This call back provides platforms
>>>>> an opportunity to refuse memory removal at the very onset. In future the
>>>>> same principle can be extended for memory hot add path if required.
>>>>>
>>>>> Platforms can choose to override this callback in order to reject specific
>>>>> memory ranges from removal or can just fallback to a default implementation
>>>>> which allows removal of all memory ranges.
>>>>
>>>> I suspect we want really want to disallow offlining instead. E.g., I
>>>
>>> If boot memory pages can be prevented from being offlined for sure, then it
>>> would indirectly definitely prevent hot remove process as well.
>>>
>>>> remember s390x does that with certain areas needed for dumping/kexec.
>>>
>>> Could not find any references to mmu_notifier in arch/s390 or any other arch
>>> for that matter apart from KVM (which has an user space component), could you
>>> please give some pointers ?
>>
>> Memory (hotplug) notifier, not MMU notifier :)
> 
> They are so similarly named :)
> 
>>
>> Not on my notebook right now, grep for MEM_GOING_OFFLINE, that should be it.
>>
> 
> Got it, thanks ! But we will still need boot memory enumeration via MEMBLOCK_BOOT
> to reject affected offline requests in the callback.

Do you really need that?

We have SECTION_IS_EARLY. You could iterate all involved sections (for
which you are getting notified) and check if any one of these is marked
SECTION_IS_EARLY. then, it was added during boot and not via add_memory().


-- 
Thanks,

David / dhildenb


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-01-13 10:38 UTC|newest]

Thread overview: 43+ 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 ` 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  3:09   ` Anshuman Khandual
2020-01-10  8:42   ` David Hildenbrand
2020-01-10  8:42     ` David Hildenbrand
2020-01-13  9:11     ` Anshuman Khandual
2020-01-13  9:11       ` Anshuman Khandual
2020-01-13  9:14       ` David Hildenbrand
2020-01-13  9:14         ` David Hildenbrand
2020-01-13  9:50         ` Anshuman Khandual
2020-01-13  9:50           ` Anshuman Khandual
2020-01-13 10:37           ` David Hildenbrand [this message]
2020-01-13 10:37             ` David Hildenbrand
2020-01-14  2:13             ` Anshuman Khandual
2020-01-14  2:13               ` Anshuman Khandual
2020-01-14 11:09               ` Anshuman Khandual
2020-01-14 11:09                 ` Anshuman Khandual
2020-01-14 12:30                 ` David Hildenbrand
2020-01-14 12:30                   ` David Hildenbrand
2020-01-11 14:11   ` kbuild test robot
2020-01-11 14:11     ` kbuild test robot
2020-01-11 14:11     ` kbuild test robot
2020-01-13  4:06     ` Anshuman Khandual
2020-01-13  4:06       ` Anshuman Khandual
2020-01-13  4:06       ` Anshuman Khandual
2020-01-11 19:49   ` kbuild test robot
2020-01-11 19:49     ` kbuild test robot
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-10  3:09   ` Anshuman Khandual
2020-01-13  7:37   ` Mike Rapoport
2020-01-13  7:37     ` Mike Rapoport
2020-01-13  8:43     ` Anshuman Khandual
2020-01-13  8:43       ` Anshuman Khandual
2020-01-13  8:57       ` David Hildenbrand
2020-01-13  8:57         ` David Hildenbrand
2020-01-10  3:09 ` [PATCH V11 3/5] of/fdt: Mark boot memory with MEMBLOCK_BOOT Anshuman Khandual
2020-01-10  3:09   ` 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   ` Anshuman Khandual
2020-01-10  3:09 ` [PATCH V11 5/5] arm64/mm: Enable memory hot remove Anshuman Khandual
2020-01-10  3:09   ` 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=19194427-1295-3596-2c2c-463c4adf4f35@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=dhildenb@redhat.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=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 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.