Re: [PATCH v2] mm/page_isolation: fix a deadlock with printk()

From: Qian Cai
Date: Thu Oct 10 2019 - 10:47:44 EST


On Thu, 2019-10-10 at 16:18 +0200, Michal Hocko wrote:
> On Thu 10-10-19 09:11:52, Qian Cai wrote:
> > On Thu, 2019-10-10 at 12:59 +0200, Michal Hocko wrote:
> > > On Thu 10-10-19 05:01:44, Qian Cai wrote:
> > > >
> > > >
> > > > > On Oct 9, 2019, at 12:23 PM, Michal Hocko <mhocko@xxxxxxxxxx> wrote:
> > > > >
> > > > > If this was only about the memory offline code then I would agree. But
> > > > > we are talking about any printk from the zone->lock context and that is
> > > > > a bigger deal. Besides that it is quite natural that the printk code
> > > > > should be more universal and allow to be also called from the MM
> > > > > contexts as much as possible. If there is any really strong reason this
> > > > > is not possible then it should be documented at least.
> > > >
> > > > Where is the best place to document this? I am thinking about under
> > > > the âstruct zoneâ definitionâs lock field in mmzone.h.
> > >
> > > I am not sure TBH and I do not think we have reached the state where
> > > this would be the only way forward.
> >
> > How about I revised the changelog to focus on memory offline rather than making
> > a rule that nobody should call printk() with zone->lock held?
>
> If you are to remove the CONFIG_DEBUG_VM printk then I am all for it. I
> am still not convinced that fiddling with dump_page in the isolation
> code is justified though.

No, dump_page() there has to be fixed together for memory offline to be useful.
What's the other options it has here? By not holding zone->lock in dump_page()
from set_migratetype_isolate(), it even has a good side-effect to increase the
system throughput as dump_page() could be time-consuming. It may make the code a
bit cleaner by introducing a has_unmovable_pages_locked() version.