From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 429F1C432C0 for ; Tue, 19 Nov 2019 09:41:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1057122304 for ; Tue, 19 Nov 2019 09:41:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1057122304 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A10506B000A; Tue, 19 Nov 2019 04:41:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 999936B000D; Tue, 19 Nov 2019 04:41:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AFDA6B0010; Tue, 19 Nov 2019 04:41:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id 750CB6B000A for ; Tue, 19 Nov 2019 04:41:37 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 408CCA760 for ; Tue, 19 Nov 2019 09:41:37 +0000 (UTC) X-FDA: 76172534634.08.pest47_48430c797724a X-HE-Tag: pest47_48430c797724a X-Filterd-Recvd-Size: 3458 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Nov 2019 09:41:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E917CB28C; Tue, 19 Nov 2019 09:41:34 +0000 (UTC) Date: Tue, 19 Nov 2019 10:41:34 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Qian Cai , Steven Rostedt , Sergey Senozhatsky , Michal Hocko , Eric Dumazet , davem@davemloft.net, netdev@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net/skbuff: silence warnings under memory pressure Message-ID: <20191119094134.6hzbjc7l5ite6bpg@pathway.suse.cz> References:<20190904065455.GE3838@dhcp22.suse.cz> <20190904071911.GB11968@jagdpanzerIV> <20190904074312.GA25744@jagdpanzerIV> <1567599263.5576.72.camel@lca.pw> <20190904144850.GA8296@tigerII.localdomain> <1567629737.5576.87.camel@lca.pw> <20190905113208.GA521@jagdpanzerIV> <1573751570.5937.122.camel@lca.pw> <20191118152738.az364dczadskgimc@pathway.suse.cz> <20191119004119.GC208047@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To:<20191119004119.GC208047@google.com> User-Agent: NeoMutt/20170912 (1.9.0) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue 2019-11-19 09:41:19, Sergey Senozhatsky wrote: > On (19/11/18 16:27), Petr Mladek wrote: > > > > @@ -2027,8 +2027,11 @@ asmlinkage int vprintk_emit(int facility, int level, > > > > pending_output = (curr_log_seq != log_next_seq); > > > > logbuf_unlock_irqrestore(flags); > > > > > > > > + if (!pending_output) > > > > + return printed_len; > > > > + > > > > /* If called from the scheduler, we can not call up(). */ > > > > - if (!in_sched && pending_output) { > > > > + if (!in_sched) { > > > > /* > > > > * Disable preemption to avoid being preempted while holding > > > > * console_sem which would prevent anyone from printing to > > > > @@ -2043,10 +2046,11 @@ asmlinkage int vprintk_emit(int facility, int level, > > > > if (console_trylock_spinning()) > > > > console_unlock(); > > > > preempt_enable(); > > > > - } > > > > > > > > - if (pending_output) > > > > + wake_up_interruptible(&log_wait); > > > > I do not like this. As a result, normal printk() will always deadlock > > in the scheduler code, including WARN() calls. The chance of the > > deadlock is small now. It happens only when there is another > > process waiting for console_sem. > > Why would it *always* deadlock? If this is the case, why we don't *always* > deadlock doing the very same wake_up_process() from console_unlock()? I speak about _normal_ printk() and not about printk_deferred(). wake_up_process() is called in console_unlock() only when sem->wait_list is not empty, see up() in kernel/locking/semaphore.c. printk() itself uses console_trylock() and does not wait. I believe that this is the rason why printk_sched() was added so late in 2012. It was more than 10 years after adding the semaphore into console_unlock(). IMHO, the deadlock was rare. Of course, it was also hard to debug but it would not take 10 years. Best Regards, Petr