On Wed 21-11-18 02:44:35, Wei Yang wrote: > On Tue, Nov 20, 2018 at 08:31:41AM +0100, Michal Hocko wrote: > >On Tue 20-11-18 09:48:22, Wei Yang wrote: > >> After memory hot-added, users could online pages through sysfs, and this > >> could be done in parallel. > >> > >> In case two threads online pages in two different empty zones at the > >> same time, there would be a contention to update the nr_zones. > > > >No, this shouldn't be the case as I've explained in the original thread. > >We use memory hotplug lock over the online phase. So there shouldn't be > >any race possible. > > Sorry for misunderstanding your point. > > > > >On the other hand I would like to see the global lock to go away because > >it causes scalability issues and I would like to change it to a range > >lock. This would make this race possible. > > The global lock you want to remove is mem_hotplug_begin() ? Yes > > Hmm... my understanding may not correct. While mem_hotplug_begin() use > percpu lock, which means if there are two threads running on two > different cpus to online pages at the same time, they could get their > own lock? No. The per-cpu is a mere implementation detail on how the synchronization is done. Only one path might aquire the exclusive lock. -- Michal Hocko SUSE Labs