I think mem_hotplug_lock protects this case these days, though. I
don't
think we had it in the early days and were just slumming it with the
pgdat locks.
Yes, it does.
I really don't like the idea of removing the lock by just saying it
doesn't protect anything without doing some homework first, though. It
would actually be really nice to comment the entire call chain from the
mem_hotplug_lock acquisition to here. There is precious little
commenting in there and it could use some love.
[hot-add operation]
add_memory_resource : acquire mem_hotplug lock
arch_add_memory
add_pages
__add_pages
__add_section
sparse_add_one_section
sparse_init_one_section
[hot-remove operation]
__remove_memory : acquire mem_hotplug lock
arch_remove_memory
__remove_pages
__remove_section
sparse_remove_one_section
Both operations are serialized by the mem_hotplug lock, so they cannot
step on each other's feet.
Now, there seems to be an agreement/thought to remove the global
mem_hotplug lock, in favor of a range locking for hot-add/remove and
online/offline stage.
So, although removing the lock here is pretty straightforward, it does
not really get us closer to that goal IMHO, if that is what we want to
do in the end.