Re: [PATCH] mm,page_alloc: Serialize out_of_memory() and allocation stall messages.
From: Tetsuo Handa
Date: Wed Oct 25 2017 - 06:47:13 EST
Tetsuo Handa wrote:
> While warn_alloc() messages are completely unreadable, what we should note are that
>
> (a) out_of_memory() => oom_kill_process() => dump_header() => show_mem() => printk()
> got stuck at console_unlock() despite this is schedulable context.
>
> ----------
> 2180: for (;;) {
> 2181: struct printk_log *msg;
> 2182: size_t ext_len = 0;
> 2183: size_t len;
> 2184:
> 2185: printk_safe_enter_irqsave(flags);
> 2186: raw_spin_lock(&logbuf_lock);
> (...snipped...)
> 2228: console_idx = log_next(console_idx);
> 2229: console_seq++;
> 2230: raw_spin_unlock(&logbuf_lock);
> 2231:
> 2232: stop_critical_timings(); /* don't trace print latency */
> 2233: call_console_drivers(ext_text, ext_len, text, len);
> 2234: start_critical_timings();
> 2235: printk_safe_exit_irqrestore(flags); // console_unlock+0x24e/0x4c0 is here.
> 2236:
> 2237: if (do_cond_resched)
> 2238: cond_resched();
> 2239: }
> ----------
It turned out that cond_resched() was not called due to do_cond_resched == 0 due to
preemptible() == 0 due to CONFIG_PREEMPT_COUNT=n despite CONFIG_PREEMPT_VOLUNTARY=y,
for CONFIG_PREEMPT_VOLUNTARY itself does not select CONFIG_PREEMPT_COUNT. Surprising...