Re: [PATCH] printk: Correctly handle preemption in console_unlock()
From: Tetsuo Handa
Date: Mon Jan 16 2017 - 08:41:19 EST
Sergey Senozhatsky wrote:
> On (01/16/17 12:38), Petr Mladek wrote:
> > > apart from that, Tetsuo wasn't really happy with the patch
> > > http://www.spinics.net/lists/linux-mm/msg103099.html
> >
> > The complain is questionable. If a code is sensitive for preemption,
> > it should disable preemption.
> >
> > Another question is if people expect that printk() would call
> > cond_resched() or preempt.
>
> my assumption would be that probably people expect printk to work
> asap.
The code executed with oom_lock held is sensitive for preemption. I tried
to disable preemption, but it was not accepted. What is so sorry is that
this is not really a problem of printk() because sleeping for minutes
(presumably forever) with oom_lock held is triggerable without printk().
It is a problem of memory page allocator which consumes a lot of CPU time
for pointless direct reclaim rather than giving CPU time to a thread which
held the oom_lock. I tried to wait for oom_lock in order to give CPU time
to the thread holding the oom_lock, but it was not accepted neither.