Re: [patch V2 1/2] mm: swap: Provide lru_add_drain_all_cpuslocked()

From: Thomas Gleixner
Date: Tue Jul 04 2017 - 08:49:21 EST

On Tue, 4 Jul 2017, Michal Hocko wrote:
> On Tue 04-07-17 11:32:33, Thomas Gleixner wrote:
> > The rework of the cpu hotplug locking unearthed potential deadlocks with
> > the memory hotplug locking code.
> >
> > The solution for these is to rework the memory hotplug locking code as well
> > and take the cpu hotplug lock before the memory hotplug lock in
> > mem_hotplug_begin(), but this will cause a recursive locking of the cpu
> > hotplug lock when the memory hotplug code calls lru_add_drain_all().
> >
> > Split out the inner workings of lru_add_drain_all() into
> > lru_add_drain_all_cpuslocked() so this function can be invoked from the
> > memory hotplug code with the cpu hotplug lock held.
> You have added callers in the later patch in the series AFAICS which
> is OK but I think it would be better to have them in this patch
> already. Nothing earth shattering (maybe a rebase artifact).

The requirement for changing that comes with the extra hotplug locking in
mem_hotplug_begin(). That is required to establish the proper lock order
and then causes the recursive locking in the next patch. Adding the caller
here would be wrong, because then lru_add_drain_all_cpuslocked() would be
called unprotected. Hens and eggs as usual :)