Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1391580ybe; Fri, 6 Sep 2019 17:16:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBdpD6rs/DHt0tav3Gg/IEjswZqDHivPcri1ME2bOm3+ORJC0lpWOMffAvlSTCUmXj7Imf X-Received: by 2002:a17:90a:b118:: with SMTP id z24mr12570558pjq.79.1567815388572; Fri, 06 Sep 2019 17:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567815388; cv=none; d=google.com; s=arc-20160816; b=Ehk0zP+OeOwnkbEI3V3d4Hyd8mBY/MsabQTHrmgT/rMbXtj46M/ICr/UDkX9J1/VvC senUkCjpYMFOj/eJe25bCooFQKdu9HT/tRkLNXoicsVSa5j5G+U1+tV7+GOPECwx/PrQ Q2dpG+RILggnmGDh7fPNc0tszyr4ASs+PS6LXAtBHVw8pRIjzDbFLuCp2chO9jMH+14H 9ufPLGshg3yK/GmU+Z6M1rkKyWsIZt9tFS6EIX3ihUnh0NIN/xcrB6vnvCA5OfB5j7Dg UDstSYzHGik8sv+x1mmoByPLF8fgvQoYwdLUcEUwV79hy45CTn1YdMsVaWKM3hhJOzdg nI0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qXtP6xYkBGGZknzbn7M9UxS1XaShk09zMRzhcpGzR80=; b=DL09lphlm8KrssUJGTXmOPSeOAtcUOjt6gsV72iHrjANEIv9Gu9ceyfBWevPNBUoBI afPaNb26MPwk38i6ao0E+idNoVb/a8EW9RRZ+m1WJncVMXXdktfV70vsMGKIMOxB0xgR 1aq0lmmUzJd8y7we/AsxGH4jrb2QMXExHnZho6JUbtzSBxX8jD4fThgijKXqjLQImFVc SOec3D5CgSISnFLHIHwqZ7h2G2HtiGgsPCgR3gccBYSF1u6o5mVN0I/p1khIm6Onc8z8 4Hl8QMBTjWXbM27o0K/EUoRgALH6nbEXr8BYAtuoIDuT+CISTJFAGJTLU0wG4p0hX1EB hP0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z25si7103054pfa.78.2019.09.06.17.16.13; Fri, 06 Sep 2019 17:16:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392232AbfIFOzg (ORCPT + 99 others); Fri, 6 Sep 2019 10:55:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:58132 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725872AbfIFOzg (ORCPT ); Fri, 6 Sep 2019 10:55:36 -0400 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 79BDCAC67; Fri, 6 Sep 2019 14:55:34 +0000 (UTC) Date: Fri, 6 Sep 2019 16:55:33 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: Steven Rostedt , Qian Cai , davem@davemloft.net, Eric Dumazet , Sergey Senozhatsky , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] net/skbuff: silence warnings under memory pressure Message-ID: <20190906145533.4uw43a5pvsawmdov@pathway.suse.cz> References: <1567546948.5576.68.camel@lca.pw> <20190904061501.GB3838@dhcp22.suse.cz> <20190904064144.GA5487@jagdpanzerIV> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190905113208.GA521@jagdpanzerIV> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2019-09-05 20:32:08, Sergey Senozhatsky wrote: > On (09/04/19 16:42), Qian Cai wrote: > > > Let me think more. > > > > To summary, those look to me are all good long-term improvement that would > > reduce the likelihood of this kind of livelock in general especially for other > > unknown allocations that happen while processing softirqs, but it is still up to > > the air if it fixes it 100% in all situations as printk() is going to take more > > time > > Well. So. I guess that we don't need irq_work most of the time. > > We need to queue irq_work for "safe" wake_up_interruptible(), when we > know that we can deadlock in scheduler. IOW, only when we are invoked > from the scheduler. Scheduler has printk_deferred(), which tells printk() > that it cannot do wake_up_interruptible(). Otherwise we can just use > normal wake_up_process() and don't need that irq_work->wake_up_interruptible() > indirection. The parts of the scheduler, which by mistake call plain printk() > from under pi_lock or rq_lock have chances to deadlock anyway and should > be switched to printk_deferred(). > > I think we can queue significantly much less irq_work-s from printk(). > > Petr, Steven, what do you think? > > Something like this. Call wake_up_interruptible(), switch to > wake_up_klogd() only when called from sched code. Replacing irq_work_queue() with wake_up_interruptible() looks dangerous to me. As a result, all "normal" printk() calls from the scheduler code will deadlock. There is almost always a userspace logger registered. By "normal" I mean anything that is not printk_deferred(). For example, any WARN() from sheduler will cause a deadlock. We will not even have chance to catch these problems in advance by lockdep. The difference is that console_unlock() calls wake_up_process() only when there is a waiter. And the hard console_lock() is not called that often. Honestly, scheduling IRQ looks like the most lightweight and reliable solution for offloading. We are in big troubles if we could not use it in printk() code. IMHO, the best solution is to ratelimit the warnings about the allocation failures. It does not make sense to repeat the same warning again and again. We might need a better ratelimiting API if the current one is not reliable. Best Regards, Petr