Re: [PATCH] net/skbuff: silence warnings under memory pressure

From: Qian Cai
Date: Wed Sep 04 2019 - 08:14:28 EST


On Wed, 2019-09-04 at 16:43 +0900, Sergey Senozhatsky wrote:
> On (09/04/19 16:19), Sergey Senozhatsky wrote:
> > Hmm. I need to look at this more... wake_up_klogd() queues work only once
> > on particular CPU: irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
> >
> > bool irq_work_queue()
> > {
> > /* Only queue if not already pending */
> > if (!irq_work_claim(work))
> > return false;
> >
> > __irq_work_queue_local(work);
> > }
>
> Plus one more check - waitqueue_active(&log_wait). printk() adds
> pending irq_work only if there is a user-space process sleeping on
> log_wait and irq_work is not already scheduled. If the syslog is
> active or there is noone to wakeup then we don't queue irq_work.

Another possibility for this potential livelock is that those printk() from
warn_alloc(), dump_stack() and show_mem() increase the time it needs to process
build_skb() allocation failures significantly under memory pressure. As the
result, ksoftirqd() could be rescheduled during that time via a different CPU
(this is a large x86 NUMA system anyway),

[83605.577256][ÂÂÂC31]ÂÂrun_ksoftirqd+0x1f/0x40
[83605.577256][ÂÂÂC31]ÂÂsmpboot_thread_fn+0x255/0x440
[83605.577256][ÂÂÂC31]ÂÂkthread+0x1df/0x200
[83605.577256][ÂÂÂC31]ÂÂret_from_fork+0x35/0x40

In addition, those printk() will deal with console drivers or even a networking
console, so it is probably not unusual that it could call irq_exit()-
>__do_softirq() at one point and then this livelock.