arg is the notifier arg. This function is just wrapping up the GOING_ONLINE notifier. The code is just a copy, so it isn't doing anything it wasn't doing before.

The original code also recycles arg for the ONLINE notifier, but that seemed unnecessary.

> This look OK, but it does add ~45 lines of code, and I'm not immediately> sure how you're going to use it. Could you address that a bit?>

Sure. When the balloon driver wants to increase the domain's size, but it finds its run out of page structures to grow into, it hotplug-adds some memory. This code uses the add_memory_resource() function I posted the patch for yesterday. (Error-checking removed for brevity.)

> I do kinda wish you'd take a real hard look at what the new functions> are doing now. I'm not sure their current names are very good.>

You're right. This is very much a first pass.

>> +/* Grow the zone to fit the expected amount of memory being added */>> +static struct zone *online_pages_zone(unsigned long pfn, unsigned long nr_pages)>> >> The comment is good, but the function name is not. :) How about> grow_zone_span() or something?>

Sure. I'm not really sure what the bookkeeping its doing really means though.

>> +/* Mark a set of pages as online */>> +unsigned long mark_pages_onlined(unsigned long pfn, unsigned long nr_pages)>> >> Isn't the comment on this one a bit redundant? :)>> This looks to me to have become the real online_pages() now. This> function is what goes and individually onlines pages. If someone was> trying to figure out whether to call online_pages() or> mark_pages_onlined(), which one would they know to call?>

Yep. My goal in this was to extract he behaviours I need without affecting any other users. online_pages() is definitely a trivial helper function now, and it could be removed without causing much damage to its couple of callers.

Perhaps. Or we could get rid of it altogether. There's only a single user of the notifier (mm/slub.c), and given that it doesn't even use the MEM_ONLINE notifier, we could just drop this part. Seems like it would be simpler to just have the hotplug code call directly into slub if that's what it needs...

My big remaining problem is how to disable the sysfs interface for this memory. I need to prevent any onlining via /sys/device/system/memory.

Looks like I need to modify register_new_memory() to pass a "don't change state" flag, and stash it in struct memory_block so that store_mem_state() knows to ignore any state changes. But it's not clear how I can get that information down into __add_section()... I guess I just need to propagate it down from add_memory().