[ add Stephen and Juergen ] On Mon, Feb 25, 2019 at 11:02 AM Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> wrote: > > This is a relatively small delta from v4. The review comments seem > to be settling down, so it seems like we should start thinking about > how this might get merged. Are there any objections to taking it in > via the nvdimm tree? > > Dan Williams, our intrepid nvdimm maintainer has said he would > appreciate acks on these from relevant folks before merging them. > Reviews/acks on any in the series would be welcome, but the last > two especially are lacking any non-Intel acks: > > mm/resource: let walk_system_ram_range() search child resources > dax: "Hotplug" persistent memory for use like normal RAM I've gone ahead and added this to the libnvdimm-for-next branch for wider exposure. Acks of course still welcome. Stephen, this collides with commit 357b4da50a62 "x86: respect memory size limiting via mem= parameter" in current -next. Here's my resolution for reference, basically just add the max_mem_size statement to Dave's rework. Holler if this causes any other problems. diff --cc mm/memory_hotplug.c index a9d5787044e1,b37f3a5c4833..c4f59ac21014 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@@ -102,28 -99,21 +102,24 @@@ u64 max_mem_size = U64_MAX /* add this memory to iomem resource */ static struct resource *register_memory_resource(u64 start, u64 size) { - struct resource *res, *conflict; + struct resource *res; + unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; + char *resource_name = "System RAM"; + if (start + size > max_mem_size) + return ERR_PTR(-E2BIG); + - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - if (!res) - return ERR_PTR(-ENOMEM); - - res->name = "System RAM"; - res->start = start; - res->end = start + size - 1; - res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; - conflict = request_resource_conflict(&iomem_resource, res); - if (conflict) { - if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) { - pr_debug("Device unaddressable memory block " - "memory hotplug at %#010llx !\n", - (unsigned long long)start); - } - pr_debug("System RAM resource %pR cannot be added\n", res); - kfree(res); + /* + * Request ownership of the new memory range. This might be + * a child of an existing resource that was present but + * not marked as busy. + */ + res = __request_region(&iomem_resource, start, size, + resource_name, flags); + + if (!res) { + pr_debug("Unable to reserve System RAM region: %016llx->%016llx\n", + start, start + size); return ERR_PTR(-EEXIST); } return res;