Re: [PATCH v2 2/3] mm/memory_hotplug: split memmap_on_memory requests across memblocks

Huang, Ying
2023-08-14T06:13:59Z

"Verma, Vishal L" <vishal.l.verma@intel.com> writes:

> On Mon, 2023-07-24 at 11:16 +0800, Huang, Ying wrote:
>> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>> >
>> > > @@ -1339,27 +1367,20 @@ int __ref add_memory_resource(int nid,
>> > > struct resource *res, mhp_t mhp_flags)
>> > > /*
>> > > * Self hosted memmap array
>> > > */
>> > > - if (mhp_flags & MHP_MEMMAP_ON_MEMORY) {
>> > > - if (!mhp_supports_memmap_on_memory(size)) {
>> > > - ret = -EINVAL;
>> > > + if ((mhp_flags & MHP_MEMMAP_ON_MEMORY) &&
>> > > + mhp_supports_memmap_on_memory(memblock_size)) {
>> > > + for (cur_start = start; cur_start < start + size;
>> > > + cur_start += memblock_size) {
>> > > + ret = add_memory_create_devices(nid,
>> > > group, cur_start,
>> > > + memblock_
>> > > size,
>> > > + mhp_flags
>> > > );
>> > > + if (ret)
>> > > + goto error;
>> > > + }
>> >
>> > We should handle the below error details here.
>> >
>> > 1) If we hit an error after some blocks got added, should we
>> > iterate over rest of the dev_dax->nr_range.
>> > 2) With some blocks added if we return a failure here, we remove
>> > the
>> > resource in dax_kmem. Is that ok?
>> >
>> > IMHO error handling with partial creation of memory blocks in a
>> > resource range should be
>> > documented with this change.
>>
>> Or, should we remove all added memory blocks upon error?
>>
> I didn't address these in v3 - I wasn't sure how we'd proceed here.
> Something obviously went very wrong and I'd imagine it is okay if this
> memory is unusable as a result.
>
> What woyuld removing the blocks we added look like? Just call
> try_remove_memory() from the error path in add_memory_resource()? (for
> a range of [start, cur_start) ?

I guess that we can just keep the original behavior. Originally, if
something goes wrong, arch_remove_memory() and remove_memory_block() (in
create_memory_block_devices()) will be called for all added memory
range. So, we should do that too?

--
Best Regards,
Huang, Ying