Already two people (including me) tried to offline subsections, because
the function looks like it can deal with it. But we really can only
online/offline full sections that are properly aligned (e.g., we can only
mark full sections online/offline via SECTION_IS_ONLINE).
Add a simple safety net to document the restriction now. Current users
(core and powernv/memtrace) respect these restrictions.
Acked-by: Michal Hocko <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Wei Yang <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Pankaj Gupta <[email protected]>
Cc: Oscar Salvador <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
---
mm/memory_hotplug.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c781d386d87f9..6856702af68d9 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -801,6 +801,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
int ret;
struct memory_notify arg;
+ /* We can only online full sections (e.g., SECTION_IS_ONLINE) */
+ if (WARN_ON_ONCE(!nr_pages ||
+ !IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION)))
+ return -EINVAL;
+
mem_hotplug_begin();
/* associate pfn range with the zone */
@@ -1483,6 +1488,11 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
struct memory_notify arg;
char *reason;
+ /* We can only offline full sections (e.g., SECTION_IS_ONLINE) */
+ if (WARN_ON_ONCE(!nr_pages ||
+ !IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION)))
+ return -EINVAL;
+
mem_hotplug_begin();
/*
--
2.26.2
On Wed, Aug 19, 2020 at 07:59:49PM +0200, David Hildenbrand wrote:
> Already two people (including me) tried to offline subsections, because
> the function looks like it can deal with it. But we really can only
> online/offline full sections that are properly aligned (e.g., we can only
> mark full sections online/offline via SECTION_IS_ONLINE).
>
> Add a simple safety net to document the restriction now. Current users
> (core and powernv/memtrace) respect these restrictions.
It's been a while since I looked at sub-section handling stuff so sorry to ask
this, but was it true that we can hot-{remove,add} sub-section granularity, while
we can only online /offline on section granularity?
>
> Acked-by: Michal Hocko <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: Wei Yang <[email protected]>
> Cc: Baoquan He <[email protected]>
> Cc: Pankaj Gupta <[email protected]>
> Cc: Oscar Salvador <[email protected]>
> Signed-off-by: David Hildenbrand <[email protected]>
Reviewed-by: Oscar Salvador <[email protected]>
--
Oscar Salvador
SUSE L3
On Mon, Aug 24, 2020 at 12:39:18PM +0200, Oscar Salvador wrote:
>On Wed, Aug 19, 2020 at 07:59:49PM +0200, David Hildenbrand wrote:
>> Already two people (including me) tried to offline subsections, because
>> the function looks like it can deal with it. But we really can only
>> online/offline full sections that are properly aligned (e.g., we can only
>> mark full sections online/offline via SECTION_IS_ONLINE).
>>
>> Add a simple safety net to document the restriction now. Current users
>> (core and powernv/memtrace) respect these restrictions.
>
>It's been a while since I looked at sub-section handling stuff so sorry to ask
>this, but was it true that we can hot-{remove,add} sub-section granularity, while
>we can only online /offline on section granularity?
>
Seems you are right.
>>
>> Acked-by: Michal Hocko <[email protected]>
>> Cc: Andrew Morton <[email protected]>
>> Cc: Michal Hocko <[email protected]>
>> Cc: Wei Yang <[email protected]>
>> Cc: Baoquan He <[email protected]>
>> Cc: Pankaj Gupta <[email protected]>
>> Cc: Oscar Salvador <[email protected]>
>> Signed-off-by: David Hildenbrand <[email protected]>
>
>Reviewed-by: Oscar Salvador <[email protected]>
>
>
>--
>Oscar Salvador
>SUSE L3
--
Wei Yang
Help you, Help me
On 25.08.20 04:11, Wei Yang wrote:
> On Mon, Aug 24, 2020 at 12:39:18PM +0200, Oscar Salvador wrote:
>> On Wed, Aug 19, 2020 at 07:59:49PM +0200, David Hildenbrand wrote:
>>> Already two people (including me) tried to offline subsections, because
>>> the function looks like it can deal with it. But we really can only
>>> online/offline full sections that are properly aligned (e.g., we can only
>>> mark full sections online/offline via SECTION_IS_ONLINE).
>>>
>>> Add a simple safety net to document the restriction now. Current users
>>> (core and powernv/memtrace) respect these restrictions.
>>
>> It's been a while since I looked at sub-section handling stuff so sorry to ask
>> this, but was it true that we can hot-{remove,add} sub-section granularity, while
>> we can only online /offline on section granularity?
>>
Yes, we can hot-{remove,add} sub-section granularity ZONE_DEVICE memory,
but not memory to be managed by the buddy.
Examples are
- Memory block devices span 1..X sections and can either be
online/offline
- We can only mark full sections to be online/offline in sparsemem
- Besides section handling, current onlining/offlining code could only
work in MAX_ORDER - 1 granularity, not necessarily sub-section
granularity.
Thanks for having a look.
>
> Seems you are right.
--
Thanks,
David / dhildenb