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

From: Michal Hocko
Date: Mon Oct 07 2019 - 07:37:14 EST


On Mon 07-10-19 07:04:00, Qian Cai wrote:
>
>
> > On Oct 7, 2019, at 4:07 AM, Michal Hocko <mhocko@xxxxxxxxxx> wrote:
> >
> > I do not think that removing the printk is the right long term solution.
> > While I do agree that removing the debugging printk __offline_isolated_pages
> > does make sense because it is essentially of a very limited use, this
> > doesn't really solve the underlying problem. There are likely other
> > printks from zone->lock. It would be much more saner to actually
> > disallow consoles to allocate any memory while printk is called from an
> > atomic context.
>
> No, there is only a handful of places called printk() from
> zone->lock. It is normal that the callers will quietly process
> âstruct zoneâ modification in a short section with zone->lock
> held.

It is extremely error prone to have any zone->lock vs. printk
dependency. I do not want to play an endless whack a mole.

> No, it is not about âallocate any memory while printk is called from an
> atomic contextâ. It is opposite lock chain from different processors which has the same effect. For example,
>
> CPU0: CPU1: CPU2:
> console_owner
> sclp_lock
> sclp_lock zone_lock
> zone_lock
> console_owner

Why would sclp_lock ever take a zone->lock (apart from an allocation).
So really if sclp_lock is a lock that might be taken from many contexts
and generate very subtle lock dependencies then it should better be
really careful what it is calling into.

In other words you are trying to fix a wrong end of the problem. Fix the
console to not allocate or depend on MM by other means.
--
Michal Hocko
SUSE Labs