2014-06-11 09:13:38

by Zhang Zhen

[permalink] [raw]
Subject: Proposal to realize hot-add *several sections one time*

Hi,

Now we can hot-add memory by

% echo start_address_of_new_memory > /sys/devices/system/memory/probe

Then, [start_address_of_new_memory, start_address_of_new_memory +
memory_block_size] memory range is hot-added.

But we can only hot-add *one section one time* by this way.
Whether we can add an argument on behalf of the count of the sections to add ?
So we can can hot-add *several sections one time*. Just like:

% echo start_address_of_new_memory count_of_sections > /sys/devices/system/memory/probe

Then, [start_address_of_new_memory, start_address_of_new_memory +
count_of_sections * memory_block_size] memory range is hot-added.

If this proposal is reasonable, i will send a patch to realize it.

Any suggestions ?

Best regards.


2014-06-11 22:08:44

by David Rientjes

[permalink] [raw]
Subject: Re: Proposal to realize hot-add *several sections one time*

On Wed, 11 Jun 2014, Zhang Zhen wrote:

> Hi,
>
> Now we can hot-add memory by
>
> % echo start_address_of_new_memory > /sys/devices/system/memory/probe
>
> Then, [start_address_of_new_memory, start_address_of_new_memory +
> memory_block_size] memory range is hot-added.
>
> But we can only hot-add *one section one time* by this way.
> Whether we can add an argument on behalf of the count of the sections to add ?
> So we can can hot-add *several sections one time*. Just like:
>

Not necessarily true, it depends on sections_per_block. Don't believe
Documentation/memory-hotplug.txt that suggests this is only for powerpc,
x86 and sh allow this interface as well.

> % echo start_address_of_new_memory count_of_sections > /sys/devices/system/memory/probe
>
> Then, [start_address_of_new_memory, start_address_of_new_memory +
> count_of_sections * memory_block_size] memory range is hot-added.
>
> If this proposal is reasonable, i will send a patch to realize it.
>

The problem is knowing how much memory is being onlined so that you can
definitively determine what count_of_sections should be. The number of
pages per memory section depends on PAGE_SIZE and SECTION_SIZE_BITS which
differ depending on the architectures that support this interface. So if
you support count_of_sections, it would return errno even though you have
onlined some sections.

2014-06-11 22:15:18

by David Rientjes

[permalink] [raw]
Subject: [patch] mm, hotplug: probe interface is available on several platforms

Documentation/memory-hotplug.txt incorrectly states that the memory driver
"probe" interface is only supported on powerpc and is vague about its
application on x86. Clarify the platforms that make this interface
available if memory hotplug is enabled.

Signed-off-by: David Rientjes <[email protected]>
---
Documentation/memory-hotplug.txt | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -209,15 +209,12 @@ If memory device is found, memory hotplug code will be called.

4.2 Notify memory hot-add event by hand
------------
-On powerpc, the firmware does not notify a memory hotplug event to the kernel.
-Therefore, "probe" interface is supported to notify the event to the kernel.
-This interface depends on CONFIG_ARCH_MEMORY_PROBE.
-
-CONFIG_ARCH_MEMORY_PROBE is supported on powerpc only. On x86, this config
-option is disabled by default since ACPI notifies a memory hotplug event to
-the kernel, which performs its hotplug operation as the result. Please
-enable this option if you need the "probe" interface for testing purposes
-on x86.
+On some architectures, the firmware may not notify the kernel of a memory
+hotplug event. Therefore, the memory "probe" interface is supported to
+explicitly notify the kernel. This interface depends on
+CONFIG_ARCH_MEMORY_PROBE and can be configured on powerpc, sh, and x86
+if hotplug is supported, although for x86 this should be handled by ACPI
+notification.

Probe interface is located at
/sys/devices/system/memory/probe

2014-06-11 22:22:15

by Dave Hansen

[permalink] [raw]
Subject: Re: [patch] mm, hotplug: probe interface is available on several platforms

On 06/11/2014 03:15 PM, David Rientjes wrote:
> +CONFIG_ARCH_MEMORY_PROBE and can be configured on powerpc, sh, and x86
> +if hotplug is supported, although for x86 this should be handled by ACPI
> +notification.

Looks like a good change, in general.

My only nit is that this implies that all hotplug on x86 is ACPI-based,
which isn't true. Xen, at least, has an extension to its ballooning
that does hotplugs without ACPI.

2014-06-12 02:41:53

by Zhang Zhen

[permalink] [raw]
Subject: Re: Proposal to realize hot-add *several sections one time*

On 2014/6/12 6:08, David Rientjes wrote:
> On Wed, 11 Jun 2014, Zhang Zhen wrote:
>
>> Hi,
>>
>> Now we can hot-add memory by
>>
>> % echo start_address_of_new_memory > /sys/devices/system/memory/probe
>>
>> Then, [start_address_of_new_memory, start_address_of_new_memory +
>> memory_block_size] memory range is hot-added.
>>
>> But we can only hot-add *one section one time* by this way.
>> Whether we can add an argument on behalf of the count of the sections to add ?
>> So we can can hot-add *several sections one time*. Just like:
>>
>
> Not necessarily true, it depends on sections_per_block. Don't believe
> Documentation/memory-hotplug.txt that suggests this is only for powerpc,
> x86 and sh allow this interface as well.
>
>> % echo start_address_of_new_memory count_of_sections > /sys/devices/system/memory/probe
>>
>> Then, [start_address_of_new_memory, start_address_of_new_memory +
>> count_of_sections * memory_block_size] memory range is hot-added.
>>
>> If this proposal is reasonable, i will send a patch to realize it.
>>
>
> The problem is knowing how much memory is being onlined so that you can
> definitively determine what count_of_sections should be. The number of
> pages per memory section depends on PAGE_SIZE and SECTION_SIZE_BITS which
> differ depending on the architectures that support this interface. So if
> you support count_of_sections, it would return errno even though you have
> onlined some sections.
>
Hum, sorry.
My expression is not right. The count of sections one time hot-added
depends on sections_per_block.

Now we are porting the memory-hotplug to arm.
But we can only hot-add *fixed number of sections one time* on particular architecture.

Whether we can add an argument on behalf of the count of the blocks to add ?

% echo start_address_of_new_memory count_of_blocks > /sys/devices/system/memory/probe

Then, [start_address_of_new_memory, start_address_of_new_memory + count_of_blocks * memory_block_size]
memory range is hot-added.

So user don't need execute several times of echo when they want to hot add multi-block size memory.

Any comments are welcome.

Best regards!
>

2014-06-12 07:07:32

by David Rientjes

[permalink] [raw]
Subject: Re: Proposal to realize hot-add *several sections one time*

On Thu, 12 Jun 2014, Zhang Zhen wrote:

> >> % echo start_address_of_new_memory count_of_sections > /sys/devices/system/memory/probe
> >>
> >> Then, [start_address_of_new_memory, start_address_of_new_memory +
> >> count_of_sections * memory_block_size] memory range is hot-added.
> >>
> >> If this proposal is reasonable, i will send a patch to realize it.
> >>
> >
> > The problem is knowing how much memory is being onlined so that you can
> > definitively determine what count_of_sections should be. The number of
> > pages per memory section depends on PAGE_SIZE and SECTION_SIZE_BITS which
> > differ depending on the architectures that support this interface. So if
> > you support count_of_sections, it would return errno even though you have
> > onlined some sections.
> >
> Hum, sorry.
> My expression is not right. The count of sections one time hot-added
> depends on sections_per_block.
>

Ok, so you know specifically what sections_per_block is for your platform
so you know exactly how many sections need to be added.

> Now we are porting the memory-hotplug to arm.
> But we can only hot-add *fixed number of sections one time* on particular architecture.
>
> Whether we can add an argument on behalf of the count of the blocks to add ?
>
> % echo start_address_of_new_memory count_of_blocks > /sys/devices/system/memory/probe
>
> Then, [start_address_of_new_memory, start_address_of_new_memory + count_of_blocks * memory_block_size]
> memory range is hot-added.
>

As I said, if the above returns errno at some point, it still can result
in some sections being onlined. To be clear: if
"echo 0x10000000 > /sys/devices/system/memory/probe" fails, the section
starting at address 0x10000000 failed to be onlined for the reason
specified by errno. If we follow your suggestion to specify how many
sections to online, if
"echo '0x10000000 16' > /sys/devices/system/memory/probe" fails, eight
sections could have been successfully onlined at address 0x10000000 and
then we encountered a failure (perhaps because the next sections were
already onlined, we get an -EEXIST). We don't know what we successfully
onlined.

This could be mitigated, but there would have to be a convincing reason
that this is better than using the currently functionally in a loop and
properly handling your error codes.

2014-06-13 07:32:40

by Zhang Zhen

[permalink] [raw]
Subject: Re: Proposal to realize hot-add *several sections one time*

On 2014/6/12 15:07, David Rientjes wrote:
> On Thu, 12 Jun 2014, Zhang Zhen wrote:
>
>>>> % echo start_address_of_new_memory count_of_sections > /sys/devices/system/memory/probe
>>>>
>>>> Then, [start_address_of_new_memory, start_address_of_new_memory +
>>>> count_of_sections * memory_block_size] memory range is hot-added.
>>>>
>>>> If this proposal is reasonable, i will send a patch to realize it.
>>>>
>>>
>>> The problem is knowing how much memory is being onlined so that you can
>>> definitively determine what count_of_sections should be. The number of
>>> pages per memory section depends on PAGE_SIZE and SECTION_SIZE_BITS which
>>> differ depending on the architectures that support this interface. So if
>>> you support count_of_sections, it would return errno even though you have
>>> onlined some sections.
>>>
>> Hum, sorry.
>> My expression is not right. The count of sections one time hot-added
>> depends on sections_per_block.
>>
>
> Ok, so you know specifically what sections_per_block is for your platform
> so you know exactly how many sections need to be added.
>
>> Now we are porting the memory-hotplug to arm.
>> But we can only hot-add *fixed number of sections one time* on particular architecture.
>>
>> Whether we can add an argument on behalf of the count of the blocks to add ?
>>
>> % echo start_address_of_new_memory count_of_blocks > /sys/devices/system/memory/probe
>>
>> Then, [start_address_of_new_memory, start_address_of_new_memory + count_of_blocks * memory_block_size]
>> memory range is hot-added.
>>
>
> As I said, if the above returns errno at some point, it still can result
> in some sections being onlined. To be clear: if
> "echo 0x10000000 > /sys/devices/system/memory/probe" fails, the section
> starting at address 0x10000000 failed to be onlined for the reason
> specified by errno. If we follow your suggestion to specify how many
> sections to online, if
> "echo '0x10000000 16' > /sys/devices/system/memory/probe" fails, eight
> sections could have been successfully onlined at address 0x10000000 and
> then we encountered a failure (perhaps because the next sections were
> already onlined, we get an -EEXIST). We don't know what we successfully
> onlined.
>
> This could be mitigated, but there would have to be a convincing reason
> that this is better than using the currently functionally in a loop and
> properly handling your error codes.

Hi David,

I think you are right.

We had better to use the currently functionally in a loop if we need to add
several blocks.
In this way, we can get an errno in time if a block failed to be onlined.

Thanks for your comments. I got it.

>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
>
>